maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbout...@apache.org
Subject [1/3] maven git commit: [MNG-6308] display groupId:artifactId in Building message header
Date Sat, 06 Jan 2018 21:41:01 GMT
Repository: maven
Updated Branches:
  refs/heads/master 68a9d7967 -> 58cf490c6


[MNG-6308] display groupId:artifactId in Building message header

Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/c2e3b3e3
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/c2e3b3e3
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/c2e3b3e3

Branch: refs/heads/master
Commit: c2e3b3e301a96e36670206db0c215f3026937d33
Parents: 98d2e19
Author: Hervé Boutemy <hboutemy@apache.org>
Authored: Sat Jan 6 22:12:08 2018 +0100
Committer: Hervé Boutemy <hboutemy@apache.org>
Committed: Sat Jan 6 22:40:29 2018 +0100

----------------------------------------------------------------------
 .../maven/cli/event/ExecutionEventLogger.java   | 21 ++++++++++++--
 .../cli/event/ExecutionEventLoggerTest.java     | 30 +++++++++++++++++++-
 2 files changed, 48 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/c2e3b3e3/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java
----------------------------------------------------------------------
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 513d56a..3da9ad3 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
@@ -261,9 +261,26 @@ public class ExecutionEventLogger
     {
         if ( logger.isInfoEnabled() )
         {
+            MavenProject project = event.getProject();
+
             logger.info( "" );
-            infoLine( '-' );
 
+            // -------< groupId:artifactId >-------
+            String projectKey = project.getGroupId() + ':' + project.getArtifactId();
+            
+            final String preHeader  = "--< ";
+            final String postHeader = " >--";
+
+            final int headerLen = preHeader.length() + projectKey.length() + postHeader.length();
+
+            String prefix = chars( '-', Math.max( 0, ( LINE_LENGTH - headerLen ) / 2 ) )
+ preHeader;
+
+            String suffix = postHeader
+                + chars( '-', Math.max( 0, LINE_LENGTH - headerLen - prefix.length() + preHeader.length()
) );
+
+            logger.info( buffer().strong( prefix ).project( projectKey ).strong( suffix ).toString()
);
+
+            // Building Project Name Version    [i/n]
             String building = "Building " + event.getProject().getName() + " " + event.getProject().getVersion();
 
             if ( totalProjects <= 1 )
@@ -283,7 +300,7 @@ public class ExecutionEventLogger
                 int pad = LINE_LENGTH - building.length() - progress.length();
 
                 infoMain( building + ( ( pad > 0 ) ? chars( ' ', pad ) : "" ) + progress
);
-            } // else what's the point
+            }
 
             infoLine( '-' );
         }

http://git-wip-us.apache.org/repos/asf/maven/blob/c2e3b3e3/maven-embedder/src/test/java/org/apache/maven/cli/event/ExecutionEventLoggerTest.java
----------------------------------------------------------------------
diff --git a/maven-embedder/src/test/java/org/apache/maven/cli/event/ExecutionEventLoggerTest.java
b/maven-embedder/src/test/java/org/apache/maven/cli/event/ExecutionEventLoggerTest.java
index 515f9fe..4c0539d 100644
--- a/maven-embedder/src/test/java/org/apache/maven/cli/event/ExecutionEventLoggerTest.java
+++ b/maven-embedder/src/test/java/org/apache/maven/cli/event/ExecutionEventLoggerTest.java
@@ -71,8 +71,36 @@ public class ExecutionEventLoggerTest
         // verify
         InOrder inOrder = inOrder( logger );
         inOrder.verify( logger ).info( "" );
-        inOrder.verify( logger ).info( "------------------------------------------------------------------------"
);
+        inOrder.verify( logger ).info( "------------------< org.apache.maven:maven-embedder
>-------------------" );
         inOrder.verify( logger ).info( "Building Apache Maven Embedder 3.5.4-SNAPSHOT" );
         inOrder.verify( logger ).info( "------------------------------------------------------------------------"
);
     }
+
+    @Test
+    public void testProjectStartedOverflow()
+    {
+        // prepare
+        Logger logger = mock( Logger.class );
+        when( logger.isInfoEnabled() ).thenReturn( true );
+        executionEventLogger = new ExecutionEventLogger( logger );
+
+        ExecutionEvent event = mock( ExecutionEvent.class );
+        MavenProject project = mock( MavenProject.class );
+        when( project.getGroupId() ).thenReturn( "org.apache.maven.plugins.overflow" );
+        when( project.getArtifactId() ).thenReturn( "maven-project-info-reports-plugin" );
+        when( project.getPackaging() ).thenReturn( "maven-plugin" );
+        when( project.getName() ).thenReturn( "Apache Maven Project Info Reports Plugin"
);
+        when( project.getVersion() ).thenReturn( "3.0.0-SNAPSHOT" );
+        when( event.getProject() ).thenReturn( project );
+
+        // execute
+        executionEventLogger.projectStarted( event );
+
+        // verify
+        InOrder inOrder = inOrder( logger );
+        inOrder.verify( logger ).info( "" );
+        inOrder.verify( logger ).info( "--< org.apache.maven.plugins.overflow:maven-project-info-reports-plugin
>--" );
+        inOrder.verify( logger ).info( "Building Apache Maven Project Info Reports Plugin
3.0.0-SNAPSHOT" );
+        inOrder.verify( logger ).info( "------------------------------------------------------------------------"
);
+    }
 }


Mime
View raw message