PR: MNG-505

prepare for version ranges in the artifact collector

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@219834 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-07-20 02:30:52 +00:00
parent d5e54a5744
commit 43c132f0fd
1 changed files with 21 additions and 8 deletions

View File

@ -24,6 +24,8 @@ import org.apache.maven.artifact.metadata.ResolutionGroup;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter; import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange;
import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.PlexusTestCase;
import java.util.Arrays; import java.util.Arrays;
@ -313,9 +315,9 @@ public class DefaultArtifactCollectorTest
private class ArtifactSpec private class ArtifactSpec
{ {
Artifact artifact; private Artifact artifact;
Set dependencies = new HashSet(); private Set dependencies = new HashSet();
public ArtifactSpec addDependency( String id, String version ) public ArtifactSpec addDependency( String id, String version )
{ {
@ -338,18 +340,27 @@ public class DefaultArtifactCollectorTest
private class Source private class Source
implements ArtifactMetadataSource implements ArtifactMetadataSource
{ {
Map artifacts = new HashMap(); private Map artifacts = new HashMap();
public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories ) public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository,
List remoteRepositories )
throws ArtifactMetadataRetrievalException throws ArtifactMetadataRetrievalException
{ {
ArtifactSpec a = (ArtifactSpec) artifacts.get( artifact.getId() ); ArtifactSpec a = (ArtifactSpec) artifacts.get( artifact.getId() );
return new ResolutionGroup( createArtifacts( artifactFactory, a.dependencies, artifact.getScope(), try
artifact.getDependencyFilter() ), Collections.EMPTY_LIST ); {
return new ResolutionGroup( createArtifacts( artifactFactory, a.dependencies, artifact.getScope(),
artifact.getDependencyFilter() ), Collections.EMPTY_LIST );
}
catch ( InvalidVersionSpecificationException e )
{
throw new ArtifactMetadataRetrievalException( e );
}
} }
private Set createArtifacts( ArtifactFactory artifactFactory, Set dependencies, String inheritedScope, private Set createArtifacts( ArtifactFactory artifactFactory, Set dependencies, String inheritedScope,
ArtifactFilter dependencyFilter ) ArtifactFilter dependencyFilter )
throws InvalidVersionSpecificationException
{ {
Set projectArtifacts = new HashSet(); Set projectArtifacts = new HashSet();
@ -357,8 +368,10 @@ public class DefaultArtifactCollectorTest
{ {
Artifact d = (Artifact) i.next(); Artifact d = (Artifact) i.next();
Artifact artifact = artifactFactory.createArtifact( d.getGroupId(), d.getArtifactId(), d.getVersion(), VersionRange versionRange = VersionRange.createFromVersionSpec( d.getVersion() );
d.getScope(), d.getType(), inheritedScope ); Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(),
versionRange, d.getType(), d.getScope(),
inheritedScope );
if ( artifact != null && ( dependencyFilter == null || dependencyFilter.include( artifact ) ) ) if ( artifact != null && ( dependencyFilter == null || dependencyFilter.include( artifact ) ) )
{ {