mirror of https://github.com/apache/maven.git
implement managed versions in tests
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@191781 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a27239912d
commit
733866dfd4
|
@ -24,6 +24,7 @@ import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Artifact collector - takes a set of original artifacts and resolves all of the best versions to use
|
||||
|
@ -39,7 +40,7 @@ public interface ArtifactCollector
|
|||
ArtifactFactory artifactFactory )
|
||||
throws ArtifactResolutionException;
|
||||
|
||||
ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, Set managedVersions,
|
||||
ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, Map managedVersions,
|
||||
ArtifactRepository localRepository, List remoteRepositories,
|
||||
ArtifactMetadataSource source, ArtifactFilter filter,
|
||||
ArtifactFactory artifactFactory )
|
||||
|
|
|
@ -47,11 +47,11 @@ public class DefaultArtifactCollector
|
|||
ArtifactFactory artifactFactory )
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
return collect( artifacts, originatingArtifact, Collections.EMPTY_SET, localRepository, remoteRepositories,
|
||||
return collect( artifacts, originatingArtifact, Collections.EMPTY_MAP, localRepository, remoteRepositories,
|
||||
source, filter, artifactFactory );
|
||||
}
|
||||
|
||||
public ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, Set managedVersions,
|
||||
public ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, Map managedVersions,
|
||||
ArtifactRepository localRepository, List remoteRepositories,
|
||||
ArtifactMetadataSource source, ArtifactFilter filter,
|
||||
ArtifactFactory artifactFactory )
|
||||
|
@ -62,7 +62,8 @@ public class DefaultArtifactCollector
|
|||
ResolutionNode root = new ResolutionNode( originatingArtifact );
|
||||
root.addDependencies( artifacts, filter );
|
||||
|
||||
recurse( root, resolvedArtifacts, localRepository, remoteRepositories, source, filter, artifactFactory );
|
||||
recurse( root, resolvedArtifacts, managedVersions, localRepository, remoteRepositories, source, filter,
|
||||
artifactFactory );
|
||||
|
||||
Set set = new HashSet();
|
||||
|
||||
|
@ -82,12 +83,19 @@ public class DefaultArtifactCollector
|
|||
return result;
|
||||
}
|
||||
|
||||
private void recurse( ResolutionNode node, Map resolvedArtifacts, ArtifactRepository localRepository,
|
||||
List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter,
|
||||
ArtifactFactory artifactFactory )
|
||||
private void recurse( ResolutionNode node, Map resolvedArtifacts, Map managedVersions,
|
||||
ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source,
|
||||
ArtifactFilter filter, ArtifactFactory artifactFactory )
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
ResolutionNode previous = (ResolutionNode) resolvedArtifacts.get( node.getKey() );
|
||||
// TODO: conflict resolvers, shouldn't be munging original artifact perhaps?
|
||||
Object key = node.getKey();
|
||||
if ( managedVersions.containsKey( key ) )
|
||||
{
|
||||
node.getArtifact().setVersion( (String) managedVersions.get( key ) );
|
||||
}
|
||||
|
||||
ResolutionNode previous = (ResolutionNode) resolvedArtifacts.get( key );
|
||||
if ( previous != null )
|
||||
{
|
||||
// TODO: conflict resolvers
|
||||
|
@ -158,7 +166,7 @@ public class DefaultArtifactCollector
|
|||
}
|
||||
}
|
||||
|
||||
resolvedArtifacts.put( node.getKey(), node );
|
||||
resolvedArtifacts.put( key, node );
|
||||
|
||||
for ( Iterator i = node.getChildrenIterator(); i.hasNext(); )
|
||||
{
|
||||
|
@ -176,7 +184,7 @@ public class DefaultArtifactCollector
|
|||
remoteRepositories, e );
|
||||
}
|
||||
|
||||
recurse( child, resolvedArtifacts, localRepository, remoteRepositories, source, filter,
|
||||
recurse( child, resolvedArtifacts, managedVersions, localRepository, remoteRepositories, source, filter,
|
||||
artifactFactory );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,11 +48,11 @@ public class LegacyArtifactCollector
|
|||
ArtifactFactory artifactFactory )
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
return collect( artifacts, originatingArtifact, Collections.EMPTY_SET, localRepository, remoteRepositories,
|
||||
return collect( artifacts, originatingArtifact, Collections.EMPTY_MAP, localRepository, remoteRepositories,
|
||||
source, filter, artifactFactory );
|
||||
}
|
||||
|
||||
public ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, Set managedVersions,
|
||||
public ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, Map managedVersions,
|
||||
ArtifactRepository localRepository, List remoteRepositories,
|
||||
ArtifactMetadataSource source, ArtifactFilter filter,
|
||||
ArtifactFactory artifactFactory )
|
||||
|
|
|
@ -65,7 +65,7 @@ public class DefaultArtifactCollectorTest
|
|||
this.projectArtifact = createArtifact( "project", "1.0", null );
|
||||
}
|
||||
|
||||
public void disabledtestCircularDependencyNotIncludingCurrentProject()
|
||||
public void testCircularDependencyNotIncludingCurrentProject()
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
ArtifactSpec a = createArtifact( "a", "1.0" );
|
||||
|
@ -82,7 +82,7 @@ public class DefaultArtifactCollectorTest
|
|||
}
|
||||
}
|
||||
|
||||
public void disabledtestCircularDependencyIncludingCurrentProject()
|
||||
public void testCircularDependencyIncludingCurrentProject()
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
ArtifactSpec a = createArtifact( "a", "1.0" );
|
||||
|
@ -132,7 +132,7 @@ public class DefaultArtifactCollectorTest
|
|||
res.getArtifacts() );
|
||||
}
|
||||
|
||||
public void disabledtestResolveManagedVersion()
|
||||
public void testResolveManagedVersion()
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
ArtifactSpec a = createArtifact( "a", "1.0" );
|
||||
|
@ -284,9 +284,10 @@ public class DefaultArtifactCollectorTest
|
|||
private ArtifactResolutionResult collect( ArtifactSpec a, Artifact managedVersion )
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
Map managedVersions = Collections.singletonMap( managedVersion.getDependencyConflictId(),
|
||||
managedVersion.getVersion() );
|
||||
return artifactCollector.collect( Collections.singleton( a.artifact ), projectArtifact.artifact,
|
||||
Collections.singleton( managedVersion ), null, null, source, null,
|
||||
artifactFactory );
|
||||
managedVersions, null, null, source, null, artifactFactory );
|
||||
}
|
||||
|
||||
private ArtifactSpec createArtifact( String id, String version )
|
||||
|
|
Loading…
Reference in New Issue