mirror of https://github.com/apache/maven.git
Resolving: MNG-757 according to the comments in the issue.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@239243 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cd48181144
commit
5d0298a942
|
@ -58,6 +58,9 @@ public class MavenMetadataSource
|
|||
|
||||
private ArtifactFactory artifactFactory;
|
||||
|
||||
// lazily instantiated and cached.
|
||||
private MavenProject superProject;
|
||||
|
||||
/**
|
||||
* Retrieve the metadata for the project from the repository.
|
||||
* Uses the ProjectBuilder, to enable post-processing and inheritance calculation before retrieving the
|
||||
|
@ -134,12 +137,65 @@ public class MavenMetadataSource
|
|||
Set artifacts = project.createArtifacts( artifactFactory, artifact.getScope(),
|
||||
artifact.getDependencyFilter() );
|
||||
|
||||
return new ResolutionGroup( pomArtifact, artifacts, project.getRemoteArtifactRepositories() );
|
||||
|
||||
List repositories = aggregateRepositoryLists( remoteRepositories, project.getRemoteArtifactRepositories() );
|
||||
|
||||
return new ResolutionGroup( pomArtifact, artifacts, repositories );
|
||||
}
|
||||
catch ( InvalidVersionSpecificationException e )
|
||||
{
|
||||
throw new ArtifactMetadataRetrievalException( "Unable to read the metadata file", e );
|
||||
}
|
||||
catch ( ProjectBuildingException e )
|
||||
{
|
||||
throw new ArtifactMetadataRetrievalException( "Unable to read the metadata file", e );
|
||||
}
|
||||
}
|
||||
|
||||
private List aggregateRepositoryLists( List remoteRepositories, List remoteArtifactRepositories )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
if ( superProject == null )
|
||||
{
|
||||
superProject = mavenProjectBuilder.buildStandaloneSuperProject( null );
|
||||
}
|
||||
|
||||
List repositories = new ArrayList();
|
||||
|
||||
repositories.addAll( remoteRepositories );
|
||||
|
||||
// ensure that these are defined
|
||||
for ( Iterator it = superProject.getRemoteArtifactRepositories().iterator(); it.hasNext(); )
|
||||
{
|
||||
ArtifactRepository superRepo = (ArtifactRepository) it.next();
|
||||
|
||||
for ( Iterator aggregatedIterator = repositories.iterator(); aggregatedIterator.hasNext(); )
|
||||
{
|
||||
ArtifactRepository repo = (ArtifactRepository) aggregatedIterator.next();
|
||||
|
||||
// if the repository exists in the list and was introduced by another POM's super-pom,
|
||||
// remove it...the repository definitions from the super-POM should only be at the end of
|
||||
// the list.
|
||||
// if the repository has been redefined, leave it.
|
||||
if ( repo.getId().equals( superRepo.getId() ) && repo.getUrl().equals( superRepo.getUrl() ) )
|
||||
{
|
||||
aggregatedIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// this list should contain the super-POM repositories, so we don't have to explicitly add them back.
|
||||
for ( Iterator it = remoteArtifactRepositories.iterator(); it.hasNext(); )
|
||||
{
|
||||
ArtifactRepository repository = (ArtifactRepository) it.next();
|
||||
|
||||
if ( !repositories.contains( repository ) )
|
||||
{
|
||||
repositories.add( repository );
|
||||
}
|
||||
}
|
||||
|
||||
return repositories;
|
||||
}
|
||||
|
||||
public static Set createArtifacts( ArtifactFactory artifactFactory, List dependencies, String inheritedScope,
|
||||
|
|
Loading…
Reference in New Issue