PR: MNG-881

ensure resources are merged if empty.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@290053 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-09-19 03:24:28 +00:00
parent 96b7fe6353
commit 33dfc5fb1c
1 changed files with 23 additions and 23 deletions

View File

@ -28,17 +28,17 @@ import java.util.Properties;
import java.util.TreeMap; import java.util.TreeMap;
/** /**
* Inject profile data into a Model, using the profile as the dominant data source, and * Inject profile data into a Model, using the profile as the dominant data source, and
* persisting results of the injection in the Model. * persisting results of the injection in the Model.
* *
* This will look similar to the ModelUtils/DefaultModelInheritanceAssembler code, but * This will look similar to the ModelUtils/DefaultModelInheritanceAssembler code, but
* they are distinct. In model inheritance, the child provides data dominance AND persists * they are distinct. In model inheritance, the child provides data dominance AND persists
* the results of the merge...sort of a 'merge-out' system. * the results of the merge...sort of a 'merge-out' system.
* *
* In this system, the profile is dominant, but the model receives the merge result...sort * In this system, the profile is dominant, but the model receives the merge result...sort
* of a 'merge-in' system. The two pieces of code look like they could be combined with a * of a 'merge-in' system. The two pieces of code look like they could be combined with a
* set of flags to determine which direction to merge 'to', but there are enough differences * set of flags to determine which direction to merge 'to', but there are enough differences
* in the code to justify the extra code involved with separating them, in order to simplify * in the code to justify the extra code involved with separating them, in order to simplify
* the logic. * the logic.
*/ */
public class DefaultProfileInjector public class DefaultProfileInjector
@ -60,13 +60,13 @@ public class DefaultProfileInjector
injectDependencyManagement( profile, model ); injectDependencyManagement( profile, model );
injectDistributionManagement( profile, model ); injectDistributionManagement( profile, model );
injectBuild( profile, model ); injectBuild( profile, model );
Properties props = new Properties(); Properties props = new Properties();
props.putAll( model.getProperties() ); props.putAll( model.getProperties() );
props.putAll( profile.getProperties() ); props.putAll( profile.getProperties() );
model.setProperties( props ); model.setProperties( props );
} }
@ -74,7 +74,7 @@ public class DefaultProfileInjector
{ {
BuildBase profileBuild = profile.getBuild(); BuildBase profileBuild = profile.getBuild();
Build modelBuild = model.getBuild(); Build modelBuild = model.getBuild();
// 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 ( profileBuild != null ) if ( profileBuild != null )
{ {
@ -83,7 +83,7 @@ public class DefaultProfileInjector
modelBuild = new Build(); modelBuild = new Build();
model.setBuild( modelBuild ); model.setBuild( modelBuild );
} }
if ( profileBuild.getDirectory() != null ) if ( profileBuild.getDirectory() != null )
{ {
modelBuild.setDirectory( profileBuild.getDirectory() ); modelBuild.setDirectory( profileBuild.getDirectory() );
@ -100,19 +100,19 @@ public class DefaultProfileInjector
} }
List profileResources = profileBuild.getResources(); List profileResources = profileBuild.getResources();
if ( profileResources != null && !profileResources.isEmpty() ) if ( profileResources != null && !profileResources.isEmpty() )
{ {
modelBuild.setResources( profileResources ); modelBuild.setResources( profileResources );
} }
List profileTestResources = profileBuild.getTestResources(); List profileTestResources = profileBuild.getTestResources();
if ( profileTestResources != null ) if ( profileTestResources != null && !profileTestResources.isEmpty() )
{ {
modelBuild.setTestResources( profileTestResources ); modelBuild.setTestResources( profileTestResources );
} }
injectPlugins( profileBuild, modelBuild ); injectPlugins( profileBuild, modelBuild );
// Plugin management :: aggregate // Plugin management :: aggregate
@ -133,7 +133,7 @@ public class DefaultProfileInjector
private void injectPlugins( PluginContainer profileContainer, PluginContainer modelContainer ) private void injectPlugins( PluginContainer profileContainer, PluginContainer modelContainer )
{ {
List modelPlugins = modelContainer.getPlugins(); List modelPlugins = modelContainer.getPlugins();
if ( modelPlugins == null ) if ( modelPlugins == null )
{ {
modelContainer.setPlugins( profileContainer.getPlugins() ); modelContainer.setPlugins( profileContainer.getPlugins() );
@ -221,35 +221,35 @@ public class DefaultProfileInjector
if ( profileExecution != null ) if ( profileExecution != null )
{ {
injectConfigurationContainer( profileExecution, modelExecution ); injectConfigurationContainer( profileExecution, modelExecution );
if ( profileExecution.getPhase() != null ) if ( profileExecution.getPhase() != null )
{ {
modelExecution.setPhase( profileExecution.getPhase() ); modelExecution.setPhase( profileExecution.getPhase() );
} }
List profileGoals = profileExecution.getGoals(); List profileGoals = profileExecution.getGoals();
List modelGoals = modelExecution.getGoals(); List modelGoals = modelExecution.getGoals();
List goals = new ArrayList(); List goals = new ArrayList();
if ( modelGoals != null && !modelGoals.isEmpty() ) if ( modelGoals != null && !modelGoals.isEmpty() )
{ {
goals.addAll( modelGoals ); goals.addAll( modelGoals );
} }
if ( profileGoals != null ) if ( profileGoals != null )
{ {
for ( Iterator goalIterator = profileGoals.iterator(); goalIterator.hasNext(); ) for ( Iterator goalIterator = profileGoals.iterator(); goalIterator.hasNext(); )
{ {
String goal = (String) goalIterator.next(); String goal = (String) goalIterator.next();
if ( !goals.contains( goal ) ) if ( !goals.contains( goal ) )
{ {
goals.add( goal ); goals.add( goal );
} }
} }
} }
modelExecution.setGoals( goals ); modelExecution.setGoals( goals );
} }
@ -276,7 +276,7 @@ public class DefaultProfileInjector
} }
private void injectConfigurationContainer( ConfigurationContainer profileContainer, private void injectConfigurationContainer( ConfigurationContainer profileContainer,
ConfigurationContainer modelContainer ) ConfigurationContainer modelContainer )
{ {
Xpp3Dom configuration = (Xpp3Dom) profileContainer.getConfiguration(); Xpp3Dom configuration = (Xpp3Dom) profileContainer.getConfiguration();
Xpp3Dom parentConfiguration = (Xpp3Dom) modelContainer.getConfiguration(); Xpp3Dom parentConfiguration = (Xpp3Dom) modelContainer.getConfiguration();