in maven-project/src/main/java/org/apache/maven/project/injection/DefaultProfileInjector.java [198:295]
private void injectPluginDefinition( Plugin profilePlugin, Plugin modelPlugin )
{
if ( ( profilePlugin == null ) || ( modelPlugin == null ) )
{
// nothing to do.
return;
}
if ( profilePlugin.isExtensions() )
{
modelPlugin.setExtensions( true );
}
if ( profilePlugin.getVersion() != null )
{
modelPlugin.setVersion( profilePlugin.getVersion() );
}
modelPlugin.setDependencies( injectDependencies( profilePlugin.getDependencies(), modelPlugin.getDependencies() ) );
// merge the lists of goals that are not attached to an <execution/>
injectConfigurationContainer( profilePlugin, modelPlugin );
// from here to the end of the method is dealing with merging of the <executions/> section.
List modelExecutions = modelPlugin.getExecutions();
if ( ( modelExecutions == null ) || modelExecutions.isEmpty() )
{
modelPlugin.setExecutions( profilePlugin.getExecutions() );
}
else
{
Map executions = new LinkedHashMap();
Map profileExecutions = profilePlugin.getExecutionsAsMap();
for ( Iterator it = modelExecutions.iterator(); it.hasNext(); )
{
PluginExecution modelExecution = (PluginExecution) it.next();
PluginExecution profileExecution = (PluginExecution) profileExecutions.get( modelExecution.getId() );
if ( profileExecution != null )
{
injectConfigurationContainer( profileExecution, modelExecution );
if ( profileExecution.getPhase() != null )
{
modelExecution.setPhase( profileExecution.getPhase() );
}
List profileGoals = profileExecution.getGoals();
List modelGoals = modelExecution.getGoals();
List goals = new ArrayList();
if ( ( modelGoals != null ) && !modelGoals.isEmpty() )
{
goals.addAll( modelGoals );
}
if ( profileGoals != null )
{
for ( Iterator goalIterator = profileGoals.iterator(); goalIterator.hasNext(); )
{
String goal = (String) goalIterator.next();
if ( !goals.contains( goal ) )
{
goals.add( goal );
}
}
}
modelExecution.setGoals( goals );
}
executions.put( modelExecution.getId(), modelExecution );
}
for ( Iterator it = profileExecutions.entrySet().iterator(); it.hasNext(); )
{
Map.Entry entry = (Map.Entry) it.next();
String id = (String) entry.getKey();
if ( !executions.containsKey( id ) )
{
executions.put( id, entry.getValue() );
}
}
modelPlugin.setExecutions( new ArrayList( executions.values() ) );
modelPlugin.flushExecutionMap();
}
}