mirror of https://github.com/apache/maven.git
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. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163185 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cf8d34fe69
commit
fa9735291f
|
@ -1,9 +1,9 @@
|
|||
package org.apache.maven.artifact.resolver;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -30,6 +30,8 @@ public interface ArtifactResolver
|
|||
ArtifactMetadataSource source )
|
||||
throws ArtifactResolutionException;
|
||||
|
||||
|
||||
|
||||
Set resolve( Set artifacts,
|
||||
Set remoteRepositories,
|
||||
ArtifactRepository localRepository )
|
||||
|
@ -40,4 +42,13 @@ public interface ArtifactResolver
|
|||
ArtifactRepository localRepository,
|
||||
ArtifactMetadataSource source )
|
||||
throws ArtifactResolutionException;
|
||||
|
||||
ArtifactResolutionResult resolveTransitively( Set artifacts,
|
||||
Set remoteRepositories,
|
||||
ArtifactRepository localRepository,
|
||||
ArtifactMetadataSource source,
|
||||
ArtifactFilter filter )
|
||||
throws ArtifactResolutionException;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,10 +2,11 @@ package org.apache.maven.artifact.resolver;
|
|||
|
||||
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 class DefaultArtifactResolver
|
|||
public ArtifactResolutionResult resolveTransitively( Set artifacts,
|
||||
Set remoteRepositories,
|
||||
ArtifactRepository localRepository,
|
||||
ArtifactMetadataSource source )
|
||||
ArtifactMetadataSource source,
|
||||
ArtifactFilter filter )
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
ArtifactResolutionResult artifactResolutionResult;
|
||||
|
@ -127,7 +129,8 @@ public class DefaultArtifactResolver
|
|||
artifactResolutionResult = collect( artifacts,
|
||||
localRepository,
|
||||
remoteRepositories,
|
||||
source );
|
||||
source,
|
||||
filter );
|
||||
}
|
||||
catch ( TransitiveArtifactResolutionException e )
|
||||
{
|
||||
|
@ -142,6 +145,15 @@ public class DefaultArtifactResolver
|
|||
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 class DefaultArtifactResolver
|
|||
//
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
public ArtifactResolutionResult collect( Set artifacts,
|
||||
protected ArtifactResolutionResult collect( Set artifacts,
|
||||
ArtifactRepository localRepository,
|
||||
Set remoteRepositories,
|
||||
ArtifactMetadataSource source )
|
||||
ArtifactMetadataSource source,
|
||||
ArtifactFilter filter )
|
||||
throws TransitiveArtifactResolutionException
|
||||
{
|
||||
ArtifactResolutionResult result = new ArtifactResolutionResult();
|
||||
|
@ -199,7 +212,15 @@ public class DefaultArtifactResolver
|
|||
}
|
||||
else
|
||||
{
|
||||
// ----------------------------------------------------------------------
|
||||
// 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 @@ public class DefaultArtifactResolver
|
|||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// 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();
|
||||
|
||||
|
@ -260,4 +283,17 @@ public class DefaultArtifactResolver
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue