maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rfscho...@apache.org
Subject svn commit: r1687959 - in /maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency: fromDependencies/AbstractDependencyFilterMojo.java resolvers/AbstractResolveMojo.java resolvers/ResolvePluginsMojo.java
Date Sat, 27 Jun 2015 18:21:13 GMT
Author: rfscholte
Date: Sat Jun 27 18:21:12 2015
New Revision: 1687959

URL: http://svn.apache.org/r1687959
Log:
[MDEP-494] Remove/replace Maven2 specific code
More goals using ArtifactResolver from maven-artifact-transfer

Modified:
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromDependencies/AbstractDependencyFilterMojo.java
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/AbstractResolveMojo.java
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolvePluginsMojo.java

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromDependencies/AbstractDependencyFilterMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromDependencies/AbstractDependencyFilterMojo.java?rev=1687959&r1=1687958&r2=1687959&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromDependencies/AbstractDependencyFilterMojo.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromDependencies/AbstractDependencyFilterMojo.java
Sat Jun 27 18:21:12 2015
@@ -491,4 +491,9 @@ public abstract class AbstractDependency
     {
         this.prependGroupId = prependGroupId;
     }
+    
+    protected final ArtifactResolver getArtifactResolver()
+    {
+        return artifactResolver;
+    }
 }

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/AbstractResolveMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/AbstractResolveMojo.java?rev=1687959&r1=1687958&r2=1687959&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/AbstractResolveMojo.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/AbstractResolveMojo.java
Sat Jun 27 18:21:12 2015
@@ -24,15 +24,16 @@ import java.util.Set;
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
 import org.apache.maven.plugin.dependency.fromDependencies.AbstractDependencyFilterMojo;
 import org.apache.maven.plugin.dependency.utils.DependencyUtil;
 import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.ProjectBuilder;
 import org.apache.maven.project.ProjectBuildingException;
+import org.apache.maven.project.ProjectBuildingRequest;
 import org.apache.maven.project.artifact.InvalidDependencyVersionException;
 import org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter;
 import org.apache.maven.shared.artifact.filter.collection.ClassifierFilter;
@@ -40,6 +41,7 @@ import org.apache.maven.shared.artifact.
 import org.apache.maven.shared.artifact.filter.collection.GroupIdFilter;
 import org.apache.maven.shared.artifact.filter.collection.ScopeFilter;
 import org.apache.maven.shared.artifact.filter.collection.TypeFilter;
+import org.apache.maven.shared.artifact.resolve.ArtifactResolverException;
 
 /**
  * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
@@ -53,7 +55,7 @@ public abstract class AbstractResolveMoj
      */
     @Component
     private ProjectBuilder projectBuilder;
-
+    
     /**
      * If specified, this parameter will cause the dependencies to be written to the path
specified, instead of writing
      * to the console.
@@ -153,16 +155,23 @@ public abstract class AbstractResolveMoj
     }
 
     protected Set<Artifact> resolveDependencyArtifacts( final MavenProject theProject
)
-        throws ArtifactResolutionException, ArtifactNotFoundException, InvalidDependencyVersionException
+        throws ArtifactResolverException, ArtifactNotFoundException, InvalidDependencyVersionException
     {
         final Set<Artifact> artifacts =
             theProject.createArtifacts( this.factory, Artifact.SCOPE_TEST,
                                         new ScopeArtifactFilter( Artifact.SCOPE_TEST ) );
 
+        ProjectBuildingRequest buildingRequest =
+            new DefaultProjectBuildingRequest( session.getProjectBuildingRequest() );
+        
+        buildingRequest.setLocalRepository( getLocal() );
+        
+        buildingRequest.setRemoteRepositories( this.remoteRepos );
+        
         for ( final Artifact artifact : artifacts )
         {
             // resolve the new artifact
-            this.resolver.resolve( artifact, this.remoteRepos, this.getLocal() );
+            getArtifactResolver().resolveArtifact( buildingRequest, artifact );
         }
         return artifacts;
     }
@@ -172,14 +181,14 @@ public abstract class AbstractResolveMoj
      *
      * @param artifact the artifact used to retrieve dependencies
      * @return resolved set of dependencies
-     * @throws ArtifactResolutionException
+     * @throws ArtifactResolverException
      * @throws ArtifactNotFoundException
      * @throws ProjectBuildingException
      * @throws InvalidDependencyVersionException
      *
      */
     protected Set<Artifact> resolveArtifactDependencies( final Artifact artifact )
-        throws ArtifactResolutionException, ArtifactNotFoundException, ProjectBuildingException,
+        throws ArtifactResolverException, ArtifactNotFoundException, ProjectBuildingException,
         InvalidDependencyVersionException
     {
         final Artifact pomArtifact =

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolvePluginsMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolvePluginsMojo.java?rev=1687959&r1=1687958&r2=1687959&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolvePluginsMojo.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolvePluginsMojo.java
Sat Jun 27 18:21:12 2015
@@ -29,16 +29,18 @@ import java.util.Set;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.dependency.utils.DependencyUtil;
 import org.apache.maven.plugins.annotations.LifecyclePhase;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
 import org.apache.maven.project.ProjectBuildingException;
+import org.apache.maven.project.ProjectBuildingRequest;
 import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException;
 import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter;
 import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts;
+import org.apache.maven.shared.artifact.resolve.ArtifactResolverException;
 import org.codehaus.plexus.util.IOUtil;
 
 /**
@@ -128,10 +130,6 @@ public class ResolvePluginsMojo
         {
             throw new MojoExecutionException( "Nested:", e );
         }
-        catch ( final ArtifactResolutionException e )
-        {
-            throw new MojoExecutionException( "Nested:", e );
-        }
         catch ( final ArtifactNotFoundException e )
         {
             throw new MojoExecutionException( "Nested:", e );
@@ -144,6 +142,10 @@ public class ResolvePluginsMojo
         {
             throw new MojoExecutionException( "Nested:", e );
         }
+        catch ( ArtifactResolverException e )
+        {
+            throw new MojoExecutionException( "Nested:", e );
+        }
         finally
         {
             IOUtil.close( outputWriter );
@@ -155,12 +157,11 @@ public class ResolvePluginsMojo
      * This method resolves the plugin artifacts from the project.
      *
      * @return set of resolved plugin artifacts.
-     * @throws ArtifactResolutionException
-     * @throws ArtifactNotFoundException
      * @throws ArtifactFilterException 
+     * @throws ArtifactResolverException 
      */
     protected Set<Artifact> resolvePluginArtifacts()
-        throws ArtifactResolutionException, ArtifactNotFoundException, ArtifactFilterException
+        throws ArtifactFilterException, ArtifactResolverException
     {
         final Set<Artifact> plugins = project.getPluginArtifacts();
         final Set<Artifact> reports = project.getReportArtifacts();
@@ -189,8 +190,15 @@ public class ResolvePluginsMojo
             //     continue;
             // }
 
+            ProjectBuildingRequest buildingRequest =
+                new DefaultProjectBuildingRequest( session.getProjectBuildingRequest() );
+            
+            buildingRequest.setLocalRepository( this.getLocal() );
+            
+            buildingRequest.setRemoteRepositories( this.remotePluginRepositories );
+            
             // resolve the new artifact
-            this.resolver.resolve( artifact, this.remotePluginRepositories, this.getLocal()
);
+            getArtifactResolver().resolveArtifact( buildingRequest, artifact );
         }
         return artifacts;
     }



Mime
View raw message