diff --git a/maven-mboot2/src/main/java/download/ArtifactDownloader.java b/maven-mboot2/src/main/java/download/ArtifactDownloader.java index 85f62687a6..6d555084b1 100644 --- a/maven-mboot2/src/main/java/download/ArtifactDownloader.java +++ b/maven-mboot2/src/main/java/download/ArtifactDownloader.java @@ -13,6 +13,8 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; +import java.util.HashMap; +import java.util.Map; public class ArtifactDownloader { @@ -36,7 +38,7 @@ public class ArtifactDownloader private static final String REPO_URL = "http://repo1.maven.org/maven2"; - private Set downloadedArtifacts = new HashSet(); + private Map downloadedArtifacts = new HashMap(); public ArtifactDownloader( Repository localRepository, List remoteRepositories ) throws Exception @@ -72,7 +74,8 @@ public class ArtifactDownloader { Dependency dep = (Dependency) j.next(); - if ( !downloadedArtifacts.contains( dep ) ) + String dependencyConflictId = dep.getDependencyConflictId(); + if ( !downloadedArtifacts.containsKey( dependencyConflictId ) ) { File destinationFile = localRepository.getArtifactFile( dep ); // The directory structure for this project may @@ -97,7 +100,12 @@ public class ArtifactDownloader throw new DownloadFailedException( "Failed to download " + dep ); } - downloadedArtifacts.add( dep ); + downloadedArtifacts.put( dependencyConflictId, dep ); + } + else + { + Dependency d = (Dependency) downloadedArtifacts.get( dependencyConflictId ); + dep.setResolvedVersion( d.getResolvedVersion() ); } } } diff --git a/maven-mboot2/src/main/java/model/Dependency.java b/maven-mboot2/src/main/java/model/Dependency.java index a2d6230b1f..c7a8c64230 100644 --- a/maven-mboot2/src/main/java/model/Dependency.java +++ b/maven-mboot2/src/main/java/model/Dependency.java @@ -250,6 +250,11 @@ public class Dependency return getGroupId() + ":" + getArtifactId() + ":" + getType(); } + public String getDependencyConflictId() + { + return getGroupId() + ":" + getArtifactId() + ":" + getType() + ":" + getVersion(); + } + public void setResolvedVersion( String resolvedVersion ) { this.resolvedVersion = resolvedVersion;