|
48 | 48 | from zipfile import ZipFile
|
49 | 49 |
|
50 | 50 | import mx
|
| 51 | +import mx_urlrewrites |
| 52 | + |
51 | 53 |
|
52 | 54 | class GradlePluginProject(mx.Distribution, mx.ClasspathDependency): # pylint: disable=too-many-instance-attributes
|
53 | 55 | """
|
@@ -252,6 +254,8 @@ def _as_gradle_path(p:str) -> str:
|
252 | 254 |
|
253 | 255 |
|
254 | 256 | class _GradleBuildTask(mx.ProjectBuildTask):
|
| 257 | + PLUGIN_PORTAL_URL = 'https://plugins.gradle.org/m2/' |
| 258 | + |
255 | 259 | def __init__(self, subject: GradlePluginProject, args):
|
256 | 260 | mx.ProjectBuildTask.__init__(self, args, 1, subject)
|
257 | 261 | 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):
|
403 | 407 | mx.logvv(properties)
|
404 | 408 |
|
405 | 409 | 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 |
406 | 424 | settings_path = os.path.join(self.subject.get_output_root(), "settings.gradle")
|
407 | 425 | with open(settings_path, 'w+') as f:
|
408 | 426 | f.write(settings)
|
|
0 commit comments