mirror of https://github.com/apache/maven.git
PR: MNG-479
Submitted by: Rahul Thakur Reviewed by: Brett Porter if you define a repository it should override anything in the parent with the same ID Also, cleaned up logic in assembler based on intentions git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@220240 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a4343cf767
commit
b82151f013
|
@ -66,7 +66,6 @@ public class DefaultModelInheritanceAssembler
|
||||||
}
|
}
|
||||||
|
|
||||||
// version
|
// version
|
||||||
// TODO: I think according to the latest design docs, we don't want to inherit version at all
|
|
||||||
if ( child.getVersion() == null )
|
if ( child.getVersion() == null )
|
||||||
{
|
{
|
||||||
// The parent version may have resolved to something different, so we take what we asked for...
|
// The parent version may have resolved to something different, so we take what we asked for...
|
||||||
|
@ -183,10 +182,13 @@ public class DefaultModelInheritanceAssembler
|
||||||
{
|
{
|
||||||
Repository repository = (Repository) iterator.next();
|
Repository repository = (Repository) iterator.next();
|
||||||
|
|
||||||
if ( !childRepositories.contains( repository ) )
|
// parent will always override child repositories
|
||||||
|
// if there are duplicates
|
||||||
|
if ( childRepositories.contains( repository ) )
|
||||||
{
|
{
|
||||||
child.addRepository( repository );
|
childRepositories.remove( repository );
|
||||||
}
|
}
|
||||||
|
child.addRepository( repository );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mojo Repositories :: aggregate
|
// Mojo Repositories :: aggregate
|
||||||
|
@ -395,12 +397,6 @@ public class DefaultModelInheritanceAssembler
|
||||||
|
|
||||||
private void assembleBuildInheritance( Model child, Build parentBuild )
|
private void assembleBuildInheritance( Model child, Build parentBuild )
|
||||||
{
|
{
|
||||||
// cannot inherit from null parent...
|
|
||||||
if ( parentBuild == null )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Build childBuild = child.getBuild();
|
Build childBuild = child.getBuild();
|
||||||
|
|
||||||
if ( parentBuild != null )
|
if ( parentBuild != null )
|
||||||
|
@ -451,49 +447,45 @@ public class DefaultModelInheritanceAssembler
|
||||||
private void assembleBuildBaseInheritance( BuildBase childBuild, BuildBase parentBuild )
|
private void assembleBuildBaseInheritance( BuildBase childBuild, BuildBase parentBuild )
|
||||||
{
|
{
|
||||||
// if the parent build is null, obviously we cannot inherit from it...
|
// if the parent build is null, obviously we cannot inherit from it...
|
||||||
if ( parentBuild == null )
|
if ( parentBuild != null )
|
||||||
{
|
{
|
||||||
return;
|
if ( childBuild.getDefaultGoal() == null )
|
||||||
}
|
{
|
||||||
|
childBuild.setDefaultGoal( parentBuild.getDefaultGoal() );
|
||||||
|
}
|
||||||
|
|
||||||
if ( childBuild.getDefaultGoal() == null )
|
if ( childBuild.getFinalName() == null )
|
||||||
{
|
{
|
||||||
childBuild.setDefaultGoal( parentBuild.getDefaultGoal() );
|
childBuild.setFinalName( parentBuild.getFinalName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( childBuild.getFinalName() == null )
|
List resources = childBuild.getResources();
|
||||||
{
|
if ( resources == null || resources.isEmpty() )
|
||||||
childBuild.setFinalName( parentBuild.getFinalName() );
|
{
|
||||||
}
|
childBuild.setResources( parentBuild.getResources() );
|
||||||
|
}
|
||||||
|
|
||||||
List resources = childBuild.getResources();
|
resources = childBuild.getTestResources();
|
||||||
if ( resources == null || resources.isEmpty() )
|
if ( resources == null || resources.isEmpty() )
|
||||||
{
|
{
|
||||||
childBuild.setResources( parentBuild.getResources() );
|
childBuild.setTestResources( parentBuild.getTestResources() );
|
||||||
}
|
}
|
||||||
|
|
||||||
resources = childBuild.getTestResources();
|
// Plugins are aggregated if Plugin.inherit != false
|
||||||
if ( resources == null || resources.isEmpty() )
|
ModelUtils.mergePluginLists( childBuild, parentBuild, true );
|
||||||
{
|
|
||||||
childBuild.setTestResources( parentBuild.getTestResources() );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Plugins are aggregated if Plugin.inherit != false
|
// Plugin management :: aggregate
|
||||||
ModelUtils.mergePluginLists( childBuild, parentBuild, true );
|
|
||||||
|
|
||||||
// Plugin management :: aggregate
|
|
||||||
if ( childBuild != null && parentBuild != null )
|
|
||||||
{
|
|
||||||
PluginManagement childPM = childBuild.getPluginManagement();
|
PluginManagement childPM = childBuild.getPluginManagement();
|
||||||
PluginManagement parentPM = parentBuild.getPluginManagement();
|
PluginManagement parentPM = parentBuild.getPluginManagement();
|
||||||
|
|
||||||
if( childPM == null && parentPM !=null )
|
if ( childPM == null && parentPM != null )
|
||||||
{
|
{
|
||||||
childBuild.setPluginManagement( parentPM );
|
childBuild.setPluginManagement( parentPM );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ModelUtils.mergePluginLists( childBuild.getPluginManagement(), parentBuild.getPluginManagement(), false );
|
ModelUtils.mergePluginLists( childBuild.getPluginManagement(), parentBuild.getPluginManagement(),
|
||||||
|
false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -263,7 +263,7 @@ public class DefaultModelInheritanceAssemblerTest
|
||||||
|
|
||||||
Model child = makeRepositoryModel( "child", "central", "http://repo2.maven.org/maven/" );
|
Model child = makeRepositoryModel( "child", "central", "http://repo2.maven.org/maven/" );
|
||||||
|
|
||||||
List repos = new ArrayList( child.getRepositories() );
|
List repos = new ArrayList( parent.getRepositories() );
|
||||||
|
|
||||||
assembler.assembleModelInheritance( child, parent );
|
assembler.assembleModelInheritance( child, parent );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue