maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rfscho...@apache.org
Subject svn commit: r1687929 - in /maven/plugins/trunk/maven-dependency-plugin/src: main/java/org/apache/maven/plugin/dependency/fromDependencies/ main/java/org/apache/maven/plugin/dependency/utils/resolvers/ main/java/org/apache/maven/plugin/dependency/utils/...
Date Sat, 27 Jun 2015 14:16:03 GMT
Author: rfscholte
Date: Sat Jun 27 14:16:03 2015
New Revision: 1687929

URL: http://svn.apache.org/r1687929
Log:
DefaultArtifactsResolver now uses ArtifactResolver from maven-artifact-transfer (with succeeding
tests)

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/utils/resolvers/DefaultArtifactsResolver.java
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/translators/ClassifierTypeTranslator.java
    maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/fromDependencies/TestCopyDependenciesMojo.java
    maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/fromDependencies/TestUnpackDependenciesMojo.java
    maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/translators/TestClassifierTypeTranslator.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=1687929&r1=1687928&r2=1687929&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 14:16:03 2015
@@ -393,7 +393,8 @@ public abstract class AbstractDependency
         // if this did something, we need to resolve the new artifacts
         if ( StringUtils.isNotEmpty( classifier ) )
         {
-            ArtifactTranslator translator = new ClassifierTypeTranslator( this.classifier,
this.type, this.factory );
+            ArtifactTranslator translator =
+                new ClassifierTypeTranslator( this.classifier, this.type, this.factory, this.getLocal()
);
             artifacts = translator.translate( artifacts, getLog() );
 
             status = filterMarkedDependencies( artifacts );

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/resolvers/DefaultArtifactsResolver.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/resolvers/DefaultArtifactsResolver.java?rev=1687929&r1=1687928&r2=1687929&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/resolvers/DefaultArtifactsResolver.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/resolvers/DefaultArtifactsResolver.java
Sat Jun 27 14:16:03 2015
@@ -42,7 +42,8 @@ public class DefaultArtifactsResolver
 
     boolean stopOnFailure;
 
-    public DefaultArtifactsResolver( ArtifactResolver theResolver, ProjectBuildingRequest
buildingRequest, boolean theStopOnFailure )
+    public DefaultArtifactsResolver( ArtifactResolver theResolver, ProjectBuildingRequest
buildingRequest,
+                                     boolean theStopOnFailure )
     {
         this.resolver = theResolver;
         this.buildingRequest = buildingRequest;

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/translators/ClassifierTypeTranslator.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/translators/ClassifierTypeTranslator.java?rev=1687929&r1=1687928&r2=1687929&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/translators/ClassifierTypeTranslator.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/translators/ClassifierTypeTranslator.java
Sat Jun 27 14:16:03 2015
@@ -19,11 +19,13 @@ package org.apache.maven.plugin.dependen
  * under the License.
  */
 
+import java.io.File;
 import java.util.HashSet;
 import java.util.Set;
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.plugin.logging.Log;
 import org.codehaus.plexus.util.StringUtils;
 
@@ -40,12 +42,23 @@ public class ClassifierTypeTranslator
     private String type;
 
     private ArtifactFactory factory;
+    
+    private ArtifactRepository repository;
 
-    public ClassifierTypeTranslator( String theClassifier, String theType, ArtifactFactory
theFactory )
+    /**
+     * 
+     * @param theClassifier
+     * @param theType
+     * @param theFactory
+     * @param theRepository required when using system scoped artifacts 
+     */
+    public ClassifierTypeTranslator( String theClassifier, String theType, ArtifactFactory
theFactory,
+                                     ArtifactRepository theRepository )
     {
         this.classifier = theClassifier;
         this.type = theType;
         this.factory = theFactory;
+        this.repository = theRepository;
     }
 
     /*
@@ -94,6 +107,11 @@ public class ClassifierTypeTranslator
             // should
             // reset it here so that it will pass other filters if needed
             newArtifact.setScope( artifact.getScope() );
+            
+            if ( Artifact.SCOPE_SYSTEM.equals( newArtifact.getScope() ) )
+            {
+                newArtifact.setFile( new File( repository.getBasedir(), repository.pathOf(
newArtifact ) ) );
+            }
 
             results.add( newArtifact );
         }

Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/fromDependencies/TestCopyDependenciesMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/fromDependencies/TestCopyDependenciesMojo.java?rev=1687929&r1=1687928&r2=1687929&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/fromDependencies/TestCopyDependenciesMojo.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/fromDependencies/TestCopyDependenciesMojo.java
Sat Jun 27 14:16:03 2015
@@ -19,25 +19,30 @@ package org.apache.maven.plugin.dependen
  * under the License.
  */
 
-import org.apache.maven.plugin.MojoFailureException;
-
 import java.io.File;
 import java.io.IOException;
 import java.util.HashSet;
 import java.util.Set;
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.LegacyLocalRepositoryManager;
 import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
+import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugin.dependency.AbstractDependencyMojoTestCase;
-import org.apache.maven.plugin.dependency.fromDependencies.CopyDependenciesMojo;
 import org.apache.maven.plugin.dependency.testUtils.DependencyTestUtils;
 import org.apache.maven.plugin.dependency.utils.DependencyUtil;
 import org.apache.maven.plugin.dependency.utils.markers.DefaultFileMarkerHandler;
+import org.apache.maven.plugin.testing.ArtifactStubFactory;
 import org.apache.maven.plugin.testing.stubs.StubArtifactRepository;
 import org.apache.maven.plugin.testing.stubs.StubArtifactResolver;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.util.StringUtils;
+import org.sonatype.aether.RepositorySystem;
+import org.sonatype.aether.repository.LocalRepositoryManager;
+import org.sonatype.aether.util.DefaultRepositorySystemSession;
 
 public class TestCopyDependenciesMojo
     extends AbstractDependencyMojoTestCase
@@ -60,6 +65,23 @@ public class TestCopyDependenciesMojo
         assertNotNull( mojo.getProject() );
         MavenProject project = mojo.getProject();
 
+        MavenSession session = newMavenSession( project );
+        setVariableValueToObject( mojo, "session", session );
+
+        DefaultRepositorySystemSession repoSession = (DefaultRepositorySystemSession) session.getRepositorySession();
+        
+        ArtifactRepository repo = new StubArtifactRepository( stubFactory.getWorkingDir().getAbsolutePath()
) {
+            @Override
+            public String pathOf( Artifact artifact )
+            {
+                return ArtifactStubFactory.getFormattedFileName( artifact, false );
+            }
+        };
+        mojo.setLocal( repo );
+        RepositorySystem repoSystem = lookup( RepositorySystem.class );
+        
+        repoSession.setLocalRepositoryManager( LegacyLocalRepositoryManager.wrap( repo, repoSystem
) );
+        
         Set<Artifact> artifacts = this.stubFactory.getScopedArtifacts();
         Set<Artifact> directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts();
         artifacts.addAll( directArtifacts );
@@ -437,11 +459,18 @@ public class TestCopyDependenciesMojo
     {
         mojo.classifier = testClassifier;
         mojo.type = testType;
+        
+        for( Artifact artifact : mojo.getProject().getArtifacts() )
+        {
+            String type = testType != null ? testType : artifact.getType();
+            
+            stubFactory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(),
artifact.getVersion(), artifact.getScope(), type, testClassifier );
+            
+        }
 
         // init classifier things
         mojo.setFactory( DependencyTestUtils.getArtifactFactory() );
         mojo.setResolver( new StubArtifactResolver( stubFactory, false, false ) );
-        mojo.setLocal( new StubArtifactRepository( this.testDir.getAbsolutePath() ) );
 
         mojo.execute();
 

Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/fromDependencies/TestUnpackDependenciesMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/fromDependencies/TestUnpackDependenciesMojo.java?rev=1687929&r1=1687928&r2=1687929&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/fromDependencies/TestUnpackDependenciesMojo.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/fromDependencies/TestUnpackDependenciesMojo.java
Sat Jun 27 14:16:03 2015
@@ -21,8 +21,11 @@ package org.apache.maven.plugin.dependen
 
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.LegacyLocalRepositoryManager;
 import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
 import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.dependency.AbstractDependencyMojoTestCase;
 import org.apache.maven.plugin.dependency.fromDependencies.UnpackDependenciesMojo;
@@ -30,10 +33,13 @@ import org.apache.maven.plugin.dependenc
 import org.apache.maven.plugin.dependency.testUtils.DependencyTestUtils;
 import org.apache.maven.plugin.dependency.utils.DependencyUtil;
 import org.apache.maven.plugin.dependency.utils.markers.DefaultFileMarkerHandler;
+import org.apache.maven.plugin.testing.ArtifactStubFactory;
 import org.apache.maven.plugin.testing.stubs.StubArtifactRepository;
 import org.apache.maven.plugin.testing.stubs.StubArtifactResolver;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.util.StringUtils;
+import org.sonatype.aether.RepositorySystem;
+import org.sonatype.aether.util.DefaultRepositorySystemSession;
 
 import java.io.File;
 import java.io.IOException;
@@ -72,6 +78,23 @@ public class TestUnpackDependenciesMojo
         assertNotNull( mojo );
         assertNotNull( mojo.getProject() );
         MavenProject project = mojo.getProject();
+        
+        MavenSession session = newMavenSession( project );
+        setVariableValueToObject( mojo, "session", session );
+        
+        DefaultRepositorySystemSession repoSession = (DefaultRepositorySystemSession) session.getRepositorySession();
+        
+        ArtifactRepository repo = new StubArtifactRepository( stubFactory.getWorkingDir().getAbsolutePath()
) {
+            @Override
+            public String pathOf( Artifact artifact )
+            {
+                return ArtifactStubFactory.getFormattedFileName( artifact, false );
+            }
+        };
+        mojo.setLocal( repo );
+        RepositorySystem repoSystem = lookup( RepositorySystem.class );
+        
+        repoSession.setLocalRepositoryManager( LegacyLocalRepositoryManager.wrap( repo, repoSystem
) );
 
         Set<Artifact> artifacts = this.stubFactory.getScopedArtifacts();
         Set<Artifact> directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts();
@@ -515,7 +538,6 @@ public class TestUnpackDependenciesMojo
         mojo.type = testType;
         mojo.setFactory( DependencyTestUtils.getArtifactFactory() );
         mojo.setResolver( new StubArtifactResolver( stubFactory, false, false ) );
-        mojo.setLocal( new StubArtifactRepository( this.testDir.getAbsolutePath() ) );
 
         for (Artifact artifact : mojo.getProject().getArtifacts())
         {

Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/translators/TestClassifierTypeTranslator.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/translators/TestClassifierTypeTranslator.java?rev=1687929&r1=1687928&r2=1687929&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/translators/TestClassifierTypeTranslator.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/translators/TestClassifierTypeTranslator.java
Sat Jun 27 14:16:03 2015
@@ -29,10 +29,12 @@ import org.apache.maven.artifact.factory
 import org.apache.maven.artifact.factory.DefaultArtifactFactory;
 import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
 import org.apache.maven.artifact.handler.manager.DefaultArtifactHandlerManager;
+import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.plugin.dependency.AbstractDependencyMojoTestCase;
 import org.apache.maven.plugin.dependency.testUtils.DependencyArtifactStubFactory;
 import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.plugin.testing.SilentLog;
+import org.apache.maven.plugin.testing.stubs.StubArtifactRepository;
 
 /**
  * @author brianf
@@ -44,6 +46,8 @@ public class TestClassifierTypeTranslato
     Set<Artifact> artifacts = new HashSet<Artifact>();
 
     ArtifactFactory artifactFactory;
+    
+    ArtifactRepository artifactRepository;
 
     Log log = new SilentLog();
 
@@ -58,6 +62,8 @@ public class TestClassifierTypeTranslato
         artifactFactory = new DefaultArtifactFactory();
         this.setVariableValueToObject( artifactFactory, "artifactHandlerManager", manager
);
 
+        artifactRepository = new StubArtifactRepository( null );
+        
         DependencyArtifactStubFactory factory = new DependencyArtifactStubFactory( null,
false );
         artifacts = factory.getMixedArtifacts();
     }
@@ -76,7 +82,7 @@ public class TestClassifierTypeTranslato
     {
         String type = "zip";
 
-        ArtifactTranslator at = new ClassifierTypeTranslator( classifier, type, artifactFactory
);
+        ArtifactTranslator at = new ClassifierTypeTranslator( classifier, type, artifactFactory,
artifactRepository );
         Set<Artifact> results = at.translate( artifacts, log );
 
         for ( Artifact artifact : artifacts )
@@ -116,7 +122,7 @@ public class TestClassifierTypeTranslato
     {
         String classifier = "jdk5";
 
-        ArtifactTranslator at = new ClassifierTypeTranslator( classifier, type, artifactFactory
);
+        ArtifactTranslator at = new ClassifierTypeTranslator( classifier, type, artifactFactory,
artifactRepository );
         Set<Artifact> results = at.translate( artifacts, log );
 
         for ( Artifact artifact : artifacts )
@@ -146,7 +152,7 @@ public class TestClassifierTypeTranslato
     {
         String classifier = "jdk14";
         String type = "sources";
-        ArtifactTranslator at = new ClassifierTypeTranslator( classifier, type, artifactFactory
);
+        ArtifactTranslator at = new ClassifierTypeTranslator( classifier, type, artifactFactory,
artifactRepository );
         Set<Artifact> results = at.translate( artifacts, log );
 
         for ( Artifact artifact : artifacts )
@@ -175,7 +181,7 @@ public class TestClassifierTypeTranslato
     {
         String classifier = "class";
         String type = "type";
-        ClassifierTypeTranslator at = new ClassifierTypeTranslator( classifier, type, artifactFactory
);
+        ClassifierTypeTranslator at = new ClassifierTypeTranslator( classifier, type, artifactFactory,
null );
 
         assertEquals( classifier, at.getClassifier() );
         assertEquals( type, at.getType() );



Mime
View raw message