From 0ff740413100b7a662c9165d26e13a6cc5ce6ae5 Mon Sep 17 00:00:00 2001 From: Foivos Zakkak Date: Tue, 3 Feb 2026 13:35:29 +0200 Subject: [PATCH] Add support for custom Maven repository URLs --- src/mx/_impl/mx.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/mx/_impl/mx.py b/src/mx/_impl/mx.py index 6b599b67a..938d37c88 100755 --- a/src/mx/_impl/mx.py +++ b/src/mx/_impl/mx.py @@ -798,6 +798,7 @@ def format_help(self): MX_CACHE_DIR Override the default location of the mx download cache. Defaults to `~/.mx/cache`. MX_GLOBAL_ENV Override the default location of the global env file that is always loaded at startup. Defaults to `~/.mx/env`. Can be disabled by setting it to an empty string. + MX_MAVEN_REPO_URLS Comma-separated list of Maven repository base URLs. Defaults to Maven Central repositories. MX_GIT_CACHE Use a cache for git objects during clones. * Setting it to `reference` will clone repositories using the cache and let them reference the cache (if the cache gets deleted these repositories will be @@ -4534,10 +4535,26 @@ def update_file(path, content, showDiff=False): _distTemplates = dict() _licenses = dict() _repositories = dict() -_mavenRepoBaseURLs = [ - "https://repo1.maven.org/maven2/", - "https://search.maven.org/remotecontent?filepath=" -] + +_resolved_maven_repo_base_urls = False +def _get_maven_repo_base_urls(): + """ + Gets the Maven repository base URLs from the MX_MAVEN_REPO_URLS environment variable. + If not set, returns the default Maven Central repositories. + The environment variable should contain a comma-separated list of URLs. + """ + default_urls = [ + "https://repo1.maven.org/maven2/", + "https://search.maven.org/remotecontent?filepath=" + ] + global _resolved_maven_repo_base_urls + if _resolved_maven_repo_base_urls is False: + urls = get_env('MX_MAVEN_REPO_URLS') + if urls: + _resolved_maven_repo_base_urls = urls.split(',') + else: + _resolved_maven_repo_base_urls = default_urls + return _resolved_maven_repo_base_urls """ Map of the environment variables loaded by parsing the suites. @@ -11059,7 +11076,7 @@ def resolveLicenses(self): def maven_download_urls(groupId, artifactId, version, classifier=None, baseURL=None): if baseURL is None: - baseURLs = _mavenRepoBaseURLs + baseURLs = _get_maven_repo_base_urls() else: baseURLs = [baseURL] classifier = f'-{classifier}' if classifier else ''