diff --git a/maven-core/src/main/java/org/apache/maven/execution/AbstractExecutionListener.java b/maven-core/src/main/java/org/apache/maven/execution/AbstractExecutionListener.java index a8a50a2458..bc32acb845 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/AbstractExecutionListener.java +++ b/maven-core/src/main/java/org/apache/maven/execution/AbstractExecutionListener.java @@ -99,4 +99,19 @@ public class AbstractExecutionListener // default does nothing } + public void forkedProjectStarted( ExecutionEvent event ) + { + // default does nothing + } + + public void forkedProjectSucceeded( ExecutionEvent event ) + { + // default does nothing + } + + public void forkedProjectFailed( ExecutionEvent event ) + { + // default does nothing + } + } diff --git a/maven-core/src/main/java/org/apache/maven/execution/ExecutionListener.java b/maven-core/src/main/java/org/apache/maven/execution/ExecutionListener.java index b277feeea1..91fa945938 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/ExecutionListener.java +++ b/maven-core/src/main/java/org/apache/maven/execution/ExecutionListener.java @@ -57,4 +57,10 @@ public interface ExecutionListener void forkFailed( ExecutionEvent event ); + void forkedProjectStarted( ExecutionEvent event ); + + void forkedProjectSucceeded( ExecutionEvent event ); + + void forkedProjectFailed( ExecutionEvent event ); + } diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleEventCatapult.java b/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleEventCatapult.java index 32094f1b2c..9cff176bb7 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleEventCatapult.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleEventCatapult.java @@ -143,4 +143,28 @@ public interface LifecycleEventCatapult } }; + static final LifecycleEventCatapult FORKED_PROJECT_STARTED = new LifecycleEventCatapult() + { + public void fire( ExecutionListener listener, ExecutionEvent event ) + { + listener.forkedProjectStarted( event ); + } + }; + + static final LifecycleEventCatapult FORKED_PROJECT_SUCCEEDED = new LifecycleEventCatapult() + { + public void fire( ExecutionListener listener, ExecutionEvent event ) + { + listener.forkedProjectSucceeded( event ); + } + }; + + static final LifecycleEventCatapult FORKED_PROJECT_FAILED = new LifecycleEventCatapult() + { + public void fire( ExecutionListener listener, ExecutionEvent event ) + { + listener.forkedProjectFailed( event ); + } + }; + } diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java index 6b3f013d7e..56c8fe39e1 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java @@ -130,8 +130,6 @@ public class MojoExecutor try { pluginManager.executeMojo( session, mojoExecution ); - - DefaultLifecycleExecutor.fireEvent( session, mojoExecution, LifecycleEventCatapult.MOJO_SUCCEEDED ); } catch ( MojoFailureException e ) { @@ -230,8 +228,20 @@ public class MojoExecutor session.getProjects().set( index, executedProject ); projectIndex.getProjects().put( fork.getKey(), executedProject ); + DefaultLifecycleExecutor.fireEvent( session, mojoExecution, + LifecycleEventCatapult.FORKED_PROJECT_STARTED ); + execute( session, fork.getValue(), projectIndex, dependencyContext ); + DefaultLifecycleExecutor.fireEvent( session, mojoExecution, + LifecycleEventCatapult.FORKED_PROJECT_SUCCEEDED ); + } + catch ( LifecycleExecutionException e ) + { + DefaultLifecycleExecutor.fireEvent( session, mojoExecution, + LifecycleEventCatapult.FORKED_PROJECT_FAILED ); + + throw e; } finally { diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/ExecutionEventLogger.java b/maven-embedder/src/main/java/org/apache/maven/cli/ExecutionEventLogger.java index 817b7080ba..7cd9074264 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/ExecutionEventLogger.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/ExecutionEventLogger.java @@ -261,17 +261,11 @@ class ExecutionEventLogger { if ( logger.isInfoEnabled() ) { - MojoExecution me = event.getMojoExecution(); StringBuilder buffer = new StringBuilder( 128 ); buffer.append( "--- " ); - buffer.append( me.getArtifactId() ).append( ':' ).append( me.getVersion() ); - buffer.append( ':' ).append( me.getGoal() ); - if ( me.getExecutionId() != null ) - { - buffer.append( " (" ).append( me.getExecutionId() ).append( ')' ); - } - buffer.append( " @ " ).append( event.getProject().getArtifactId() ); + append( buffer, event.getMojoExecution() ); + append( buffer, event.getProject() ); buffer.append( " ---" ); logger.info( "" ); @@ -282,18 +276,63 @@ class ExecutionEventLogger @Override public void forkStarted( ExecutionEvent event ) { - if ( logger.isDebugEnabled() ) + if ( logger.isInfoEnabled() ) { - logger.debug( "Forking execution for " + event.getMojoExecution().getMojoDescriptor().getId() ); + StringBuilder buffer = new StringBuilder( 128 ); + + buffer.append( ">>> " ); + append( buffer, event.getMojoExecution() ); + append( buffer, event.getProject() ); + buffer.append( " >>>" ); + + logger.info( "" ); + logger.info( buffer.toString() ); } } @Override public void forkSucceeded( ExecutionEvent event ) { - if ( logger.isDebugEnabled() ) + if ( logger.isInfoEnabled() ) { - logger.debug( "Completed forked execution for " + event.getMojoExecution().getMojoDescriptor().getId() ); + StringBuilder buffer = new StringBuilder( 128 ); + + buffer.append( "<<< " ); + append( buffer, event.getMojoExecution() ); + append( buffer, event.getProject() ); + buffer.append( " <<<" ); + + logger.info( "" ); + logger.info( buffer.toString() ); + } + } + + private void append( StringBuilder buffer, MojoExecution me ) + { + buffer.append( me.getArtifactId() ).append( ':' ).append( me.getVersion() ); + buffer.append( ':' ).append( me.getGoal() ); + if ( me.getExecutionId() != null ) + { + buffer.append( " (" ).append( me.getExecutionId() ).append( ')' ); + } + } + + private void append( StringBuilder buffer, MavenProject project ) + { + buffer.append( " @ " ).append( project.getArtifactId() ); + } + + @Override + public void forkedProjectStarted( ExecutionEvent event ) + { + if ( logger.isInfoEnabled() && event.getMojoExecution().getForkedExecutions().size() > 1 ) + { + logger.info( chars( ' ', LINE_LENGTH ) ); + logger.info( chars( '>', LINE_LENGTH ) ); + + logger.info( "Forking " + event.getProject().getName() + " " + event.getProject().getVersion() ); + + logger.info( chars( '>', LINE_LENGTH ) ); } }