Skip to content

Commit 2730986

Browse files
committed
[GR-59841] GradlePluginProject use Gradle plugin portal through mx url rewrites.
PullRequest: graalpython/3583
2 parents ea82729 + fdf3b8a commit 2730986

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

mx.graalpython/mx_graalpython_gradleproject.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
from zipfile import ZipFile
4949

5050
import mx
51+
import mx_urlrewrites
52+
5153

5254
class GradlePluginProject(mx.Distribution, mx.ClasspathDependency): # pylint: disable=too-many-instance-attributes
5355
"""
@@ -252,6 +254,8 @@ def _as_gradle_path(p:str) -> str:
252254

253255

254256
class _GradleBuildTask(mx.ProjectBuildTask):
257+
PLUGIN_PORTAL_URL = 'https://plugins.gradle.org/m2/'
258+
255259
def __init__(self, subject: GradlePluginProject, args):
256260
mx.ProjectBuildTask.__init__(self, args, 1, subject)
257261
self.build_script_path = os.path.join(self.subject.get_output_root(), "build.gradle")
@@ -403,6 +407,20 @@ def _create_build_script(self, version: str | None = None):
403407
mx.logvv(properties)
404408

405409
settings = f'rootProject.name = "{self.subject.gradleProjectName}"'
410+
plugin_repo = mx_urlrewrites.rewriteurl(_GradleBuildTask.PLUGIN_PORTAL_URL)
411+
if plugin_repo != _GradleBuildTask.PLUGIN_PORTAL_URL:
412+
# Note: we are not including mavenCentral for ordinary dependencies,
413+
# so this should be the only repo that Gradle searches, so far we only
414+
# depend on one external plugin: java-gradle-plugin
415+
settings = textwrap.dedent(f'''
416+
pluginManagement {{
417+
repositories {{
418+
maven {{
419+
url = uri("{plugin_repo}")
420+
}}
421+
}}
422+
}}
423+
''') + settings
406424
settings_path = os.path.join(self.subject.get_output_root(), "settings.gradle")
407425
with open(settings_path, 'w+') as f:
408426
f.write(settings)

0 commit comments

Comments
 (0)