Skip to content

Commit 133cdf2

Browse files
committed
dynamically add custom maven repos for standalone testing
(cherry picked from commit 84aef21)
1 parent 6364ed3 commit 133cdf2

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

graalpython/com.oracle.graal.python.test/src/tests/test_standalone.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@
4545

4646
is_enabled = 'ENABLE_STANDALONE_UNITTESTS' in os.environ and os.environ['ENABLE_STANDALONE_UNITTESTS'] == "true"
4747
MVN_CMD = [shutil.which('mvn')]
48-
if 'MAVEN_REPO_OVERRIDE' in os.environ:
49-
MVN_CMD += ['-Dmaven.repo.remote=' + os.environ['MAVEN_REPO_OVERRIDE']]
5048

5149
def run_cmd(cmd, env, cwd=None):
5250
process = subprocess.Popen(cmd, env=env, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, text=True)
@@ -110,6 +108,31 @@ def test_polyglot_app():
110108
out = run_cmd(cmd, env)
111109
assert "Creating polyglot java python application in directory " + target_dir in out
112110

111+
if custom_repos := os.environ.get("MAVEN_REPO_OVERRIDE"):
112+
repos = []
113+
for idx, custom_repo in enumerate(custom_repos.split(",")):
114+
repos.append(f"""
115+
<repository>
116+
<id>myrepo{idx}</id>
117+
<url>{custom_repo}</url>
118+
<releases>
119+
<enabled>true</enabled>
120+
</releases>
121+
<snapshots>
122+
<enabled>true</enabled>
123+
</snapshots>
124+
</repository>
125+
""")
126+
with open(os.path.join(target_dir, "pom.xml"), "r") as f:
127+
contents = f.read()
128+
with open(os.path.join(target_dir, "pom.xml"), "w") as f:
129+
f.write(contents.replace("</project>", """
130+
<repositories>
131+
""" + '\n'.join(repos) + """
132+
</repositories>
133+
</project>
134+
"""))
135+
113136
cmd = MVN_CMD + ["package", "-Pnative"]
114137
out = run_cmd(cmd, env, cwd=target_dir)
115138
assert "BUILD SUCCESS" in out

mx.graalpython/mx_graalpython.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1544,8 +1544,8 @@ def graalpython_gate_runner(args, tasks):
15441544
mx.maven_deploy(deploy_args)
15451545
# setup maven downloader overrides
15461546
env['MAVEN_REPO_OVERRIDE'] = ",".join([
1547-
mx_urlrewrites.rewriteurl('https://repo1.maven.org/maven2/'),
15481547
f"{pathlib.Path(path).as_uri()}/",
1548+
mx_urlrewrites.rewriteurl('https://repo1.maven.org/maven2/'),
15491549
])
15501550
env["org.graalvm.maven.downloader.version"] = version
15511551
env["org.graalvm.maven.downloader.repository"] = f"{pathlib.Path(path).as_uri()}/"

0 commit comments

Comments
 (0)