This is an automated email from the ASF dual-hosted git repository. slachiewicz pushed a commit to branch MNG-7777-guice6 in repository https://gitbox.apache.org/repos/asf/maven.git
commit 24f11f331b33308c5fcdebd7f2f38d1c77dd0f14 Author: Petr Široký <petr.sir...@pm.me> AuthorDate: Sat Mar 18 21:42:15 2023 +0100 [MNG-7743] Make the build work on JDK 20 * the behaviour before the fix was already pretty confusing. JDK 19 and older do not check the presense of '{' in the constructor, so the URL object got created, but when converting to file the result would be e.g. '/../../src/test/remote-repo' which is completely wrong. But it seems the affected tests did not really care, as all of them were passing --- .../apache/maven/repository/TestRepositoryConnector.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnector.java b/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnector.java index 4fd761003..89c749eb9 100644 --- a/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnector.java +++ b/maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnector.java @@ -49,10 +49,17 @@ public class TestRepositoryConnector implements RepositoryConnector { public TestRepositoryConnector(RemoteRepository repository) { this.repository = repository; - try { - basedir = FileUtils.toFile(new URL(repository.getUrl())); - } catch (MalformedURLException e) { - throw new IllegalStateException(e); + String repositoryUrl = repository.getUrl(); + if (repositoryUrl.contains("${")) { + // the repository url contains unresolved properties and getting the basedir is not possible + // in JDK 20+ 'new URL(string)' will fail if the string contains a curly brace + this.basedir = null; + } else { + try { + basedir = FileUtils.toFile(new URL(repositoryUrl)); + } catch (MalformedURLException e) { + throw new IllegalStateException(e); + } } }