o Moved logging over to listener

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@804961 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-08-17 13:01:28 +00:00
parent b5cdb0dc74
commit df8c87bba7
2 changed files with 82 additions and 40 deletions

View File

@ -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<String> 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 )
{

View File

@ -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() );
}
}
}