[MNG-5630] improved display of forked executions: added phase or goal

This commit is contained in:
Hervé Boutemy 2014-05-10 20:53:56 +02:00
parent b527490517
commit 2cea7c6f84
1 changed files with 27 additions and 0 deletions

View File

@ -21,6 +21,7 @@ package org.apache.maven.cli.event;
import static org.apache.maven.cli.CLIReportingUtils.formatDuration; import static org.apache.maven.cli.CLIReportingUtils.formatDuration;
import static org.apache.maven.cli.CLIReportingUtils.formatTimestamp; import static org.apache.maven.cli.CLIReportingUtils.formatTimestamp;
import org.apache.maven.execution.AbstractExecutionListener; import org.apache.maven.execution.AbstractExecutionListener;
import org.apache.maven.execution.BuildFailure; import org.apache.maven.execution.BuildFailure;
import org.apache.maven.execution.BuildSuccess; import org.apache.maven.execution.BuildSuccess;
@ -29,7 +30,9 @@ import org.apache.maven.execution.ExecutionEvent;
import org.apache.maven.execution.MavenExecutionResult; import org.apache.maven.execution.MavenExecutionResult;
import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -289,6 +292,8 @@ public class ExecutionEventLogger
buffer.append( ">>> " ); buffer.append( ">>> " );
append( buffer, event.getMojoExecution() ); append( buffer, event.getMojoExecution() );
buffer.append( " > " );
appendForkInfo( buffer, event.getMojoExecution().getMojoDescriptor() );
append( buffer, event.getProject() ); append( buffer, event.getProject() );
buffer.append( " >>>" ); buffer.append( " >>>" );
@ -309,6 +314,8 @@ public class ExecutionEventLogger
buffer.append( "<<< " ); buffer.append( "<<< " );
append( buffer, event.getMojoExecution() ); append( buffer, event.getMojoExecution() );
buffer.append( " < " );
appendForkInfo( buffer, event.getMojoExecution().getMojoDescriptor() );
append( buffer, event.getProject() ); append( buffer, event.getProject() );
buffer.append( " <<<" ); buffer.append( " <<<" );
@ -327,6 +334,26 @@ public class ExecutionEventLogger
} }
} }
private void appendForkInfo( StringBuilder buffer, MojoDescriptor md )
{
if ( StringUtils.isNotEmpty( md.getExecutePhase() ) )
{
// forked phase
if ( StringUtils.isNotEmpty( md.getExecuteLifecycle() ) )
{
buffer.append( '[' );
buffer.append( md.getExecuteLifecycle() );
buffer.append( ']' );
}
buffer.append( md.getExecutePhase() );
}
else
{
// forked goal
buffer.append( md.getExecuteGoal() );
}
}
private void append( StringBuilder buffer, MavenProject project ) private void append( StringBuilder buffer, MavenProject project )
{ {
buffer.append( " @ " ).append( project.getArtifactId() ); buffer.append( " @ " ).append( project.getArtifactId() );