mirror of https://github.com/apache/maven.git
o Fixed resolution of transitive dependencies
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@813805 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0553695bcb
commit
552a920fb0
|
@ -59,10 +59,10 @@ public class ArtifactResolutionResult
|
||||||
|
|
||||||
private List<ArtifactRepository> repositories;
|
private List<ArtifactRepository> repositories;
|
||||||
|
|
||||||
private Set<Artifact> requestedArtifacts;
|
|
||||||
|
|
||||||
private Set<Artifact> artifacts;
|
private Set<Artifact> artifacts;
|
||||||
|
|
||||||
|
private Set<ResolutionNode> resolutionNodes;
|
||||||
|
|
||||||
public Artifact getOriginatingArtifact()
|
public Artifact getOriginatingArtifact()
|
||||||
{
|
{
|
||||||
return originatingArtifact;
|
return originatingArtifact;
|
||||||
|
@ -100,19 +100,19 @@ public class ArtifactResolutionResult
|
||||||
this.artifacts = artifacts;
|
this.artifacts = artifacts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRequestedArtifact( Artifact artifact )
|
public Set<ResolutionNode> getResolutionNodes()
|
||||||
{
|
{
|
||||||
if ( requestedArtifacts == null )
|
if ( resolutionNodes == null )
|
||||||
{
|
{
|
||||||
requestedArtifacts = new LinkedHashSet<Artifact>();
|
resolutionNodes = new LinkedHashSet<ResolutionNode>();
|
||||||
}
|
}
|
||||||
|
|
||||||
requestedArtifacts.add( artifact );
|
return resolutionNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Artifact> getRequestedArtifacts()
|
public void setResolutionNodes( Set<ResolutionNode> resolutionNodes )
|
||||||
{
|
{
|
||||||
return requestedArtifacts;
|
this.resolutionNodes = resolutionNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasMissingArtifacts()
|
public boolean hasMissingArtifacts()
|
||||||
|
|
|
@ -493,15 +493,21 @@ public class DefaultArtifactResolver
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( result.getArtifacts() != null )
|
if ( result.getResolutionNodes() != null )
|
||||||
{
|
{
|
||||||
for ( Artifact artifact : result.getArtifacts() )
|
ArtifactResolutionRequest childRequest = new ArtifactResolutionRequest( request );
|
||||||
|
|
||||||
|
for ( ResolutionNode node : result.getResolutionNodes() )
|
||||||
{
|
{
|
||||||
|
Artifact artifact = node.getArtifact();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if ( resolutionFilter == null || resolutionFilter.include( artifact ) )
|
if ( resolutionFilter == null || resolutionFilter.include( artifact ) )
|
||||||
{
|
{
|
||||||
resolve( artifact, request, request.getTransferListener(), false );
|
childRequest.setRemoteRepositories( node.getRemoteRepositories() );
|
||||||
|
|
||||||
|
resolve( artifact, childRequest, request.getTransferListener(), false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( ArtifactNotFoundException anfe )
|
catch ( ArtifactNotFoundException anfe )
|
||||||
|
|
|
@ -170,7 +170,6 @@ public class DefaultLegacyArtifactCollector
|
||||||
|
|
||||||
// This is required right now.
|
// This is required right now.
|
||||||
result.addArtifact( artifact );
|
result.addArtifact( artifact );
|
||||||
result.addRequestedArtifact( artifact );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,6 +181,8 @@ public class DefaultLegacyArtifactCollector
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result.setResolutionNodes( set );
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -137,6 +138,8 @@ public class MavenMetadataSource
|
||||||
|
|
||||||
List<Dependency> managedDependencies = null;
|
List<Dependency> managedDependencies = null;
|
||||||
|
|
||||||
|
List<ArtifactRepository> pomRepositories = null;
|
||||||
|
|
||||||
Artifact pomArtifact;
|
Artifact pomArtifact;
|
||||||
|
|
||||||
Artifact relocatedArtifact = null;
|
Artifact relocatedArtifact = null;
|
||||||
|
@ -177,6 +180,8 @@ public class MavenMetadataSource
|
||||||
|
|
||||||
DependencyManagement depMngt = rel.project.getDependencyManagement();
|
DependencyManagement depMngt = rel.project.getDependencyManagement();
|
||||||
managedDependencies = ( depMngt != null ) ? depMngt.getDependencies() : null;
|
managedDependencies = ( depMngt != null ) ? depMngt.getDependencies() : null;
|
||||||
|
|
||||||
|
pomRepositories = rel.project.getRemoteArtifactRepositories();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,8 +216,11 @@ public class MavenMetadataSource
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<ArtifactRepository> aggregatedRepositories =
|
||||||
|
aggregateRepositories( request.getRemoteRepositories(), pomRepositories );
|
||||||
|
|
||||||
ResolutionGroup result =
|
ResolutionGroup result =
|
||||||
new ResolutionGroup( pomArtifact, relocatedArtifact, artifacts, managedVersions, request.getRemoteRepositories() );
|
new ResolutionGroup( pomArtifact, relocatedArtifact, artifacts, managedVersions, aggregatedRepositories );
|
||||||
|
|
||||||
cache.put( artifact, request.isResolveManagedVersions(), request.getLocalRepository(),
|
cache.put( artifact, request.isResolveManagedVersions(), request.getLocalRepository(),
|
||||||
request.getRemoteRepositories(), result );
|
request.getRemoteRepositories(), result );
|
||||||
|
@ -220,6 +228,37 @@ public class MavenMetadataSource
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<ArtifactRepository> aggregateRepositories( List<ArtifactRepository> requestRepositories,
|
||||||
|
List<ArtifactRepository> pomRepositories )
|
||||||
|
{
|
||||||
|
List<ArtifactRepository> repositories = requestRepositories;
|
||||||
|
|
||||||
|
if ( pomRepositories != null && !pomRepositories.isEmpty() )
|
||||||
|
{
|
||||||
|
Map<String, ArtifactRepository> repos = new LinkedHashMap<String, ArtifactRepository>();
|
||||||
|
|
||||||
|
for ( ArtifactRepository repo : requestRepositories )
|
||||||
|
{
|
||||||
|
if ( !repos.containsKey( repo.getId() ) )
|
||||||
|
{
|
||||||
|
repos.put( repo.getId(), repo );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( ArtifactRepository repo : pomRepositories )
|
||||||
|
{
|
||||||
|
if ( !repos.containsKey( repo.getId() ) )
|
||||||
|
{
|
||||||
|
repos.put( repo.getId(), repo );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories = new ArrayList<ArtifactRepository>( repos.values() );
|
||||||
|
}
|
||||||
|
|
||||||
|
return repositories;
|
||||||
|
}
|
||||||
|
|
||||||
private Artifact createDependencyArtifact( Dependency dependency, Artifact owner, Artifact pom )
|
private Artifact createDependencyArtifact( Dependency dependency, Artifact owner, Artifact pom )
|
||||||
throws ArtifactMetadataRetrievalException
|
throws ArtifactMetadataRetrievalException
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue