[MNG-6391] - Printout version of last built module in reactor build

This commit is contained in:
Karl Heinz Marbaise 2018-04-11 19:42:38 +02:00
parent 42c77a71df
commit 23f5c88d11
No known key found for this signature in database
GPG Key ID: BF1518E0160788A2
1 changed files with 32 additions and 6 deletions

View File

@ -141,19 +141,46 @@ public class ExecutionEventLogger
}
}
private boolean isSingleVersionedReactor( MavenSession session )
{
boolean result = true;
MavenProject topProject = session.getTopLevelProject();
List<MavenProject> sortedProjects = session.getProjectDependencyGraph().getSortedProjects();
for ( MavenProject mavenProject : sortedProjects )
{
if ( !topProject.getVersion().equals( mavenProject.getVersion() ) )
{
result = false;
break;
}
}
return result;
}
private void logReactorSummary( MavenSession session )
{
boolean isSingleVersion = isSingleVersionedReactor( session );
infoLine( '-' );
infoMain( "Reactor Summary:" );
StringBuilder summary = new StringBuilder( "Reactor Summary" );
if ( isSingleVersion )
{
summary.append( " for " );
summary.append( session.getTopLevelProject().getName() );
summary.append( " " );
summary.append( session.getTopLevelProject().getVersion() );
}
summary.append( ":" );
infoMain( summary.toString() );
logger.info( "" );
MavenExecutionResult result = session.getResult();
List<MavenProject> projects = session.getProjects();
MavenProject lastProject = projects.get( projects.size() - 1 );
MavenProject topProject = session.getTopLevelProject();
for ( MavenProject project : projects )
{
@ -162,8 +189,7 @@ public class ExecutionEventLogger
buffer.append( project.getName() );
buffer.append( ' ' );
if ( topProject.equals( project ) || lastProject.equals( project )
|| !topProject.getVersion().equals( project.getVersion() ) )
if ( !isSingleVersion )
{
buffer.append( project.getVersion() );
buffer.append( ' ' );
@ -241,7 +267,7 @@ public class ExecutionEventLogger
String wallClock = session.getRequest().getDegreeOfConcurrency() > 1 ? " (Wall Clock)" : "";
logger.info( "Total time: " + formatDuration( time ) + wallClock );
logger.info( "Total time: " + formatDuration( time ) + wallClock );
logger.info( "Finished at: " + formatTimestamp( finish ) );
}