maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject cvs commit: maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/resolver ArtifactResolver.java DefaultArtifactResolver.java
Date Wed, 06 Oct 2004 14:30:00 GMT
jvanzyl     2004/10/06 07:30:00

  Modified:    maven-artifact/src/main/java/org/apache/maven/artifact/resolver
                        ArtifactResolver.java DefaultArtifactResolver.java
  Log:
  o putting into play the use of the artifact filter during the transitive
    collection of artifacts.
  
    -> I was previously using a an exclude list but that was only taking into
       account the top-level pass of the artifacts so what was happening was
       things like maven-core weren't going in repeatedly but all of
       maven-core's deps were going in repeatedly. So by using the filter
       in the collector that sort of behaviour is stopped and now I can
       make the filter do anything I want to account for any weirdisms
       I subsequently encounter.
  
  Revision  Changes    Path
  1.2       +15 -4     maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolver.java
  
  Index: ArtifactResolver.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolver.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ArtifactResolver.java	9 Aug 2004 18:37:33 -0000	1.1
  +++ ArtifactResolver.java	6 Oct 2004 14:30:00 -0000	1.2
  @@ -1,9 +1,9 @@
   package org.apache.maven.artifact.resolver;
   
   import org.apache.maven.artifact.Artifact;
  -import org.apache.maven.artifact.repository.ArtifactRepository;
  -import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
  +import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
   import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
  +import org.apache.maven.artifact.repository.ArtifactRepository;
   
   import java.util.Set;
   
  @@ -23,13 +23,15 @@
                         Set remoteRepositories,
                         ArtifactRepository localRepository )
           throws ArtifactResolutionException;
  -
  +    
       ArtifactResolutionResult resolveTransitively( Artifact artifact,
                                                     Set remoteRepositories,
                                                     ArtifactRepository localRepository,
                                                     ArtifactMetadataSource source )
           throws ArtifactResolutionException;
   
  +    
  +    
       Set resolve( Set artifacts,
                    Set remoteRepositories,
                    ArtifactRepository localRepository )
  @@ -40,4 +42,13 @@
                                                     ArtifactRepository localRepository,
                                                     ArtifactMetadataSource source )
           throws ArtifactResolutionException;
  +
  +    ArtifactResolutionResult resolveTransitively( Set artifacts,
  +                                                  Set remoteRepositories,
  +                                                  ArtifactRepository localRepository,
  +                                                  ArtifactMetadataSource source,
  +                                                  ArtifactFilter filter )
  +        throws ArtifactResolutionException;
  +    
  +    
   }
  
  
  
  1.6       +44 -8     maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
  
  Index: DefaultArtifactResolver.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultArtifactResolver.java	29 Sep 2004 11:20:38 -0000	1.5
  +++ DefaultArtifactResolver.java	6 Oct 2004 14:30:00 -0000	1.6
  @@ -2,10 +2,11 @@
   
   import org.apache.maven.artifact.AbstractArtifactComponent;
   import org.apache.maven.artifact.Artifact;
  +import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
   import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundException;
   import org.apache.maven.artifact.manager.WagonManager;
  -import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
   import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
  +import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
   import org.apache.maven.artifact.repository.ArtifactRepository;
   import org.apache.maven.wagon.TransferFailedException;
   
  @@ -117,7 +118,8 @@
       public ArtifactResolutionResult resolveTransitively( Set artifacts,
                                                            Set remoteRepositories,
                                                            ArtifactRepository localRepository,
  -                                                         ArtifactMetadataSource source
)
  +                                                         ArtifactMetadataSource source,
  +                                                         ArtifactFilter filter )
           throws ArtifactResolutionException
       {
           ArtifactResolutionResult artifactResolutionResult;
  @@ -127,7 +129,8 @@
               artifactResolutionResult = collect( artifacts,
                                                   localRepository,
                                                   remoteRepositories,
  -                                                source );
  +                                                source,
  +                                                filter );
           }
           catch ( TransitiveArtifactResolutionException e )
           {
  @@ -142,6 +145,15 @@
           return artifactResolutionResult;
       }
   
  +    public ArtifactResolutionResult resolveTransitively( Set artifacts,
  +                                                         Set remoteRepositories,
  +                                                         ArtifactRepository localRepository,
  +                                                         ArtifactMetadataSource source
)
  +        throws ArtifactResolutionException
  +    {
  +        return resolveTransitively( artifacts, remoteRepositories, localRepository, source,
null );
  +    }
  +
       public ArtifactResolutionResult resolveTransitively( Artifact artifact,
                                                            Set remoteRepositories,
                                                            ArtifactRepository localRepository,
  @@ -160,10 +172,11 @@
       //
       // ----------------------------------------------------------------------
   
  -    public ArtifactResolutionResult collect( Set artifacts,
  -                                             ArtifactRepository localRepository,
  -                                             Set remoteRepositories,
  -                                             ArtifactMetadataSource source )
  +    protected ArtifactResolutionResult collect( Set artifacts,
  +                                                ArtifactRepository localRepository,
  +                                                Set remoteRepositories,
  +                                                ArtifactMetadataSource source,
  +                                                ArtifactFilter filter )
           throws TransitiveArtifactResolutionException
       {
           ArtifactResolutionResult result = new ArtifactResolutionResult();
  @@ -199,7 +212,15 @@
                   }
                   else
                   {
  -                    //It's the first time we have encountered this artifact
  +                    // ----------------------------------------------------------------------
  +                    // It's the first time we have encountered this artifact
  +                    // ----------------------------------------------------------------------
  +
  +                    if ( filter != null && !filter.include( newArtifact.getArtifactId()
) )
  +                    {
  +                        continue;
  +                    }
  +
                       resolvedArtifacts.put( id, newArtifact );
   
                       Set referencedDependencies = null;
  @@ -219,8 +240,10 @@
               }
           }
   
  +        // ----------------------------------------------------------------------
           // the dependencies list is keyed by groupId+artifactId+type
           // so it must be 'rekeyed' to the complete id: groupId+artifactId+type+version
  +        // ----------------------------------------------------------------------
   
           Map artifactResult = result.getArtifacts();
   
  @@ -259,5 +282,18 @@
           }
   
           conflicts.add( newArtifact );
  +    }
  +
  +    protected boolean includeArtifact( String artifactId, String[] artifactExcludes )
  +    {
  +        for ( int b = 0; b < artifactExcludes.length; b++ )
  +        {
  +            if ( artifactId.equals( artifactExcludes[b] ) )
  +            {
  +                return false;
  +            }
  +        }
  +
  +        return true;
       }
   }
  
  
  

Mime
View raw message