brett       2005/04/12 21:29:25

  Modified:    
maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly
                        AssemblyMojo.java
  Added:       
maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter
                        AndArtifactFilter.java ExcludesArtifactFilter.java
                        IncludesArtifactFilter.java
  Log:
  move artifact filters to maven-artifact
  
  Revision  Changes    Path
  1.3       +4 -68     
maven-components/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AssemblyMojo.java
  
  Index: AssemblyMojo.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-plugins/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/AssemblyMojo.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AssemblyMojo.java 7 Apr 2005 02:43:56 -0000       1.2
  +++ AssemblyMojo.java 13 Apr 2005 04:29:25 -0000      1.3
  @@ -17,7 +17,9 @@
    */
   
   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 @@
           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 );
  -        }
  -    }
   }
  
  
  
  1.1                  
maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/AndArtifactFilter.java
  
  Index: AndArtifactFilter.java
  ===================================================================
  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 <a href="mailto:[EMAIL PROTECTED]">Brett Porter</a>
   * @version $Id: AndArtifactFilter.java,v 1.1 2005/04/13 04:29:25 brett Exp $
   */
  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 );
      }
  }
  
  
  
  1.1                  
maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/ExcludesArtifactFilter.java
  
  Index: ExcludesArtifactFilter.java
  ===================================================================
  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 <a href="mailto:[EMAIL PROTECTED]">Brett Porter</a>
   * @version $Id: ExcludesArtifactFilter.java,v 1.1 2005/04/13 04:29:25 brett 
Exp $
   * @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 );
      }
  }
  
  
  
  1.1                  
maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/filter/IncludesArtifactFilter.java
  
  Index: IncludesArtifactFilter.java
  ===================================================================
  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 <a href="mailto:[EMAIL PROTECTED]">Brett Porter</a>
   * @version $Id: IncludesArtifactFilter.java,v 1.1 2005/04/13 04:29:25 brett 
Exp $
   */
  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;
      }
  }
  
  
  

Reply via email to