From 23f5c88d118fb06b93fc94017997d1753a0dc576 Mon Sep 17 00:00:00 2001 From: Karl Heinz Marbaise Date: Wed, 11 Apr 2018 19:42:38 +0200 Subject: [PATCH] [MNG-6391] - Printout version of last built module in reactor build --- .../maven/cli/event/ExecutionEventLogger.java | 38 ++++++++++++++++--- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java b/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java index 00c9164e33..cb34d8ecee 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java @@ -141,19 +141,46 @@ public class ExecutionEventLogger } } + private boolean isSingleVersionedReactor( MavenSession session ) + { + boolean result = true; + + MavenProject topProject = session.getTopLevelProject(); + List 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 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 ) ); }