diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java b/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java index 4b41858961..92c0ee6a94 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java @@ -313,6 +313,46 @@ public class MavenModelMerger } } + protected void mergeModelBase_PluginRepositories( ModelBase target, ModelBase source, boolean sourceDominant, + Map context ) + { + List src = source.getPluginRepositories(); + if ( !src.isEmpty() ) + { + List tgt = target.getPluginRepositories(); + Map merged = new LinkedHashMap( ( src.size() + tgt.size() ) * 2 ); + + List 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( merged.values() ) ); + } + } + /* * TODO: Whether duplicates should be removed looks like an option for the generated merger. */