{
public void executeTask( DependencyGraph graph )
{
Iterator it;
DependencyGraphWalker walker = new WalkDepthFirstSearch();
RefineConflictsVisitor refineConflictsVisitor = new RefineConflictsVisitor();
MultiValueMap depMap = new MultiValueMap();
// Identify deps that need to be resolved.
it = graph.getNodes().iterator();
while ( it.hasNext() )
{
DependencyGraphNode node = (DependencyGraphNode) it.next();
String key = DependencyGraphKeys.toManagementKey( node.getArtifact() );
// This will add this node to the specified key, not replace a previous one.
depMap.put( key, node );
}
// Process those depMap entries with more than 1 value.
ToArtifactReferenceTransformer nodeToArtifact = new ToArtifactReferenceTransformer();
it = depMap.entrySet().iterator();
while ( it.hasNext() )
{
Map.Entry entry = (Entry) it.next();
Collection nodes = (Collection) entry.getValue();
if ( nodes.size() > 1 )
{
List conflictingArtifacts = new ArrayList();
conflictingArtifacts.addAll( nodes );
CollectionUtils.transform( conflictingArtifacts, nodeToArtifact );
refineConflictsVisitor.resetConflictingArtifacts();
refineConflictsVisitor.addAllConflictingArtifacts( conflictingArtifacts );
walker.visit( graph, refineConflictsVisitor );
}
}
}