Author: pgier
Date: Fri May  8 21:26:28 2009
New Revision: 773106

URL: http://svn.apache.org/viewvc?rev=773106&view=rev
Log:
[MANTTASKS-149] Allow type filter to accept multiple types.

Added:
    
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/TypesArtifactFilter.java
   (with props)
Modified:
    
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java
    
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/examples/dependencies.apt
    maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/reference.apt

Modified: 
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java
URL: 
http://svn.apache.org/viewvc/maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java?rev=773106&r1=773105&r2=773106&view=diff
==============================================================================
--- 
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java
 (original)
+++ 
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java
 Fri May  8 21:26:28 2009
@@ -30,7 +30,6 @@
 import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
 import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
-import org.apache.maven.artifact.resolver.filter.TypeArtifactFilter;
 import org.apache.maven.model.Dependency;
 import org.apache.maven.project.artifact.InvalidDependencyVersionException;
 import org.apache.maven.project.artifact.MavenMetadataSource;
@@ -152,7 +151,7 @@
             }
             if ( type != null )
             {
-                TypeArtifactFilter typeArtifactFilter = new 
TypeArtifactFilter( type );
+                ArtifactFilter typeArtifactFilter = new TypesArtifactFilter( 
type );
                 if ( filter != null )
                 {
                     AndArtifactFilter andFilter = new AndArtifactFilter();

Added: 
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/TypesArtifactFilter.java
URL: 
http://svn.apache.org/viewvc/maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/TypesArtifactFilter.java?rev=773106&view=auto
==============================================================================
--- 
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/TypesArtifactFilter.java
 (added)
+++ 
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/TypesArtifactFilter.java
 Fri May  8 21:26:28 2009
@@ -0,0 +1,63 @@
+package org.apache.maven.artifact.ant;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Artifact Filter which filters on artifact types.
+ * 
+ */
+public class TypesArtifactFilter
+    implements ArtifactFilter
+{
+    private List types = new ArrayList();
+
+    /** 
+     * Accepts a comma separated list of types
+     * 
+     * @param types
+     */
+    public TypesArtifactFilter( String types )
+    {
+        if ( !types.trim().equals( "" ) )
+        {
+            String[] typesArray = types.split( "," );
+            for ( int i = 0; i < typesArray.length; ++i )
+            {
+                this.types.add( typesArray[i].trim() );
+            }
+        }
+    }
+
+    public boolean include( Artifact artifact )
+    {
+        String artifactType = artifact.getType();
+        if ( artifactType == null || artifactType.equals( "" ) )
+        {
+            artifactType = "jar";
+        }
+        return types.contains( artifactType );
+    }
+}

Propchange: 
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/TypesArtifactFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/TypesArtifactFilter.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: 
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/examples/dependencies.apt
URL: 
http://svn.apache.org/viewvc/maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/examples/dependencies.apt?rev=773106&r1=773105&r2=773106&view=diff
==============================================================================
--- 
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/examples/dependencies.apt
 (original)
+++ 
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/examples/dependencies.apt
 Fri May  8 21:26:28 2009
@@ -171,8 +171,8 @@
 
 Filtering Dependencies by Type
 
-  Dependencies can be filterd by type by using the <<<type>>> attribute.  This 
can be set to a string
-  containing the desired type.  The following example will only include 
artifacts of the jar type.
+  Dependencies can be filterd by type by using the <<<type>>> attribute.  This 
can be set to a 
+  comma separate list of the types to select.  The following example will only 
include artifacts of the jar type.
 
 -----
     <artifact:dependencies filesetId="deps.fileset" type="jar">

Modified: 
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/reference.apt
URL: 
http://svn.apache.org/viewvc/maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/reference.apt?rev=773106&r1=773105&r2=773106&view=diff
==============================================================================
--- maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/reference.apt 
(original)
+++ maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/reference.apt 
Fri May  8 21:26:28 2009
@@ -54,7 +54,7 @@
 
*-------------------------+---------------------------------------------------------------------------+--------------+-------------+
 | <<<sourcesFilesetId>>>  | The reference ID to store a fileset under, for the 
sources attachements of the resolved dependencies. | No | 2.0.6 |
 
*-------------------------+---------------------------------------------------------------------------+--------------+-------------+
-| <<<type>>>              | The type of artifacts to be retrieved. By default 
all artifact types will be included.   | No     |    |
+| <<<type>>>              | A comma separated list of artifact types to be 
retrieved. 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   |    | 
 
*-------------------------+---------------------------------------------------------------------------+--------------+-------------+


Reply via email to