mirror of https://github.com/apache/maven.git
Resolving: MNG-709...scrubbing caller from forked lifecycle, and letting it run in the main lifecycle after the fork returns.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@233259 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9bd6219732
commit
fcc893a626
|
@ -479,10 +479,10 @@ public class DefaultLifecycleExecutor
|
||||||
private void forkLifecycle( MojoDescriptor mojoDescriptor, MavenSession session, MavenProject project )
|
private void forkLifecycle( MojoDescriptor mojoDescriptor, MavenSession session, MavenProject project )
|
||||||
throws LifecycleExecutionException, MojoExecutionException, ArtifactResolutionException
|
throws LifecycleExecutionException, MojoExecutionException, ArtifactResolutionException
|
||||||
{
|
{
|
||||||
String task = mojoDescriptor.getExecutePhase();
|
String targetPhase = mojoDescriptor.getExecutePhase();
|
||||||
|
|
||||||
// Create new lifecycle
|
// Create new lifecycle
|
||||||
Map lifecycleMappings = constructLifecycleMappings( session, task, project );
|
Map lifecycleMappings = constructLifecycleMappings( session, targetPhase, project );
|
||||||
|
|
||||||
String executeLifecycle = mojoDescriptor.getExecuteLifecycle();
|
String executeLifecycle = mojoDescriptor.getExecuteLifecycle();
|
||||||
if ( executeLifecycle != null )
|
if ( executeLifecycle != null )
|
||||||
|
@ -525,25 +525,15 @@ public class DefaultLifecycleExecutor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String mojoPhase = findFirstPhaseBindingForMojo( mojoDescriptor, lifecycleMappings );
|
removeFromLifecycle( mojoDescriptor, lifecycleMappings );
|
||||||
|
|
||||||
int mojoPhaseIdx = phases.indexOf( mojoPhase );
|
|
||||||
int execPhaseIdx = phases.indexOf( task );
|
|
||||||
|
|
||||||
if ( mojoPhaseIdx > -1 && mojoPhaseIdx <= execPhaseIdx )
|
|
||||||
{
|
|
||||||
throw new LifecycleExecutionException( "Infinite loop detected in build process. Mojo: \'"
|
|
||||||
+ mojoDescriptor.getGoal() + "\' declares executePhase of: \'" + task
|
|
||||||
+ "\' but is itself bound to phase: \'" + mojoPhase
|
|
||||||
+ "\'. This will result in infinite forking of build execution." );
|
|
||||||
}
|
|
||||||
|
|
||||||
MavenProject executionProject = new MavenProject( project );
|
MavenProject executionProject = new MavenProject( project );
|
||||||
executeGoalWithLifecycle( task, session, lifecycleMappings, executionProject );
|
executeGoalWithLifecycle( targetPhase, session, lifecycleMappings, executionProject );
|
||||||
project.setExecutionProject( executionProject );
|
project.setExecutionProject( executionProject );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String findFirstPhaseBindingForMojo( MojoDescriptor mojoDescriptor, Map lifecycleMappings )
|
private void removeFromLifecycle( MojoDescriptor mojoDescriptor, Map lifecycleMappings )
|
||||||
{
|
{
|
||||||
PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
|
PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
|
||||||
|
|
||||||
|
@ -553,22 +543,15 @@ public class DefaultLifecycleExecutor
|
||||||
String mojoIdWithoutVersion = pluginDescriptor.getGroupId() + ":" + pluginDescriptor.getArtifactId() + ":"
|
String mojoIdWithoutVersion = pluginDescriptor.getGroupId() + ":" + pluginDescriptor.getArtifactId() + ":"
|
||||||
+ mojoDescriptor.getGoal();
|
+ mojoDescriptor.getGoal();
|
||||||
|
|
||||||
for ( Iterator it = lifecycleMappings.entrySet().iterator(); it.hasNext(); )
|
for ( Iterator it = lifecycleMappings.values().iterator(); it.hasNext(); )
|
||||||
{
|
{
|
||||||
Map.Entry entry = (Map.Entry) it.next();
|
List tasks = (List) it.next();
|
||||||
|
|
||||||
String phase = (String) entry.getKey();
|
tasks.remove( mojoIdWithVersion );
|
||||||
List tasks = (List) entry.getValue();
|
tasks.remove( mojoIdWithoutVersion );
|
||||||
|
|
||||||
if ( tasks.contains( mojoIdWithVersion ) || tasks.contains( mojoIdWithoutVersion ) )
|
|
||||||
{
|
|
||||||
return phase;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map constructLifecycleMappings( MavenSession session, String selectedPhase, MavenProject project )
|
private Map constructLifecycleMappings( MavenSession session, String selectedPhase, MavenProject project )
|
||||||
throws ArtifactResolutionException, LifecycleExecutionException
|
throws ArtifactResolutionException, LifecycleExecutionException
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue