private void executeGoals( final List goals, final Stack forkEntryPoints, final MavenSession session, final MavenProject project )
throws LifecycleExecutionException, BuildFailureException, PluginNotFoundException
{
for ( Iterator i = goals.iterator(); i.hasNext(); )
{
MojoExecution mojoExecution = (MojoExecution) i.next();
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
PlexusConfiguration configuration = mojoDescriptor.getMojoConfiguration();
boolean usesReactorProjects = mojoDescriptor.isAggregator() || usesSessionOrReactorProjects( configuration );
if ( usesReactorProjects )
{
calculateAllConcreteStates( session );
}
else
{
calculateConcreteState( project, session, true );
}
calculateConcreteConfiguration( mojoExecution, project, session );
List reportExecutions = null;
if ( mojoDescriptor.isRequiresReports() )
{
reportExecutions = getReportExecutions( project, forkEntryPoints, mojoExecution, session );
}
boolean hasFork = false;
if ( mojoDescriptor.getExecutePhase() != null || mojoDescriptor.getExecuteGoal() != null )
{
hasFork = true;
}
else if ( reportExecutions != null )
{
for ( Iterator it = reportExecutions.iterator(); it.hasNext(); )
{
MojoExecution reportExecution = (MojoExecution) it.next();
MojoDescriptor reportDescriptor = reportExecution.getMojoDescriptor();
if ( reportDescriptor.getExecutePhase() != null || reportDescriptor.getExecuteGoal() != null )
{
hasFork = true;
}
}
}
if ( hasFork )
{
// NOTE: This must always happen, regardless of treatment of reactorProjects below, because
// if we're in a forked execution right now, the current project will itself be an execution project of
// something in the reactorProjects list, and won't have a next-stage executionProject created
// for it otherwise, which leaves the project == null for the upcoming forked execution.
createExecutionProject( project, session, true );
if ( usesReactorProjects )
{
List reactorProjects = session.getSortedProjects();
for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
{
MavenProject reactorProject = (MavenProject) it.next();
createExecutionProject( reactorProject, session, false );
}
}
}
if ( mojoDescriptor.getExecutePhase() != null || mojoDescriptor.getExecuteGoal() != null )
{
forkEntryPoints.push( mojoDescriptor );
forkLifecycle( mojoDescriptor, forkEntryPoints, session, project, mojoExecution.getExecutionId() );
forkEntryPoints.pop();
}
if ( mojoDescriptor.isRequiresReports() )
{
List reports = getReports( reportExecutions, project, mojoExecution, session );
mojoExecution.setReports( reports );
for ( Iterator j = mojoExecution.getForkedExecutions().iterator(); j.hasNext(); )
{
MojoExecution forkedExecution = (MojoExecution) j.next();
MojoDescriptor descriptor = forkedExecution.getMojoDescriptor();
if ( descriptor.getExecutePhase() != null )
{
forkEntryPoints.push( descriptor );
forkLifecycle( descriptor, forkEntryPoints, session, project, forkedExecution.getExecutionId() );
forkEntryPoints.pop();
}
}
}