You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2006/11/14 04:18:44 UTC
svn commit: r474639 - in /maven/plugins/trunk/maven-dependency-plugin/src:
main/java/org/apache/maven/plugin/dependency/
main/java/org/apache/maven/plugin/dependency/utils/filters/ site/apt/
test/java/org/apache/maven/plugin/dependency/ test/java/org/a...
Author: brianf
Date: Mon Nov 13 19:18:43 2006
New Revision: 474639
URL: http://svn.apache.org/viewvc?view=rev&rev=474639
Log:
DEP-43 applied patch from Richard van der Hoff to allow include/exclude by classifier. Also updated site docs.
Added:
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactFeatureFilter.java
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ClassifierFilter.java
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestClassifierFilter.java
Modified:
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyFilterMojo.java
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/TypeFilter.java
maven/plugins/trunk/maven-dependency-plugin/src/site/apt/usage.apt
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo.java
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/ArtifactStubFactory.java
maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestTypeFilter.java
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyFilterMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyFilterMojo.java?view=diff&rev=474639&r1=474638&r2=474639
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyFilterMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractDependencyFilterMojo.java Mon Nov 13 19:18:43 2006
@@ -22,6 +22,7 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.dependency.utils.DependencyStatusSets;
import org.apache.maven.plugin.dependency.utils.filters.ArtifactsFilter;
+import org.apache.maven.plugin.dependency.utils.filters.ClassifierFilter;
import org.apache.maven.plugin.dependency.utils.filters.FilterArtifacts;
import org.apache.maven.plugin.dependency.utils.filters.ScopeFilter;
import org.apache.maven.plugin.dependency.utils.filters.TransitivityFilter;
@@ -82,6 +83,24 @@
protected String excludeScope;
/**
+ * Comma Separated list of Classifiers to include. Empty String indicates include
+ * everything (default).
+ * @since 2.0
+ * @parameter expression="${includeClassifiers}" default-value=""
+ * @optional
+ */
+ protected String includeClassifiers;
+
+ /**
+ * Comma Separated list of Classifiers to exclude. Empty String indicates don't
+ * exclude anything (default). Ignored if includeClassifiers is used.
+ * @since 2.0
+ * @parameter expression="${excludeClassifiers}" default-value=""
+ * @optional
+ */
+ protected String excludeClassifiers;
+
+ /**
* Specify classifier to look for. Example: sources
* @optional
* @since 2.0
@@ -158,6 +177,7 @@
filter.addFilter( new TransitivityFilter( project.getDependencyArtifacts(), this.excludeTransitive ) );
filter.addFilter( new ScopeFilter( this.includeScope, this.excludeScope ) );
filter.addFilter( new TypeFilter( this.includeTypes, this.excludeTypes ) );
+ filter.addFilter( new ClassifierFilter( this.includeClassifiers, this.excludeClassifiers ) );
// start with all artifacts.
Set artifacts = project.getArtifacts();
Added: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactFeatureFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactFeatureFilter.java?view=auto&rev=474639
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactFeatureFilter.java (added)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/AbstractArtifactFeatureFilter.java Mon Nov 13 19:18:43 2006
@@ -0,0 +1,209 @@
+/*
+ * Licensed 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.
+ */
+
+package org.apache.maven.plugin.dependency.utils.filters;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.logging.Log;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * This is the common base class of ClassifierFilter and TypeFilter
+ *
+ * @author <a href="richardv@mxtelecom.com">Richard van der Hoff</a>
+ */
+public abstract class AbstractArtifactFeatureFilter implements ArtifactsFilter {
+ /** The list of types or classifiers to include */
+ private List includes;
+
+ /** The list of types or classifiers to exclude (ignored if includes != null) */
+ private List excludes;
+
+ /** The configuration string for the include list - comma separated */
+ private String includeString;
+
+ /** The configuration string for the exclude list - comma separated */
+ private String excludeString;
+
+ /** The name of the feature we are filtering on - for logging - "Classifiers" or "Types" */
+ private String featureName;
+
+ public AbstractArtifactFeatureFilter( String include, String exclude, String featureName )
+ {
+ setExcludes( exclude );
+ setIncludes( include );
+ this.featureName = featureName;
+ }
+
+ /**
+ * This function determines if filtering needs to be performed. Excludes are
+ * ignored if Includes are used.
+ *
+ * @param dependencies
+ * the set of dependencies to filter.
+ *
+ * @return a Set of filtered dependencies.
+ */
+ public Set filter( Set artifacts, Log log )
+ {
+ Set results = artifacts;
+
+ if ( this.includes != null && !this.includes.isEmpty() )
+ {
+ log.debug( "Including only "+featureName+": " + this.includeString );
+ results = filterIncludes( artifacts, this.includes );
+ }
+ else
+ {
+ if ( this.excludes != null && !this.excludes.isEmpty() )
+ {
+ log.debug( "Excluding "+featureName+": " + this.excludeString );
+ results = filterExcludes( artifacts, this.excludes );
+ }
+ }
+ return results;
+ }
+
+ /**
+ * Processes the dependencies list and includes the dependencies that match
+ * a filter in the list.
+ *
+ * @param depends
+ * List of dependencies.
+ * @param includes
+ * List of types or classifiers to include.
+ *
+ * @return a set of filtered artifacts.
+ */
+ private Set filterIncludes( Set artifacts, List theIncludes )
+ {
+ Set result = new HashSet();
+
+ Iterator includeIter = theIncludes.iterator();
+ while ( includeIter.hasNext() )
+ {
+ String include = (String) includeIter.next();
+ Iterator iter = artifacts.iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+
+ // if the classifier or type of the artifact matches the feature to include, add to the
+ // results
+ if ( getArtifactFeature(artifact).equals( include ) )
+ {
+ result.add( artifact );
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Processes the dependencies list and excludes the dependencies that match
+ * a filter in the list.
+ *
+ * @param depends
+ * List of dependencies.
+ * @param excludes
+ * List of types or classifiers to exclude.
+ *
+ * @return a set of filtered artifacts.
+ */
+ private Set filterExcludes( Set artifacts, List theExcludes )
+ {
+ Set result = new HashSet();
+
+ Iterator iter = artifacts.iterator();
+ while ( iter.hasNext() )
+ {
+ boolean exclude = false;
+ Artifact artifact = (Artifact) iter.next();
+ String artifactFeature = getArtifactFeature(artifact);
+
+ // look through all types or classifiers. If no matches are found
+ // then it can be added to the results.
+ Iterator excludeIter = theExcludes.iterator();
+ while ( excludeIter.hasNext() )
+ {
+ String excludeFeature = (String) excludeIter.next();
+ if ( artifactFeature.equals( excludeFeature ) )
+ {
+ exclude = true;
+ break;
+ }
+ }
+
+ if ( !exclude )
+ {
+ result.add( artifact );
+ }
+ }
+
+ return result;
+ }
+
+
+
+ /**
+ * Should return the type or classifier of the given artifact, so that we can filter it
+ *
+ * @param artifact artifact to return type or classifier of
+ * @return type or classifier
+ */
+ protected abstract String getArtifactFeature(Artifact artifact);
+
+ public void setExcludes( String excludeString )
+ {
+ this.excludeString = excludeString;
+
+ if ( StringUtils.isNotEmpty( excludeString ) )
+ {
+ this.excludes = Arrays.asList( StringUtils.split( excludeString, "," ) );
+ }
+ }
+
+
+ public void setIncludes( String includeString )
+ {
+ this.includeString = includeString;
+
+ if ( StringUtils.isNotEmpty( includeString ) )
+ {
+ this.includes = Arrays.asList( StringUtils.split( includeString, "," ) );
+ }
+ }
+
+ /**
+ * @return Returns the excludes.
+ */
+ public List getExcludes()
+ {
+ return this.excludes;
+ }
+
+ /**
+ * @return Returns the includes.
+ */
+ public List getIncludes()
+ {
+ return this.includes;
+ }
+}
Added: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ClassifierFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ClassifierFilter.java?view=auto&rev=474639
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ClassifierFilter.java (added)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/ClassifierFilter.java Mon Nov 13 19:18:43 2006
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2006 MX Telecom Ltd. <ri...@mxtelecom.com>
+ *
+ * Licensed 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.
+ */
+package org.apache.maven.plugin.dependency.utils.filters;
+
+import org.apache.maven.artifact.Artifact;
+
+public class ClassifierFilter extends AbstractArtifactFeatureFilter
+{
+ public ClassifierFilter( String include, String exclude )
+ {
+ super(include,exclude,"Classifiers");
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.maven.plugin.dependency.utils.filters.AbstractArtifactFeatureFilter#getArtifactFeature(org.apache.maven.artifact.Artifact)
+ */
+ protected String getArtifactFeature(Artifact artifact) {
+ return artifact.getClassifier();
+ }
+ }
Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/TypeFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/TypeFilter.java?view=diff&rev=474639&r1=474638&r2=474639
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/TypeFilter.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/utils/filters/TypeFilter.java Mon Nov 13 19:18:43 2006
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2006 Brian Fox (brianefox@gmail.com)
+ * Copyright 2006 MX Telecom Ltd. <ri...@mxtelecom.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,182 +15,19 @@
*/
package org.apache.maven.plugin.dependency.utils.filters;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.logging.Log;
-import org.codehaus.plexus.util.StringUtils;
-public class TypeFilter
- implements ArtifactsFilter
+public class TypeFilter extends AbstractArtifactFeatureFilter
{
- private List includeTypes;
-
- private List excludeTypes;
-
- private String includeString;
-
- private String excludeString;
-
public TypeFilter( String include, String exclude )
{
- setExcludeTypes( exclude );
- setIncludeTypes( include );
- }
-
- /**
- * This function determines if filtering needs to be performed. Excludes are
- * ignored if Includes are used.
- *
- * @param dependencies
- * the set of dependencies to filter.
- *
- * @return a Set of filtered dependencies.
- */
- public Set filter( Set artifacts, Log log )
- {
- Set results = artifacts;
-
- if ( this.includeTypes != null && !this.includeTypes.isEmpty() )
- {
- log.debug( "Including only Types: " + this.includeString );
- results = filterIncludes( artifacts, this.includeTypes );
- }
- else
- {
- if ( this.excludeTypes != null && !this.excludeTypes.isEmpty() )
- {
- log.debug( "Excluding Types: " + this.excludeString );
- results = filterExcludes( artifacts, this.excludeTypes );
- }
- }
- return results;
- }
-
- /**
- * Processes the dependencies list and includes the dependencies that match
- * a type in the list.
- *
- * @param depends
- * List of dependencies.
- * @param types
- * List of types to include.
- *
- * @return a set of filtered types.
- */
- private Set filterIncludes( Set artifacts, List types )
- {
- Set result = new HashSet();
-
- Iterator typeIter = types.iterator();
- while ( typeIter.hasNext() )
- {
- String artifactType = (String) typeIter.next();
- Iterator iter = artifacts.iterator();
- while ( iter.hasNext() )
- {
- Artifact artifact = (Artifact) iter.next();
-
- // if the type matches the type, add to the
- // results
- if ( artifact.getType().equals( artifactType ) )
- {
- result.add( artifact );
- }
- }
- }
- return result;
- }
-
- /**
- * Processes the dependencies list and excludes the dependencies that match
- * a type in the list.
- *
- * @param depends
- * List of dependencies.
- * @param types
- * List of types to exclude.
- *
- * @return a set of filtered types.
- */
- private Set filterExcludes( Set artifacts, List types )
- {
- Set result = new HashSet();
-
- Iterator iter = artifacts.iterator();
- while ( iter.hasNext() )
- {
- boolean exclude = false;
- Artifact artifact = (Artifact) iter.next();
-
- // look through all types. If no matches are found
- // then it can be added to the results.
- Iterator typeIter = types.iterator();
- while ( typeIter.hasNext() )
- {
- String artifactType = (String) typeIter.next();
- if ( artifact.getType().equals( artifactType ) )
- {
- exclude = true;
- break;
- }
- }
-
- if ( !exclude )
- {
- result.add( artifact );
- }
- }
-
- return result;
- }
-
- /**
- * @param includeTypes
- * The includeTypes to set.
- */
- public void setExcludeTypes( String excludeTypeString )
- {
- this.excludeString = excludeTypeString;
-
- if ( StringUtils.isNotEmpty( excludeTypeString ) )
- {
- this.excludeTypes = Arrays.asList( StringUtils.split( excludeTypeString, "," ) );
- }
- }
-
- /**
- * @param includeTypes
- * The includeTypes to set.
- */
- public void setIncludeTypes( String includeTypeString )
- {
- this.includeString = includeTypeString;
-
- if ( StringUtils.isNotEmpty( includeTypeString ) )
- {
- this.includeTypes = Arrays.asList( StringUtils.split( includeTypeString, "," ) );
- }
- }
-
- /**
- * @return Returns the excludeTypes.
- */
- public List getExcludeTypes()
- {
- return this.excludeTypes;
+ super(include, exclude, "Types");
}
- /**
- * @return Returns the includeTypes.
+ /* (non-Javadoc)
+ * @see org.apache.maven.plugin.dependency.utils.filters.AbstractArtifactFeatureFilter#getArtifactFeature(org.apache.maven.artifact.Artifact)
*/
- public List getIncludeTypes()
- {
- return this.includeTypes;
+ protected String getArtifactFeature(Artifact artifact) {
+ return artifact.getType();
}
-
}
Modified: maven/plugins/trunk/maven-dependency-plugin/src/site/apt/usage.apt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/site/apt/usage.apt?view=diff&rev=474639&r1=474638&r2=474639
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/site/apt/usage.apt (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/site/apt/usage.apt Mon Nov 13 19:18:43 2006
@@ -99,7 +99,7 @@
<<<mvn dependency:copy-dependencies -Dclassifer=sources>>> will try to find
the sources for all dependencies and copy them.
- Also included is the ability to include or exclude by type (war, jar etc) and / or scope (runtime, test etc).
+ Also included is the ability to include or exclude by type (war, jar etc), scope (runtime, test, etc), classifier (jdk14, sources, etc) or a combination of all three.
Artifacts are copied using the following rules:
@@ -219,7 +219,7 @@
<<<mvn dependency:unpack-dependencies -Dclassifer=sources>>> will try to find
the sources for all dependencies and unpack them.
- Also included is the ability to include or exclude by type (war, jar etc) and / or scope (runtime, test etc).
+ Also included is the ability to include or exclude by type (war, jar etc), scope (runtime, test, etc), classifier (jdk14, sources, etc) or a combination of all three.
Artifacts are copied using the following rules:
Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo.java?view=diff&rev=474639&r1=474638&r2=474639
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo.java Mon Nov 13 19:18:43 2006
@@ -190,6 +190,60 @@
assertTrue( mojo.outputDirectory.delete() );
}
+ public void testCopyDependenciesMojoExcludeClassifier()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getClassifiedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+ mojo.excludeClassifiers = "one";
+ mojo.execute();
+
+ // test - get all direct dependencies and verify that they exist if they
+ // do not have a classifier of "one"
+ // then delete the file and at the end, verify the folder is empty.
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+ assertEquals( artifact.getClassifier().equals( "one" ), !file.exists() );
+ file.delete();
+ assertFalse( file.exists() );
+ }
+ // assumes you can't delete a folder that has files.
+ assertTrue( mojo.outputDirectory.delete() );
+ }
+
+ public void testCopyDependenciesMojoIncludeClassifier()
+ throws Exception
+ {
+ mojo.project.setArtifacts( stubFactory.getClassifiedArtifacts() );
+ mojo.project.setDependencyArtifacts( new HashSet() );
+
+ mojo.includeClassifiers = "one";
+ // if include is used, exclude should be ignored.
+ mojo.excludeClassifiers = "one";
+
+ mojo.execute();
+
+ // test - get all direct dependencies and verify that they exist only if
+ // they are a jar
+ // then delete the file and at the end, verify the folder is empty.
+ Iterator iter = mojo.project.getArtifacts().iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ String fileName = DependencyUtil.getFormattedFileName( artifact, false );
+ File file = new File( mojo.outputDirectory, fileName );
+ assertEquals( artifact.getClassifier().equals( "one" ), file.exists() );
+ file.delete();
+ assertFalse( file.exists() );
+ }
+ // assumes you can't delete a folder that has files.
+ assertTrue( mojo.outputDirectory.delete() );
+ }
+
public void testCopyDependenciesMojoSubPerType()
throws Exception
{
@@ -588,4 +642,4 @@
assertEquals( mojo.getDependencies( true ).toString(), mojo.getDependencySets( true ).getResolvedDependencies()
.toString() );
}
-}
\ No newline at end of file
+}
Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/ArtifactStubFactory.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/ArtifactStubFactory.java?view=diff&rev=474639&r1=474638&r2=474639
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/ArtifactStubFactory.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/ArtifactStubFactory.java Mon Nov 13 19:18:43 2006
@@ -194,6 +194,17 @@
return set;
}
+ public Set getClassifiedArtifacts()
+ throws IOException
+ {
+ Set set = new HashSet();
+ set.add( createArtifact( "g", "a", "1.0", Artifact.SCOPE_COMPILE, "jar", "one" ) );
+ set.add( createArtifact( "g", "b", "1.0", Artifact.SCOPE_COMPILE, "jar", "two" ) );
+ set.add( createArtifact( "g", "c", "1.0", Artifact.SCOPE_COMPILE, "jar", "three" ) );
+ set.add( createArtifact( "g", "d", "1.0", Artifact.SCOPE_COMPILE, "jar", "four" ) );
+ return set;
+ }
+
public Set getTypedArchiveArtifacts()
throws IOException
{
Added: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestClassifierFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestClassifierFilter.java?view=auto&rev=474639
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestClassifierFilter.java (added)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestClassifierFilter.java Mon Nov 13 19:18:43 2006
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2005-2006 Brian Fox (brianefox@gmail.com)
+ *
+ * Licensed 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.
+ */
+/**
+ *
+ */
+package org.apache.maven.plugin.dependency.utils.filters;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.dependency.utils.ArtifactStubFactory;
+import org.apache.maven.plugin.dependency.utils.SilentLog;
+import org.apache.maven.plugin.logging.Log;
+
+/**
+ * @author brianf
+ *
+ */
+public class TestClassifierFilter
+ extends TestCase
+{
+ Set artifacts = new HashSet();
+
+ Log log = new SilentLog();
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ ArtifactStubFactory factory = new ArtifactStubFactory( null, false );
+ artifacts = factory.getClassifiedArtifacts();
+ }
+
+ public void testClassifierParsing()
+ {
+ ClassifierFilter filter = new ClassifierFilter( "one,two", "three,four," );
+ List includes = filter.getIncludes();
+ List excludes = filter.getExcludes();
+
+ assertEquals( 2, includes.size() );
+ assertEquals( 2, excludes.size() );
+ assertEquals( "one", includes.get( 0 ).toString() );
+ assertEquals( "two", includes.get( 1 ).toString() );
+ assertEquals( "three", excludes.get( 0 ).toString() );
+ assertEquals( "four", excludes.get( 1 ).toString() );
+ }
+
+ public void testFiltering()
+ {
+ ClassifierFilter filter = new ClassifierFilter( "one,two", "one,three," );
+ Set result = filter.filter( artifacts, log );
+ assertEquals( 2, result.size() );
+
+ Iterator iter = result.iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ assertTrue( artifact.getClassifier().equals( "one" ) || artifact.getClassifier().equals( "two" ) );
+ }
+ }
+
+ public void testFiltering2()
+ {
+ ClassifierFilter filter = new ClassifierFilter( null, "one,three," );
+ Set result = filter.filter( artifacts, log );
+ assertEquals( 2, result.size() );
+
+ Iterator iter = result.iterator();
+ while ( iter.hasNext() )
+ {
+ Artifact artifact = (Artifact) iter.next();
+ assertTrue( artifact.getClassifier().equals( "two" ) || artifact.getClassifier().equals( "four" ) );
+ }
+ }
+
+ public void testFiltering3()
+ {
+ ClassifierFilter filter = new ClassifierFilter( null, null );
+ Set result = filter.filter( artifacts, log );
+ assertEquals( 4, result.size() );
+ }
+}
Modified: maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestTypeFilter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestTypeFilter.java?view=diff&rev=474639&r1=474638&r2=474639
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestTypeFilter.java (original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/utils/filters/TestTypeFilter.java Mon Nov 13 19:18:43 2006
@@ -53,8 +53,8 @@
public void testTypeParsing()
{
TypeFilter filter = new TypeFilter( "war,jar", "sources,zip," );
- List includes = filter.getIncludeTypes();
- List excludes = filter.getExcludeTypes();
+ List includes = filter.getIncludes();
+ List excludes = filter.getExcludes();
assertEquals( 2, includes.size() );
assertEquals( 2, excludes.size() );