o Fixed propagation of POM-level plugin dependencies to the plugin manager

git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@771481 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-05-04 22:41:22 +00:00
parent 31061189b0
commit 3659cbd249
2 changed files with 32 additions and 6 deletions

View File

@ -19,6 +19,8 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -424,8 +426,32 @@ public class DefaultArtifactResolver
if ( request.isResolveTransitively() ) if ( request.isResolveTransitively() )
{ {
try try
{ {
artifacts = source.retrieve( rootArtifact, localRepository, remoteRepositories ).getArtifacts(); Set<Artifact> directArtifacts =
source.retrieve( rootArtifact, localRepository, remoteRepositories ).getArtifacts();
if ( artifacts == null || artifacts.isEmpty() )
{
artifacts = directArtifacts;
}
else
{
List<Artifact> allArtifacts = new ArrayList<Artifact>();
allArtifacts.addAll( artifacts );
allArtifacts.addAll( directArtifacts );
Map<String, Artifact> mergedArtifacts = new LinkedHashMap<String, Artifact>();
for ( Artifact artifact : allArtifacts )
{
String conflictId = artifact.getDependencyConflictId();
if ( !mergedArtifacts.containsKey( conflictId ) )
{
mergedArtifacts.put( conflictId, artifact );
}
}
artifacts = new LinkedHashSet<Artifact>( mergedArtifacts.values() );
}
} }
catch ( ArtifactMetadataRetrievalException e ) catch ( ArtifactMetadataRetrievalException e )
{ {

View File

@ -468,15 +468,15 @@ public class DefaultLifecycleExecutor
throw new LifecycleExecutionException( message ); throw new LifecycleExecutionException( message );
} }
if ( plugin.getVersion() == null ) for ( Plugin buildPlugin : project.getBuildPlugins() )
{ {
for ( Plugin buildPlugin : project.getBuildPlugins() ) if ( buildPlugin.getKey().equals( plugin.getKey() ) )
{ {
if ( buildPlugin.getKey().equals( plugin.getKey() ) ) if ( plugin.getVersion() == null || plugin.getVersion().equals( buildPlugin.getVersion() ) )
{ {
plugin = buildPlugin; plugin = buildPlugin;
break;
} }
break;
} }
} }