@@ -944,11 +944,25 @@ def graalvm_jdk():
944
944
mx .run_mx (mx_args + ["graalvm-home" ], out = out )
945
945
return out .data .splitlines ()[- 1 ].strip ()
946
946
947
+ def get_maven_cache ():
948
+ buildnr = os .environ .get ('BUILD_NUMBER' )
949
+ # don't worry about maven.repo.local if not running on gate
950
+ return os .path .join (SUITE .get_mx_output_dir (), 'm2_cache_' + buildnr ) if buildnr else None
947
951
948
952
def deploy_local_maven_repo ():
953
+ env = os .environ .copy ()
954
+ m2_cache = get_maven_cache ()
955
+ if m2_cache :
956
+ mvn_repo_local = f'-Dmaven.repo.local={ m2_cache } '
957
+ maven_opts = env .get ('MAVEN_OPTS' )
958
+ maven_opts = maven_opts + " " + mvn_repo_local if maven_opts else mvn_repo_local
959
+ env ['MAVEN_OPTS' ] = maven_opts
960
+ mx .log (f'Added { mvn_repo_local } to MAVEN_OPTS={ maven_opts } ' )
961
+
949
962
if not DISABLE_REBUILD :
950
963
# build GraalPy and all the necessary dependencies, so that we can deploy them
951
- mx .run_mx (["build" ])
964
+ mx .run_mx (["build" ], env = env )
965
+
952
966
# deploy maven artifacts
953
967
version = GRAAL_VERSION
954
968
path = os .path .join (SUITE .get_mx_output_dir (), 'public-maven-repo' )
@@ -964,11 +978,16 @@ def deploy_local_maven_repo():
964
978
'local' ,
965
979
pathlib .Path (path ).as_uri (),
966
980
]
981
+
967
982
if not DISABLE_REBUILD :
968
983
mx .rmtree (path , ignore_errors = True )
969
984
os .mkdir (path )
970
- mx .maven_deploy (deploy_args )
971
- return path , version
985
+ if m2_cache :
986
+ with set_env (MAVEN_OPTS = maven_opts ):
987
+ mx .maven_deploy (deploy_args )
988
+ else :
989
+ mx .maven_deploy (deploy_args )
990
+ return path , version , env
972
991
973
992
974
993
def python_jvm (_ = None ):
@@ -1406,7 +1425,7 @@ def graalpython_gate_runner(args, tasks):
1406
1425
# JUnit tests with Maven
1407
1426
with Task ('GraalPython integration JUnit with Maven' , tasks , tags = [GraalPythonTags .junit_maven ]) as task :
1408
1427
if task :
1409
- mvn_repo_path , artifacts_version = deploy_local_maven_repo ()
1428
+ mvn_repo_path , artifacts_version , env = deploy_local_maven_repo ()
1410
1429
mvn_repo_path = pathlib .Path (mvn_repo_path ).as_uri ()
1411
1430
central_override = mx_urlrewrites .rewriteurl ('https://repo1.maven.org/maven2/' )
1412
1431
pom_path = os .path .join (SUITE .dir , 'graalpython/com.oracle.graal.python.test.integration/pom.xml' )
@@ -1420,9 +1439,10 @@ def graalpython_gate_runner(args, tasks):
1420
1439
mx .run_maven (mvn_cmd_base + ['dependency:purge-local-repository' , '-DreResolve=false' ])
1421
1440
1422
1441
mx .log ("Running integration JUnit tests on GraalVM SDK" )
1423
- env = extend_os_env ( JAVA_HOME = graalvm_jdk () )
1442
+ env [ 'JAVA_HOME' ] = graalvm_jdk ()
1424
1443
mx .run_maven (mvn_cmd_base + ['-U' , 'clean' , 'test' ], env = env )
1425
1444
1445
+ env ['JAVA_HOME' ] = os .environ ['JAVA_HOME' ]
1426
1446
mx .log (f"Running integration JUnit tests on vanilla JDK: { os .environ .get ('JAVA_HOME' , 'system java' )} " )
1427
1447
mx .run_maven (mvn_cmd_base + ['-U' , '-Dpolyglot.engine.WarnInterpreterOnly=false' , 'clean' , 'test' ])
1428
1448
@@ -1481,13 +1501,15 @@ def graalpython_gate_runner(args, tasks):
1481
1501
1482
1502
with Task ('GraalPython standalone module tests' , tasks , tags = [GraalPythonTags .unittest_standalone ]) as task :
1483
1503
if task :
1484
- env = {
1485
- 'ENABLE_STANDALONE_UNITTESTS' : 'true' ,
1486
- 'ENABLE_JBANG_INTEGRATION_UNITTESTS' : 'false' ,
1487
- 'JAVA_HOME' : graalvm_jdk (),
1488
- 'PYTHON_STANDALONE_HOME' : graalpy_standalone_home ('jvm' )
1489
- }
1490
- mvn_repo_path , version = deploy_local_maven_repo ()
1504
+ gvm_jdk = graalvm_jdk ()
1505
+ standalone_home = graalpy_standalone_home ('jvm' )
1506
+ mvn_repo_path , version , env = deploy_local_maven_repo ()
1507
+
1508
+ env ['ENABLE_STANDALONE_UNITTESTS' ] = 'true'
1509
+ env ['ENABLE_JBANG_INTEGRATION_UNITTESTS' ] = 'true'
1510
+ env ['JAVA_HOME' ] = gvm_jdk
1511
+ env ['PYTHON_STANDALONE_HOME' ] = standalone_home
1512
+
1491
1513
# setup maven downloader overrides
1492
1514
env ['MAVEN_REPO_OVERRIDE' ] = "," .join ([
1493
1515
f"{ pathlib .Path (mvn_repo_path ).as_uri ()} /" ,
@@ -1498,13 +1520,15 @@ def graalpython_gate_runner(args, tasks):
1498
1520
1499
1521
# setup JBang executable
1500
1522
env ["JBANG_CMD" ] = _prepare_jbang ()
1523
+ m2_cache = get_maven_cache ()
1524
+ if m2_cache :
1525
+ env ["JBANG_REPO" ] = m2_cache
1501
1526
1502
1527
# run the test
1503
1528
mx .logv (f"running with os.environ extended with: { env = } " )
1504
- full_env = extend_os_env (** env )
1505
1529
mx .run ([sys .executable , _graalpytest_driver (), "-v" ,
1506
1530
"graalpython/com.oracle.graal.python.test/src/tests/standalone/test_jbang_integration.py" ,
1507
- "graalpython/com.oracle.graal.python.test/src/tests/standalone/test_standalone.py" ], env = full_env )
1531
+ "graalpython/com.oracle.graal.python.test/src/tests/standalone/test_standalone.py" ], env = env )
1508
1532
1509
1533
with Task ('GraalPython Python tests' , tasks , tags = [GraalPythonTags .tagged ]) as task :
1510
1534
if task :
0 commit comments