[MNG-5280] Inconsistent order of repositories and pluginRepositories from profiles in settings (regression Maven 3)

Submitted by: Anders Hammar

* Applied without change

* This is the fix of the bug.

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1373761 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Connolly 2012-08-16 08:55:53 +00:00
parent 6025a22092
commit 31285e3b68
1 changed files with 40 additions and 0 deletions

View File

@ -313,6 +313,46 @@ public class MavenModelMerger
}
}
protected void mergeModelBase_PluginRepositories( ModelBase target, ModelBase source, boolean sourceDominant,
Map<Object, Object> context )
{
List<Repository> src = source.getPluginRepositories();
if ( !src.isEmpty() )
{
List<Repository> tgt = target.getPluginRepositories();
Map<Object, Repository> merged = new LinkedHashMap<Object, Repository>( ( src.size() + tgt.size() ) * 2 );
List<Repository> dominant, recessive;
if ( sourceDominant )
{
dominant = src;
recessive = tgt;
}
else
{
dominant = tgt;
recessive = src;
}
for ( Repository element : dominant )
{
Object key = getRepositoryKey( element );
merged.put( key, element );
}
for ( Repository element : recessive )
{
Object key = getRepositoryKey( element );
if ( !merged.containsKey( key ) )
{
merged.put( key, element );
}
}
target.setPluginRepositories( new ArrayList<Repository>( merged.values() ) );
}
}
/*
* TODO: Whether duplicates should be removed looks like an option for the generated merger.
*/