mirror of https://github.com/apache/maven.git
[MNG-7743] Make the build work on JDK 20 (#1065)
* [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 * Remove forgotten println Co-authored-by: Yeikel <email@yeikel.com> * Test with latest JDK * Do not run ITs with jdk 20, but just the "build itself" --------- Co-authored-by: Yeikel <email@yeikel.com> Co-authored-by: Guillaume Nodet <gnodet@gmail.com> # Conflicts: # .github/workflows/maven_build_itself.yml # maven-core/src/test/java/org/apache/maven/repository/TestRepositoryConnector.java
This commit is contained in:
parent
f0c2c65526
commit
b42f2100a7
|
@ -49,10 +49,20 @@ 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 {
|
||||
URL url = new URL(repository.getUrl());
|
||||
if ("file".equals(url.getProtocol())) {
|
||||
basedir = new File(url.getPath());
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue