in maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java [426:521]
private List segmentTaskListByAggregationNeeds( final List tasks, final MavenSession session, final MavenProject project )
throws LifecycleExecutionException, BuildFailureException
{
List segments = new ArrayList();
if ( project != null )
{
TaskSegment currentSegment = null;
for ( Iterator it = tasks.iterator(); it.hasNext(); )
{
String task = (String) it.next();
// if it's a phase, then we don't need to check whether it's an aggregator.
// simply add it to the current task partition.
if ( getPhaseToLifecycleMap().containsKey( task ) )
{
if ( currentSegment != null && currentSegment.aggregate() )
{
segments.add( currentSegment );
currentSegment = null;
}
if ( currentSegment == null )
{
currentSegment = new TaskSegment();
}
currentSegment.add( task );
}
else
{
MojoDescriptor mojo = null;
try
{
// definitely a CLI goal, can use prefix
mojo = getMojoDescriptor( task, session, project, task, true, false );
}
catch ( PluginNotFoundException e )
{
// TODO: shouldn't hit this, investigate using the same resolution logic as otheres for plugins in the reactor
getLogger().info(
"Cannot find mojo descriptor for: \'" + task + "\' - Treating as non-aggregator." );
getLogger().debug( "", e );
}
// if the mojo descriptor was found, determine aggregator status according to:
// 1. whether the mojo declares itself an aggregator
// 2. whether the mojo DOES NOT require a project to function (implicitly avoid reactor)
if ( mojo != null && ( mojo.isAggregator() || !mojo.isProjectRequired() ) )
{
if ( currentSegment != null && !currentSegment.aggregate() )
{
segments.add( currentSegment );
currentSegment = null;
}
if ( currentSegment == null )
{
currentSegment = new TaskSegment( true );
}
currentSegment.add( task );
}
else
{
if ( currentSegment != null && currentSegment.aggregate() )
{
segments.add( currentSegment );
currentSegment = null;
}
if ( currentSegment == null )
{
currentSegment = new TaskSegment();
}
currentSegment.add( task );
}
}
}
segments.add( currentSegment );
}
else
{
TaskSegment segment = new TaskSegment( false );
for ( Iterator i = tasks.iterator(); i.hasNext(); )
{
segment.add( (String) i.next() );
}
segments.add( segment );
}
return segments;
}