diff --git a/jetty-maven-plugin/pom.xml b/jetty-maven-plugin/pom.xml index 530c586f60f..7c1fc57d140 100644 --- a/jetty-maven-plugin/pom.xml +++ b/jetty-maven-plugin/pom.xml @@ -49,6 +49,7 @@ + org.apache.maven.plugins maven-surefire-plugin -Dstop.port=@{test.stopPort} -Djetty.port=@{test.jettyPort} @@ -114,11 +115,6 @@ - - org.apache.maven.shared - maven-artifact-transfer - ${maven-artifact-transfer.version} - org.apache.maven maven-plugin-api @@ -150,6 +146,16 @@ maven-core provided + + org.apache.maven.resolver + maven-resolver-api + ${maven.resolver.version} + provided + + + org.codehaus.plexus + plexus-utils + org.apache.maven.plugin-tools maven-plugin-tools-api diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractWebAppMojo.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractWebAppMojo.java index 834c010f91d..de1dddff76b 100644 --- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractWebAppMojo.java +++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/AbstractWebAppMojo.java @@ -45,8 +45,8 @@ import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; -import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver; import org.codehaus.plexus.util.StringUtils; +import org.eclipse.aether.RepositorySystem; import org.eclipse.jetty.maven.plugin.utils.MavenProjectHelper; import org.eclipse.jetty.security.LoginService; import org.eclipse.jetty.server.RequestLog; @@ -357,7 +357,7 @@ public abstract class AbstractWebAppMojo extends AbstractMojo * */ @Component - private ArtifactResolver artifactResolver; + private RepositorySystem repositorySystem; /** * The current maven session @@ -410,7 +410,7 @@ public abstract class AbstractWebAppMojo extends AbstractMojo } getLog().info("Configuring Jetty for project: " + getProjectName()); - mavenProjectHelper = new MavenProjectHelper(project, artifactResolver, remoteRepositories, session); + mavenProjectHelper = new MavenProjectHelper(project, repositorySystem, remoteRepositories, session); mergedSystemProperties = mergeSystemProperties(); configureSystemProperties(); augmentPluginClasspath(); diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/utils/MavenProjectHelper.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/utils/MavenProjectHelper.java index b5b9d03da94..9d17ff2975f 100644 --- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/utils/MavenProjectHelper.java +++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/utils/MavenProjectHelper.java @@ -25,15 +25,16 @@ import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; +import org.apache.maven.RepositoryUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.execution.MavenSession; -import org.apache.maven.project.DefaultProjectBuildingRequest; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.ProjectBuildingRequest; -import org.apache.maven.shared.transfer.artifact.DefaultArtifactCoordinate; -import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver; -import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.artifact.DefaultArtifact; +import org.eclipse.aether.resolution.ArtifactRequest; +import org.eclipse.aether.resolution.ArtifactResolutionException; +import org.eclipse.aether.resolution.ArtifactResult; import org.eclipse.jetty.maven.plugin.OverlayManager; import org.eclipse.jetty.maven.plugin.WarPluginInfo; @@ -46,7 +47,7 @@ import org.eclipse.jetty.maven.plugin.WarPluginInfo; public class MavenProjectHelper { private MavenProject project; - private ArtifactResolver artifactResolver; + private RepositorySystem repositorySystem; private List remoteRepositories; private MavenSession session; private final Map artifactToReactorProjectMap; @@ -62,14 +63,14 @@ public class MavenProjectHelper /** * @param project the project being built - * @param artifactResolver a resolve for artifacts + * @param repositorySystem a resolve for artifacts * @param remoteRepositories repositories from which to resolve artifacts * @param session the current maven build session */ - public MavenProjectHelper(MavenProject project, ArtifactResolver artifactResolver, List remoteRepositories, MavenSession session) + public MavenProjectHelper(MavenProject project, RepositorySystem repositorySystem, List remoteRepositories, MavenSession session) { this.project = project; - this.artifactResolver = artifactResolver; + this.repositorySystem = repositorySystem; this.remoteRepositories = remoteRepositories; this.session = session; //work out which dependent projects are in the reactor @@ -145,26 +146,18 @@ public class MavenProjectHelper * @param version the version of the artifact to resolve * @param type the type of the artifact to resolve * @return a File representing the location of the artifact or null if not resolved - * @throws ArtifactResolverException + * @throws ArtifactResolutionException */ public File resolveArtifact(String groupId, String artifactId, String version, String type) - throws ArtifactResolverException + throws ArtifactResolutionException { - DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate(); - coordinate.setGroupId(groupId); - coordinate.setArtifactId(artifactId); - coordinate.setVersion(version); - coordinate.setExtension(type); + ArtifactRequest request = new ArtifactRequest(); + request.setRepositories(RepositoryUtils.toRepos(remoteRepositories)); + request.setArtifact(new DefaultArtifact(groupId, artifactId, "", type, version)); + ArtifactResult result = repositorySystem.resolveArtifact(session.getRepositorySession(), request); - ProjectBuildingRequest buildingRequest = - new DefaultProjectBuildingRequest(session.getProjectBuildingRequest()); - - buildingRequest.setRemoteRepositories(remoteRepositories); - - Artifact a = artifactResolver.resolveArtifact(buildingRequest, coordinate).getArtifact(); - - if (a != null) - return a.getFile(); + if (result.isResolved()) + return result.getArtifact().getFile(); return null; } diff --git a/pom.xml b/pom.xml index eba9f3a2970..3f453f1239f 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,6 @@ 1.3.0-alpha16 3.0.5 10.3.6 - 0.13.1 1.8.1 3.8.4 3.12.11