diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/AndArtifactFilter.java b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/AndArtifactFilter.java new file mode 100644 index 0000000000..0a8e02dc28 --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/AndArtifactFilter.java @@ -0,0 +1,54 @@ +package org.apache.maven.artifact.resolver.filter; + +/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * 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. + */ + +import org.apache.maven.artifact.Artifact; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Apply multiple filters. + * + * @author Brett Porter + * @version $Id$ + */ +public class AndArtifactFilter + implements ArtifactFilter +{ + private final List filters = new ArrayList(); + + public boolean include( Artifact artifact ) + { + boolean include = true; + for ( Iterator i = filters.iterator(); i.hasNext() && include; ) + { + ArtifactFilter filter = (ArtifactFilter) i.next(); + if ( !filter.include( artifact ) ) + { + include = false; + } + } + return include; + } + + public void add( ArtifactFilter artifactFilter ) + { + filters.add( artifactFilter ); + } +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/ExcludesArtifactFilter.java b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/ExcludesArtifactFilter.java new file mode 100644 index 0000000000..34ab6db742 --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/ExcludesArtifactFilter.java @@ -0,0 +1,42 @@ +package org.apache.maven.artifact.resolver.filter; + +/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * 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. + */ + +import org.apache.maven.artifact.Artifact; + +import java.util.List; + +/** + * Filter to exclude from a list of artifact patterns. + * + * @author Brett Porter + * @version $Id$ + * @todo I think this is equiv. to exclusion set filter in maven-core + */ +public class ExcludesArtifactFilter + extends IncludesArtifactFilter +{ + public ExcludesArtifactFilter( List patterns ) + { + super( patterns ); + } + + public boolean include( Artifact artifact ) + { + return !super.include( artifact ); + } +} diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/IncludesArtifactFilter.java b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/IncludesArtifactFilter.java new file mode 100644 index 0000000000..02762b873a --- /dev/null +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/IncludesArtifactFilter.java @@ -0,0 +1,55 @@ +package org.apache.maven.artifact.resolver.filter; + +/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * 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. + */ + +import org.apache.maven.artifact.Artifact; + +import java.util.Iterator; +import java.util.List; + +/** + * Filter to include from a list of artifact patterns. + * + * @author Brett Porter + * @version $Id$ + */ +public class IncludesArtifactFilter + implements ArtifactFilter +{ + private final List patterns; + + public IncludesArtifactFilter( List patterns ) + { + this.patterns = patterns; + } + + public boolean include( Artifact artifact ) + { + String id = artifact.getGroupId() + ":" + artifact.getArtifactId(); + + boolean matched = false; + for ( Iterator i = patterns.iterator(); i.hasNext() & !matched; ) + { + // TODO: what about wildcards? Just specifying groups? versions? + if ( id.equals( i.next() ) ) + { + matched = true; + } + } + return matched; + } +} diff --git a/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AssemblyMojo.java b/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AssemblyMojo.java index 496aad9e14..e9822e366c 100755 --- a/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AssemblyMojo.java +++ b/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AssemblyMojo.java @@ -17,7 +17,9 @@ package org.apache.maven.plugin.assembly; */ import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.resolver.filter.ArtifactFilter; +import org.apache.maven.artifact.resolver.filter.AndArtifactFilter; +import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter; +import org.apache.maven.artifact.resolver.filter.IncludesArtifactFilter; import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; import org.apache.maven.plugin.AbstractPlugin; import org.apache.maven.plugin.PluginExecutionException; @@ -326,70 +328,4 @@ public class AssemblyMojo return defaultExcludes; } - // TODO: move to maven-artifact - generally useful - private static class AndArtifactFilter - implements ArtifactFilter - { - private final List filters = new ArrayList(); - - public boolean include( Artifact artifact ) - { - boolean include = true; - for ( Iterator i = filters.iterator(); i.hasNext() && include; ) - { - ArtifactFilter filter = (ArtifactFilter) i.next(); - if ( !filter.include( artifact ) ) - { - include = false; - } - } - return include; - } - - public void add( ArtifactFilter artifactFilter ) - { - filters.add( artifactFilter ); - } - } - - private static class IncludesArtifactFilter - implements ArtifactFilter - { - private final List patterns; - - public IncludesArtifactFilter( List patterns ) - { - this.patterns = patterns; - } - - public boolean include( Artifact artifact ) - { - String id = artifact.getGroupId() + ":" + artifact.getArtifactId(); - - boolean matched = false; - for ( Iterator i = patterns.iterator(); i.hasNext() & !matched; ) - { - // TODO: what about wildcards? Just specifying groups? versions? - if ( id.equals( i.next() ) ) - { - matched = true; - } - } - return matched; - } - } - - private static class ExcludesArtifactFilter - extends IncludesArtifactFilter - { - public ExcludesArtifactFilter( List patterns ) - { - super( patterns ); - } - - public boolean include( Artifact artifact ) - { - return !super.include( artifact ); - } - } }