diff --git a/pom.xml b/pom.xml
index 6abae44d..12375687 100644
--- a/pom.xml
+++ b/pom.xml
@@ -137,6 +137,14 @@
${mavenVersion}
provided
+
+
+ org.eclipse.aether
+ aether-util
+
+ 1.0.0.v20140518
+
+
org.codehaus.plexus
plexus-utils
diff --git a/src/main/java/org/codehaus/mojo/exec/ExecJavaMojo.java b/src/main/java/org/codehaus/mojo/exec/ExecJavaMojo.java
index 7ec90fd7..f9444883 100644
--- a/src/main/java/org/codehaus/mojo/exec/ExecJavaMojo.java
+++ b/src/main/java/org/codehaus/mojo/exec/ExecJavaMojo.java
@@ -18,13 +18,11 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ForkJoinPool;
+import java.util.stream.Collectors;
import java.util.stream.Stream;
+import org.apache.maven.RepositoryUtils;
import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
-import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
-import org.apache.maven.artifact.resolver.ResolutionErrorHandler;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
@@ -32,7 +30,15 @@
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.ProjectBuilder;
-import org.apache.maven.repository.RepositorySystem;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.collection.CollectRequest;
+import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.graph.DependencyFilter;
+import org.eclipse.aether.resolution.ArtifactResult;
+import org.eclipse.aether.resolution.DependencyRequest;
+import org.eclipse.aether.resolution.DependencyResolutionException;
+import org.eclipse.aether.resolution.DependencyResult;
+import org.eclipse.aether.util.filter.DependencyFilterUtils;
/**
* Executes the supplied java class in the current VM with the enclosing project's dependencies as classpath.
@@ -47,10 +53,6 @@ public class ExecJavaMojo
@Component
private RepositorySystem repositorySystem;
- @Component
- private ResolutionErrorHandler resolutionErrorHandler;
-
-
/**
* @since 1.0
*/
@@ -642,10 +644,8 @@ private void addRelevantPluginDependenciesToClasspath( List path )
* Add any relevant project dependencies to the classpath. Takes includeProjectDependencies into consideration.
*
* @param path classpath of {@link java.net.URL} objects
- * @throws MojoExecutionException if a problem happens
*/
private void addRelevantProjectDependenciesToClasspath( List path )
- throws MojoExecutionException
{
if ( this.includeProjectDependencies )
{
@@ -692,7 +692,7 @@ private Set determineRelevantPluginDependencies()
if ( this.executableDependency == null )
{
getLog().debug( "All Plugin Dependencies will be included." );
- relevantDependencies = new HashSet( this.getPluginDependencies() );
+ relevantDependencies = new HashSet<>( this.getPluginDependencies() );
}
else
{
@@ -712,32 +712,36 @@ private Set determineRelevantPluginDependencies()
/**
* Resolve the executable dependencies for the specified project
*
- * @param executablePomArtifact the project's POM
+ * @param executableArtifact the executable plugin dependency
* @return a set of Artifacts
* @throws MojoExecutionException if a failure happens
*/
- private Set resolveExecutableDependencies( Artifact executablePomArtifact )
+ private Set resolveExecutableDependencies( Artifact executableArtifact )
throws MojoExecutionException
{
try
{
- ArtifactResolutionRequest request = new ArtifactResolutionRequest()
- .setArtifact( executablePomArtifact )
- .setLocalRepository( getSession().getLocalRepository() )
- .setRemoteRepositories( getSession().getRequest().getRemoteRepositories() )
- .setForceUpdate( getSession().getRequest().isUpdateSnapshots() )
- .setOffline( getSession().isOffline() )
- .setResolveTransitively( true );
+ CollectRequest collectRequest = new CollectRequest();
+ collectRequest.setRoot(
+ new Dependency( RepositoryUtils.toArtifact( executableArtifact ), classpathScope ) );
+ collectRequest.setRepositories( project.getRemotePluginRepositories() );
+
+ DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter( classpathScope );
+
+ DependencyRequest dependencyRequest = new DependencyRequest( collectRequest, classpathFilter );
- ArtifactResolutionResult result = repositorySystem.resolve( request );
- resolutionErrorHandler.throwErrors( request, result );
+ DependencyResult dependencyResult =
+ repositorySystem.resolveDependencies( getSession().getRepositorySession(), dependencyRequest );
- return result.getArtifacts();
+ return dependencyResult.getArtifactResults().stream()
+ .map( ArtifactResult::getArtifact )
+ .map( RepositoryUtils::toArtifact )
+ .collect( Collectors.toSet() );
}
- catch ( ArtifactResolutionException ex )
+ catch ( DependencyResolutionException ex )
{
throw new MojoExecutionException( "Encountered problems resolving dependencies of the executable "
- + "in preparation for its execution.", ex );
+ + "in preparation for its execution.", ex );
}
}