From 1368593199abb5c836fa2481c23ada27853f90f5 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 4 Aug 2023 14:09:57 +0100 Subject: [PATCH] Upgrade to Maven Resolver 1.9.14 Closes gh-36751 --- .../spring-boot-parent/build.gradle | 2 +- .../classpath/ModifiedClassPathClassLoader.java | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/spring-boot-project/spring-boot-parent/build.gradle b/spring-boot-project/spring-boot-parent/build.gradle index dadf2242b7..73fe311a14 100644 --- a/spring-boot-project/spring-boot-parent/build.gradle +++ b/spring-boot-project/spring-boot-parent/build.gradle @@ -118,7 +118,7 @@ bom { ] } } - library("Maven Resolver", "1.6.3") { + library("Maven Resolver", "1.9.14") { group("org.apache.maven.resolver") { modules = [ "maven-resolver-api", diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathClassLoader.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathClassLoader.java index 80438116f2..f05fa664d6 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathClassLoader.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathClassLoader.java @@ -43,7 +43,6 @@ import org.eclipse.aether.artifact.DefaultArtifact; import org.eclipse.aether.collection.CollectRequest; import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory; import org.eclipse.aether.graph.Dependency; -import org.eclipse.aether.impl.DefaultServiceLocator; import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.resolution.ArtifactResult; @@ -240,11 +239,9 @@ final class ModifiedClassPathClassLoader extends URLClassLoader { private static List resolveCoordinates(String[] coordinates) { Exception latestFailure = null; - DefaultServiceLocator serviceLocator = MavenRepositorySystemUtils.newServiceLocator(); - serviceLocator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); - serviceLocator.addService(TransporterFactory.class, HttpTransporterFactory.class); - RepositorySystem repositorySystem = serviceLocator.getService(RepositorySystem.class); + RepositorySystem repositorySystem = createRepositorySystem(); DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession(); + session.setSystemProperties(System.getProperties()); LocalRepository localRepository = new LocalRepository(System.getProperty("user.home") + "/.m2/repository"); RemoteRepository remoteRepository = new RemoteRepository.Builder("central", "default", "https://repo.maven.apache.org/maven2") @@ -270,6 +267,15 @@ final class ModifiedClassPathClassLoader extends URLClassLoader { latestFailure); } + @SuppressWarnings("deprecation") + private static RepositorySystem createRepositorySystem() { + org.eclipse.aether.impl.DefaultServiceLocator serviceLocator = MavenRepositorySystemUtils.newServiceLocator(); + serviceLocator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); + serviceLocator.addService(TransporterFactory.class, HttpTransporterFactory.class); + RepositorySystem repositorySystem = serviceLocator.getService(RepositorySystem.class); + return repositorySystem; + } + private static List createDependencies(String[] allCoordinates) { List dependencies = new ArrayList<>(); for (String coordinate : allCoordinates) {