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 0aa0698c2c..fdea343472 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 @@ -140,20 +140,8 @@ public class DefaultLifecycleExecutor public void execute( MavenSession session ) { - // TODO: Use a listener here instead of loggers fireEvent( session, null, LifecycleEventCatapult.SESSION_STARTED ); - - logger.info( "Build Order:" ); - - logger.info( "" ); - - for( MavenProject project : session.getProjects() ) - { - logger.info( project.getName() ); - } - - logger.info( "" ); - + MavenProject rootProject = session.getTopLevelProject(); List goals = session.getGoals(); @@ -186,16 +174,11 @@ public class DefaultLifecycleExecutor { fireEvent( session, null, LifecycleEventCatapult.PROJECT_SKIPPED ); - logger.info( "Skipping " + currentProject.getName() ); - logger.info( "This project has been banned from the build due to previous failures." ); - continue; } fireEvent( session, null, LifecycleEventCatapult.PROJECT_STARTED ); - logger.info( "Building " + currentProject.getName() ); - repositoryRequest.setRemoteRepositories( currentProject.getPluginArtifactRepositories() ); populateDefaultConfigurationForPlugins( currentProject.getBuild().getPlugins(), repositoryRequest ); @@ -299,8 +282,6 @@ public class DefaultLifecycleExecutor { fireEvent( session, mojoExecution, LifecycleEventCatapult.MOJO_SKIPPED ); - logger.warn( "Goal " + mojoDescriptor.getGoal() - + " requires online mode for execution but Maven is currently offline, skipping" ); return; } } @@ -315,11 +296,6 @@ public class DefaultLifecycleExecutor try { - if ( logger.isDebugEnabled() ) - { - logger.debug( "Forking execution for " + mojoDescriptor.getId() ); - } - executionProject = project.clone(); session.setCurrentProject( executionProject ); @@ -336,11 +312,6 @@ public class DefaultLifecycleExecutor } fireEvent( session, mojoExecution, LifecycleEventCatapult.FORK_SUCCEEDED ); - - if ( logger.isDebugEnabled() ) - { - logger.debug( "Completed forked execution for " + mojoDescriptor.getId() ); - } } catch ( MojoFailureException e ) { @@ -374,8 +345,6 @@ public class DefaultLifecycleExecutor { project.setExecutionProject( executionProject ); - logger.info( executionDescription( mojoExecution, project ) ); - pluginManager.executeMojo( session, mojoExecution ); fireEvent( session, mojoExecution, LifecycleEventCatapult.MOJO_SUCCEEDED ); @@ -805,14 +774,6 @@ public class DefaultLifecycleExecutor } } - private String executionDescription( MojoExecution me, MavenProject project ) - { - PluginDescriptor pd = me.getMojoDescriptor().getPluginDescriptor(); - StringBuilder sb = new StringBuilder( 128 ); - sb.append( "Executing " + pd.getArtifactId() + "[" + pd.getVersion() + "]: " + me.getMojoDescriptor().getGoal() + " on " + project.getArtifactId() ); - return sb.toString(); - } - private void populateMojoExecutionConfiguration( MavenProject project, MojoExecution mojoExecution, boolean allowPluginLevelConfig ) { diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/LifecycleEventLogger.java b/maven-embedder/src/main/java/org/apache/maven/cli/LifecycleEventLogger.java index 6699092be2..9e9f26ba62 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/LifecycleEventLogger.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/LifecycleEventLogger.java @@ -21,6 +21,10 @@ package org.apache.maven.cli; import org.apache.maven.embedder.MavenEmbedderLogger; import org.apache.maven.lifecycle.AbstractLifecycleListener; +import org.apache.maven.lifecycle.LifecycleEvent; +import org.apache.maven.plugin.descriptor.MojoDescriptor; +import org.apache.maven.plugin.descriptor.PluginDescriptor; +import org.apache.maven.project.MavenProject; /** * Logs lifecycle events to a user-supplied logger. @@ -45,4 +49,81 @@ class LifecycleEventLogger // TODO: log the events + @Override + public void sessionStarted( LifecycleEvent event ) + { + if ( logger.isInfoEnabled() ) + { + logger.info( "Build Order:" ); + + logger.info( "" ); + + for ( MavenProject project : event.getSession().getProjects() ) + { + logger.info( project.getName() ); + } + + logger.info( "" ); + } + } + + @Override + public void projectSkipped( LifecycleEvent event ) + { + if ( logger.isInfoEnabled() ) + { + logger.info( "Skipping " + event.getProject().getName() ); + logger.info( "This project has been banned from the build due to previous failures." ); + } + } + + @Override + public void projectStarted( LifecycleEvent event ) + { + if ( logger.isInfoEnabled() ) + { + logger.info( "Building " + event.getProject().getName() ); + } + } + + @Override + public void mojoSkipped( LifecycleEvent event ) + { + if ( logger.isWarnEnabled() ) + { + logger.warn( "Goal " + event.getMojoExecution().getMojoDescriptor().getGoal() + + " requires online mode for execution but Maven is currently offline, skipping" ); + } + } + + @Override + public void mojoStarted( LifecycleEvent event ) + { + if ( logger.isInfoEnabled() ) + { + MojoDescriptor md = event.getMojoExecution().getMojoDescriptor(); + PluginDescriptor pd = md.getPluginDescriptor(); + logger.info( "Executing " + pd.getArtifactId() + ':' + pd.getVersion() + ':' + md.getGoal() + " on " + + event.getProject().getArtifactId() ); + } + } + + @Override + public void forkStarted( LifecycleEvent event ) + { + if ( logger.isDebugEnabled() ) + { + logger.debug( "Forking execution for " + event.getMojoExecution().getMojoDescriptor().getId() ); + } + } + + @Override + public void forkSucceeded( LifecycleEvent event ) + { + if ( logger.isDebugEnabled() ) + { + logger.debug( "Completed forked execution for " + event.getMojoExecution().getMojoDescriptor().getId() ); + } + } + }