mirror of https://github.com/apache/maven.git
use the correct resolved version for a dependency even if it was previously downloaded.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@168129 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
49eb3eb8f0
commit
d3c02d1760
|
@ -13,6 +13,8 @@ import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class ArtifactDownloader
|
public class ArtifactDownloader
|
||||||
{
|
{
|
||||||
|
@ -36,7 +38,7 @@ public class ArtifactDownloader
|
||||||
|
|
||||||
private static final String REPO_URL = "http://repo1.maven.org/maven2";
|
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 )
|
public ArtifactDownloader( Repository localRepository, List remoteRepositories )
|
||||||
throws Exception
|
throws Exception
|
||||||
|
@ -72,7 +74,8 @@ public class ArtifactDownloader
|
||||||
{
|
{
|
||||||
Dependency dep = (Dependency) j.next();
|
Dependency dep = (Dependency) j.next();
|
||||||
|
|
||||||
if ( !downloadedArtifacts.contains( dep ) )
|
String dependencyConflictId = dep.getDependencyConflictId();
|
||||||
|
if ( !downloadedArtifacts.containsKey( dependencyConflictId ) )
|
||||||
{
|
{
|
||||||
File destinationFile = localRepository.getArtifactFile( dep );
|
File destinationFile = localRepository.getArtifactFile( dep );
|
||||||
// The directory structure for this project may
|
// The directory structure for this project may
|
||||||
|
@ -97,7 +100,12 @@ public class ArtifactDownloader
|
||||||
throw new DownloadFailedException( "Failed to download " + dep );
|
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() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -250,6 +250,11 @@ public class Dependency
|
||||||
return getGroupId() + ":" + getArtifactId() + ":" + getType();
|
return getGroupId() + ":" + getArtifactId() + ":" + getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDependencyConflictId()
|
||||||
|
{
|
||||||
|
return getGroupId() + ":" + getArtifactId() + ":" + getType() + ":" + getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
public void setResolvedVersion( String resolvedVersion )
|
public void setResolvedVersion( String resolvedVersion )
|
||||||
{
|
{
|
||||||
this.resolvedVersion = resolvedVersion;
|
this.resolvedVersion = resolvedVersion;
|
||||||
|
|
Loading…
Reference in New Issue