From 8b22b2dffa01a5276cbae8fd22444275e82cd74c Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Sun, 24 May 2009 14:35:25 +0000 Subject: [PATCH] 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 --- .../resolver/DefaultArtifactResolver.java | 18 +++--------------- .../resolver/ArtifactResolverTest.java | 6 ++---- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java index 9b99568f16..8c10e8e3b8 100644 --- a/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java +++ b/maven-compat/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java @@ -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(); @@ -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 allArtifacts = new LinkedHashSet(); diff --git a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java index 3197fb8123..16ae8f561c 100644 --- a/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java +++ b/maven-compat/src/test/java/org/apache/maven/artifact/resolver/ArtifactResolverTest.java @@ -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() ); }