You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2009/01/18 00:29:14 UTC

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

Author: bentmann
Date: Sat Jan 17 15:29:13 2009
New Revision: 735359

URL: http://svn.apache.org/viewvc?rev=735359&view=rev
Log:
o Added build time to summary output

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

Modified: maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java?rev=735359&r1=735358&r2=735359&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java (original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java Sat Jan 17 15:29:13 2009
@@ -27,6 +27,8 @@
 import java.io.PrintStream;
 import java.io.Reader;
 import java.io.Writer;
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -473,6 +475,11 @@
     private String filteredPomPrefix = "interpolated-";
 
     /**
+     * The format for elapsed build time.
+     */
+    private final DecimalFormat SECS_FORMAT = new DecimalFormat( "(0.0 s)", new DecimalFormatSymbols( Locale.ENGLISH ) );
+
+    /**
      * Invokes Maven on the configured test projects.
      * 
      * @throws MojoExecutionException If the goal encountered severe errors.
@@ -1011,20 +1018,24 @@
             }
         }
 
+        long milliseconds = System.currentTimeMillis();
         try
         {
             runBuild( basedir, interpolatedPomFile, settingsFile );
 
             if ( !suppressSummaries )
             {
-                getLog().info( "...SUCCESS." );
+                milliseconds = System.currentTimeMillis() - milliseconds;
+                getLog().info( "..SUCCESS " + formatTime( milliseconds ) );
             }
         }
         catch ( BuildFailureException e )
         {
             if ( !suppressSummaries )
             {
-                getLog().info( "...FAILED. " + e.getMessage() );
+                milliseconds = System.currentTimeMillis() - milliseconds;
+                getLog().info( "..FAILED " + formatTime( milliseconds ) );
+                getLog().info( "  " + e.getMessage() );
             }
             throw e;
         }
@@ -1038,6 +1049,17 @@
     }
 
     /**
+     * Formats the specified build duration time.
+     * 
+     * @param milliseconds The duration of the build.
+     * @return The formatted time, never <code>null</code>.
+     */
+    private String formatTime( long milliseconds )
+    {
+        return SECS_FORMAT.format( milliseconds / 1000.0 );
+    }
+
+    /**
      * Runs the specified project.
      * 
      * @param basedir The base directory of the project, must not be <code>null</code>.