o Restored original behavior of legacy resolution methods (every client and not just Surefire that calls the old methods expects the root artifact to not be resolved as in 2.x now)

git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@778161 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-05-24 14:35:25 +00:00
parent 22b4d0ee5f
commit 8b22b2dffa
2 changed files with 5 additions and 19 deletions

View File

@ -329,6 +329,7 @@ public class DefaultArtifactResolver
{
ArtifactResolutionRequest request = new ArtifactResolutionRequest()
.setArtifact( originatingArtifact )
.setResolveRoot( false )
// This is required by the surefire plugin
.setArtifactDependencies( artifacts )
.setManagedVersionMap( managedVersions )
@ -357,11 +358,6 @@ public class DefaultArtifactResolver
// ------------------------------------------------------------------------
//
// ------------------------------------------------------------------------
private boolean isDummy( ArtifactResolutionRequest request )
{
return request.getArtifact().getArtifactId().equals( "dummy" ) && request.getArtifact().getGroupId().equals( "dummy" );
}
public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
{
@ -386,15 +382,7 @@ public class DefaultArtifactResolver
// won't happen
}
}
// This is an extreme hack because of the ridiculous APIs we have a root that is disconnected and
// useless. The SureFire plugin passes in a dummy root artifact that is actually used in the production
// plugin ... We have no choice but to put this hack in the core.
if ( isDummy( request ) )
{
request.setResolveRoot( false );
}
if ( listeners == null )
{
listeners = new ArrayList<ResolutionListener>();
@ -513,7 +501,7 @@ public class DefaultArtifactResolver
// We want to send the root artifact back in the result but we need to do this after the other dependencies
// have been resolved.
if ( request.isResolveRoot() && !isDummy( request ) )
if ( request.isResolveRoot() )
{
// Add the root artifact (as the first artifact to retain logical order of class path!)
Set<Artifact> allArtifacts = new LinkedHashSet<Artifact>();

View File

@ -113,7 +113,7 @@ public class ArtifactResolverTest
ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections.singleton( g ), projectArtifact, remoteRepositories(), localRepository(), null );
assertEquals( 3, result.getArtifacts().size() );
assertEquals( 2, result.getArtifacts().size() );
assertTrue( result.getArtifacts().contains( g ) );
@ -135,7 +135,7 @@ public class ArtifactResolverTest
ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections.singleton( i ), projectArtifact, remoteRepositories(), localRepository(), null );
assertEquals( 3, result.getArtifacts().size() );
assertEquals( 2, result.getArtifacts().size() );
assertTrue( result.getArtifacts().contains( i ) );
@ -231,7 +231,6 @@ public class ArtifactResolverTest
artifactResolver.resolveTransitively( set, projectArtifact, remoteRepositories(), localRepository(), mds );
Iterator i = result.getArtifacts().iterator();
i.next();
assertEquals( "n should be first", n, i.next() );
assertEquals( "m should be second", m, i.next() );
@ -244,7 +243,6 @@ public class ArtifactResolverTest
artifactResolver.resolveTransitively( set, projectArtifact, remoteRepositories(), localRepository(), mds );
i = result.getArtifacts().iterator();
i.next();
assertEquals( "m should be first", m, i.next() );
assertEquals( "n should be second", n, i.next() );
}