{
project = project.getExecutionProject();
forkEntryPoints.push( mojoDescriptor );
PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
String targetPhase = mojoDescriptor.getExecutePhase();
Map lifecycleMappings = null;
if ( targetPhase != null )
{
Lifecycle lifecycle = getLifecycleForPhase( targetPhase );
// Create new lifecycle
lifecycleMappings = constructLifecycleMappings( session, targetPhase, project, lifecycle );
String executeLifecycle = mojoDescriptor.getExecuteLifecycle();
if ( executeLifecycle != null )
{
org.apache.maven.plugin.lifecycle.Lifecycle lifecycleOverlay;
try
{
lifecycleOverlay = pluginDescriptor.getLifecycleMapping( executeLifecycle );
}
catch ( IOException e )
{
throw new LifecycleExecutionException( "Unable to read lifecycle mapping file: " + e.getMessage(),
e );
}
catch ( XmlPullParserException e )
{
throw new LifecycleExecutionException( "Unable to parse lifecycle mapping file: " + e.getMessage(),
e );
}
if ( lifecycleOverlay == null )
{
throw new LifecycleExecutionException( "Lifecycle '" + executeLifecycle + "' not found in plugin" );
}
for ( Iterator i = lifecycleOverlay.getPhases().iterator(); i.hasNext(); )
{
Phase phase = (Phase) i.next();
for ( Iterator j = phase.getExecutions().iterator(); j.hasNext(); )
{
Execution exec = (Execution) j.next();
for ( Iterator k = exec.getGoals().iterator(); k.hasNext(); )
{
String goal = (String) k.next();
PluginDescriptor lifecyclePluginDescriptor;
String lifecycleGoal;
// Here we are looking to see if we have a mojo from an external plugin.
// If we do then we need to lookup the plugin descriptor for the externally
// referenced plugin so that we can overly the execution into the lifecycle.