maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From khmarba...@apache.org
Subject [maven] 01/01: [MNG-6391] - Printout version of last built module in reactor build
Date Thu, 13 Sep 2018 20:21:48 GMT
This is an automated email from the ASF dual-hosted git repository.

khmarbaise pushed a commit to branch MNG-6391
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 26cf1681900856ddbae7dba4dd4365550a03a246
Author: Karl Heinz Marbaise <khmarbaise@apache.org>
AuthorDate: Wed Apr 11 19:42:38 2018 +0200

    [MNG-6391] - Printout version of last built module in reactor build
---
 .../maven/cli/event/ExecutionEventLogger.java      | 37 ++++++++++++++++++----
 1 file changed, 31 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 00c9164..c96cda9 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,45 @@ 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( " (" );
+            summary.append( session.getTopLevelProject().getVersion() );
+            summary.append( ")" );
+        }
+        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 +188,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 +266,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 ) );
     }


Mime
View raw message