You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2017/04/25 20:38:31 UTC

svn commit: r1792653 - /maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/AbstractInvokerMojo.java

Author: hboutemy
Date: Tue Apr 25 20:38:31 2017
New Revision: 1792653

URL: http://svn.apache.org/viewvc?rev=1792653&view=rev
Log:
[MINVOKER-205] improved output

Modified:
    maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/AbstractInvokerMojo.java

Modified: maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/AbstractInvokerMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/AbstractInvokerMojo.java?rev=1792653&r1=1792652&r2=1792653&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/AbstractInvokerMojo.java (original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/AbstractInvokerMojo.java Tue Apr 25 20:38:31 2017
@@ -80,6 +80,7 @@ import org.apache.maven.shared.invoker.M
 import org.apache.maven.shared.scriptinterpreter.RunErrorException;
 import org.apache.maven.shared.scriptinterpreter.RunFailureException;
 import org.apache.maven.shared.scriptinterpreter.ScriptRunner;
+import org.apache.maven.shared.utils.logging.MessageBuilder;
 import org.codehaus.plexus.interpolation.InterpolationException;
 import org.codehaus.plexus.interpolation.Interpolator;
 import org.codehaus.plexus.interpolation.MapBasedValueSource;
@@ -108,6 +109,11 @@ public abstract class AbstractInvokerMoj
     extends AbstractMojo
 {
     /**
+     * The zero-based column index where to print the invoker result.
+     */
+    private static final int RESULT_COLUMN = 60;
+
+    /**
      * Flag used to suppress certain invocations. This is useful in tailoring the build using profiles.
      *
      * @since 1.1
@@ -1517,7 +1523,8 @@ public abstract class AbstractInvokerMoj
 
                     if ( !suppressSummaries )
                     {
-                        getLog().info( ".." + buffer().success( "SUCCESS " ) + formatTime( buildJob.getTime() ) );
+                        getLog().info( pad( buildJob ).success( "SUCCESS" ).a( ' ' )
+                            + formatTime( buildJob.getTime() ) );
                     }
                 }
                 else
@@ -1526,7 +1533,8 @@ public abstract class AbstractInvokerMoj
 
                     if ( !suppressSummaries )
                     {
-                        getLog().info( ".." + buffer().warning( "SKIPPED " ) + formatTime( buildJob.getTime() ) );
+                        getLog().info( pad( buildJob ).warning( "SKIPPED" ).a( ' ' )
+                            + formatTime( buildJob.getTime() ) );
                     }
                 }
             }
@@ -1565,7 +1573,7 @@ public abstract class AbstractInvokerMoj
 
                 if ( !suppressSummaries )
                 {
-                    getLog().info( ".." + buffer().warning( "SKIPPED " ) + " due to " + message.toString() );
+                    getLog().info( pad( buildJob ).warning( "SKIPPED" ) + " due to " + message.toString() );
                 }
 
                 // Abuse failureMessage, the field in the report which should contain the reason for skipping
@@ -1580,7 +1588,7 @@ public abstract class AbstractInvokerMoj
 
             if ( !suppressSummaries )
             {
-                getLog().info( ".." + buffer().failure( "ERROR " ) + formatTime( buildJob.getTime() ) );
+                getLog().info( pad( buildJob ).failure( "ERROR" ).a( ' ' ) + formatTime( buildJob.getTime() ) );
                 getLog().info( "  " + e.getMessage() );
             }
         }
@@ -1591,7 +1599,7 @@ public abstract class AbstractInvokerMoj
 
             if ( !suppressSummaries )
             {
-                getLog().info( ".." + buffer().failure( "FAILED " ) + formatTime( buildJob.getTime() ) );
+                getLog().info( pad( buildJob ).failure( "FAILED" ).a( ' ' ) + formatTime( buildJob.getTime() ) );
                 getLog().info( "  " + e.getMessage() );
             }
         }
@@ -1602,6 +1610,27 @@ public abstract class AbstractInvokerMoj
         }
     }
 
+    private MessageBuilder pad( BuildJob buildJob )
+    {
+        MessageBuilder buffer = buffer( 128 );
+
+        buffer.a( "          " );
+        buffer.a( buildJob.getProject() );
+        buffer.a( ' ' );
+
+        int l = 11 + buildJob.getProject().length();
+
+        if ( l < RESULT_COLUMN )
+        {
+            for ( int i = RESULT_COLUMN - l; i > 0; i-- )
+            {
+                buffer.a( '.' );
+            }
+        }
+
+        return buffer.a( ' ' );
+    }
+
     /**
      * Delete the interpolated pom file if it has been created before.
      *