Skip to content

Commit 1b3700a

Browse files
committed
use maven wrapper from internal mirror
1 parent 3fd37d7 commit 1b3700a

6 files changed

Lines changed: 308 additions & 15 deletions

File tree

graalpython/com.oracle.graal.python.test/src/tests/standalone/mvnw/.mvn/wrapper/maven-wrapper.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
wrapperVersion=3.3.1
18-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip
17+
wrapperVersion=3.3.2
18+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.8/apache-maven-3.9.8-bin.zip

graalpython/com.oracle.graal.python.test/src/tests/standalone/mvnw/mvnw

Lines changed: 259 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

graalpython/com.oracle.graal.python.test/src/tests/standalone/mvnw/mvnw.cmd

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,26 @@ def generate_app(self, tmpdir, target_dir, target_name, pom_template=None):
175175

176176
util.patch_pom_repositories(os.path.join(target_dir, "pom.xml"))
177177

178+
distribution_url_override = self.env.get("MAVEN_DISTRIBUTION_URL_OVERRIDE")
179+
if distribution_url_override:
180+
mvnw_dir = os.path.join(os.path.dirname(__file__), "mvnw")
181+
182+
shutil.copy(os.path.join(mvnw_dir, "mvnw"), os.path.join(target_dir, "mvnw"))
183+
shutil.copy(os.path.join(mvnw_dir, "mvnw.cmd"), os.path.join(target_dir, "mvnw.cmd"))
184+
shutil.copytree(os.path.join(mvnw_dir, ".mvn"), os.path.join(target_dir, ".mvn"))
185+
186+
mvnw_properties = os.path.join(target_dir, ".mvn", "wrapper", "maven-wrapper.properties")
187+
new_lines = []
188+
with(open(mvnw_properties)) as f:
189+
while line := f.readline():
190+
line.strip()
191+
if not line.startswith("#") and "distributionUrl" in line:
192+
new_lines.append(f"distributionUrl={distribution_url_override}\n")
193+
else:
194+
new_lines.append(line)
195+
with(open(mvnw_properties, "w")) as f:
196+
f.writelines(new_lines)
197+
178198
@unittest.skipUnless(is_enabled, "ENABLE_STANDALONE_UNITTESTS is not true")
179199
def test_generated_app(self):
180200
with tempfile.TemporaryDirectory() as tmpdir:

graalpython/com.oracle.graal.python.test/src/tests/standalone/util.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
import subprocess
4343
import sys
4444

45-
MAVEN_VERSION = "3.9.6"
45+
MAVEN_VERSION = "3.9.8"
4646

4747
def run_cmd(cmd, env, cwd=None, print_out=False):
4848
out = []
@@ -74,17 +74,8 @@ def print_output(out, err_msg):
7474
print("", err_msg, "", sep="\n")
7575

7676
def get_mvn_wrapper(project_dir, env):
77-
if 'win32' != sys.platform:
78-
cmd = [shutil.which('mvn'), "--batch-mode", "wrapper:wrapper", f"-Dmaven={MAVEN_VERSION}"]
79-
out, return_code = run_cmd(cmd, env, cwd=project_dir)
80-
check_ouput("BUILD SUCCESS", out)
81-
mvn_cmd = [os.path.abspath(os.path.join(project_dir, "mvnw")), "--batch-mode"]
82-
else:
83-
# TODO installing mvn wrapper with the current mvn 3.3.9 on gates does not work
84-
# we have to provide the mvnw.cmd script
85-
mvnw_dir = os.path.join(os.path.dirname(__file__), "mvnw")
86-
mvn_cmd = [os.path.abspath(os.path.join(mvnw_dir, "mvnw.cmd")), "--batch-mode"]
87-
77+
cmd = "mvnw" if 'win32' != sys.platform else "mvnw.cmd"
78+
mvn_cmd = [os.path.join(project_dir, cmd), "--batch-mode"]
8879
cmd = mvn_cmd + ["--version"]
8980
out, return_code = run_cmd(cmd, env, cwd=project_dir)
9081
check_ouput(MAVEN_VERSION, out)

mx.graalpython/mx_graalpython.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,21 @@ def get_cpython():
13721372
else:
13731373
return "python3"
13741374

1375+
def get_wrapper_urls(wrapper_properties_file, keys):
1376+
ret = dict()
1377+
with(open(wrapper_properties_file)) as f:
1378+
while line := f.readline():
1379+
line = line.strip()
1380+
for key in keys:
1381+
if not line.startswith("#") and key not in ret.keys() and key in line:
1382+
s = line.split("=")
1383+
if len(s) > 1:
1384+
ret.update({key : mx_urlrewrites.rewriteurl(s[1].strip())})
1385+
break
1386+
for key in keys:
1387+
assert key in ret.keys(), f"Expected key '{key}' to be in {wrapper_properties_file}, but was not."
1388+
1389+
return ret
13751390

13761391
def graalpython_gate_runner(args, tasks):
13771392
report = lambda: (not is_collecting_coverage()) and task
@@ -1530,6 +1545,11 @@ def graalpython_gate_runner(args, tasks):
15301545
f"{pathlib.Path(mvn_repo_path).as_uri()}/",
15311546
mx_urlrewrites.rewriteurl('https://repo1.maven.org/maven2/'),
15321547
])
1548+
1549+
urls = get_wrapper_urls("graalpython/com.oracle.graal.python.test/src/tests/standalone/mvnw/.mvn/wrapper/maven-wrapper.properties", ["distributionUrl"])
1550+
if "distributionUrl" in urls:
1551+
env["MAVEN_DISTRIBUTION_URL_OVERRIDE"] = mx_urlrewrites.rewriteurl(urls["distributionUrl"])
1552+
15331553
env["org.graalvm.maven.downloader.version"] = version
15341554
env["org.graalvm.maven.downloader.repository"] = f"{pathlib.Path(mvn_repo_path).as_uri()}/"
15351555

0 commit comments

Comments
 (0)