You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by st...@apache.org on 2011/01/20 14:25:53 UTC

svn commit: r1061291 - in /maven/ant-tasks/trunk/src: main/java/org/apache/maven/artifact/ant/DependenciesTask.java site/apt/reference.apt

Author: stephenc
Date: Thu Jan 20 13:25:53 2011
New Revision: 1061291

URL: http://svn.apache.org/viewvc?rev=1061291&view=rev
Log:
[MANTTASKS-210] added pathType attribute to allow filtering of the resolved artifacts when constructing the path object.  Default behaviour remains as is if the attribute is not defined

Modified:
    maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java
    maven/ant-tasks/trunk/src/site/apt/reference.apt

Modified: maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java
URL: http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java?rev=1061291&r1=1061290&r2=1061291&view=diff
==============================================================================
--- maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java (original)
+++ maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java Thu Jan 20 13:25:53 2011
@@ -120,6 +120,11 @@ public class DependenciesTask
     private String type;
 
     /**
+     * A comma separated list of dependency types to include in the resulting path object.
+     */
+    private String pathType;
+
+    /**
      * The file name to use for the generated Ant build that contains dependency properties and references.
      */
     private String dependencyRefsBuildFile;
@@ -281,11 +286,22 @@ public class DependenciesTask
 
         Set<String> versions = new HashSet<String>();
 
+        ArtifactFilter pathFilter;
+
+        if ( pathType  != null )
+        {
+            pathFilter = new TypesArtifactFilter( pathType );
+        }
+        else
+        {
+            pathFilter = null;
+        }
+
         for ( Iterator<Artifact> i = result.getArtifacts().iterator(); i.hasNext(); )
         {
             Artifact artifact = i.next();
 
-            addArtifactToResult( localRepo, artifact, dependencyFileSet, dependencyPath );
+            addArtifactToResult( localRepo, artifact, dependencyFileSet, dependencyPath, pathFilter );
 
             versions.add( artifact.getVersion() );
 
@@ -460,11 +476,11 @@ public class DependenciesTask
     private void addArtifactToResult( ArtifactRepository localRepo, Artifact artifact,
                                       FileSet toFileSet )
     {
-        addArtifactToResult( localRepo, artifact, toFileSet, null );
+        addArtifactToResult( localRepo, artifact, toFileSet, null, null );
     }
 
     private void addArtifactToResult( ArtifactRepository localRepo, Artifact artifact,
-                                      FileSet toFileSet, Path path )
+                                      FileSet toFileSet, Path path, ArtifactFilter filter )
     {
         String filename = localRepo.pathOf( artifact );
 
@@ -477,7 +493,7 @@ public class DependenciesTask
         artifactFileSet.setFile( artifact.getFile() );
         getProject().addReference( artifact.getDependencyConflictId(), artifactFileSet );
 
-        if ( path != null )
+        if ( path != null && ( filter == null || filter.include( artifact ) ) )
         {
             path.addFileset( artifactFileSet );
         }
@@ -588,6 +604,11 @@ public class DependenciesTask
         this.type = type;
     }
 
+    public void setPathType( String pathType )
+    {
+        this.pathType = pathType;
+    }
+
     public String getScopes()
     {
         return scopes;

Modified: maven/ant-tasks/trunk/src/site/apt/reference.apt
URL: http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/site/apt/reference.apt?rev=1061291&r1=1061290&r2=1061291&view=diff
==============================================================================
--- maven/ant-tasks/trunk/src/site/apt/reference.apt (original)
+++ maven/ant-tasks/trunk/src/site/apt/reference.apt Thu Jan 20 13:25:53 2011
@@ -56,6 +56,8 @@
 *-------------------------+---------------------------------------------------------------------------+--------------+-------------+
 | <<<type>>>              | A comma separated list of artifact types to be retrieved. By default all artifact types will be included.   | No     |    |
 *-------------------------+---------------------------------------------------------------------------+--------------+-------------+
+| <<<pathType>>>          | A comma separated list of artifact types to be added to the path object. By default all artifact types will be included.   | No     |    |
+*-------------------------+---------------------------------------------------------------------------+--------------+-------------+
 | <<<useScope>>>          | Follows the Maven scope behaviour.  Can be set to <<<compile>>>, <<<runtime>>>, or <<<test>>>.  If no value is provided, all scopes will be included.  | No   |    |
 *-------------------------+---------------------------------------------------------------------------+--------------+-------------+
 | <<<scopes>>>            | A comma separated list of specific scopes to be retrieved.  If no value is provided, all scopes will be included.  | No   |  2.0.10  |