diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java index 37878c5961..54e64079c4 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java @@ -984,6 +984,8 @@ public class DefaultLifecycleExecutor mojoExecution.addForkedExecutions( getKey( forkedProject ), forkedExecutions ); } + + alreadyForkedExecutions.remove( mojoDescriptor ); } private List calculateForkedGoal( MojoExecution mojoExecution, MavenSession session, @@ -1005,6 +1007,11 @@ public class DefaultLifecycleExecutor throw new MojoNotFoundException( forkedGoal, pluginDescriptor ); } + if ( alreadyForkedExecutions.contains( forkedMojoDescriptor ) ) + { + return Collections.emptyList(); + } + MojoExecution forkedExecution = new MojoExecution( forkedMojoDescriptor, forkedGoal ); populateMojoExecutionConfiguration( project, forkedExecution, true ); @@ -1052,13 +1059,18 @@ public class DefaultLifecycleExecutor for ( List forkedExecutions : lifecycleMappings.values() ) { - for ( MojoExecution forkedExecution : forkedExecutions ) + for ( Iterator it = forkedExecutions.iterator(); it.hasNext(); ) { - extractMojoConfiguration( forkedExecution ); + MojoExecution forkedExecution = it.next(); - calculateForkedExecutions( forkedExecution, session, project, alreadyForkedExecutions ); + if ( !alreadyForkedExecutions.contains( forkedExecution.getMojoDescriptor() ) ) + { + extractMojoConfiguration( forkedExecution ); - mojoExecutions.add( forkedExecution ); + calculateForkedExecutions( forkedExecution, session, project, alreadyForkedExecutions ); + + mojoExecutions.add( forkedExecution ); + } } }