mirror of https://github.com/apache/maven.git
o Improved logging for forked executions
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@932966 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6ab4736f12
commit
21997b5c6b
|
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -57,4 +57,10 @@ public interface ExecutionListener
|
|||
|
||||
void forkFailed( ExecutionEvent event );
|
||||
|
||||
void forkedProjectStarted( ExecutionEvent event );
|
||||
|
||||
void forkedProjectSucceeded( ExecutionEvent event );
|
||||
|
||||
void forkedProjectFailed( ExecutionEvent event );
|
||||
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue