You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2005/10/08 17:35:46 UTC
svn commit: r307304 - in
/maven/components/trunk/maven-core/src/main/java/org/apache/maven:
DefaultMaven.java execution/BuildFailure.java execution/BuildSuccess.java
execution/ReactorManager.java lifecycle/DefaultLifecycleExecutor.java
Author: brett
Date: Sat Oct 8 08:35:39 2005
New Revision: 307304
URL: http://svn.apache.org/viewcvs?rev=307304&view=rev
Log:
PR: MNG-721
list time taken per project in the reactor summary
Added:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/BuildFailure.java (with props)
maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/BuildSuccess.java (with props)
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/ReactorManager.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java?rev=307304&r1=307303&r2=307304&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java Sat Oct 8 08:35:39 2005
@@ -59,12 +59,15 @@
import java.io.File;
import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.TimeZone;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
@@ -326,7 +329,7 @@
if ( rm.hasBuildFailure( project ) )
{
- logReactorSummaryLine( project.getName(), "FAILED" );
+ logReactorSummaryLine( project.getName(), "FAILED", rm.getBuildFailure( project ).getTime() );
}
else if ( rm.isBlackListed( project ) )
{
@@ -334,7 +337,7 @@
}
else if ( rm.hasBuildSuccess( project ) )
{
- logReactorSummaryLine( project.getName(), "SUCCESS" );
+ logReactorSummaryLine( project.getName(), "SUCCESS", rm.getBuildSuccess( project ).getTime() );
}
else
{
@@ -348,22 +351,56 @@
private void logReactorSummaryLine( String name, String status )
{
+ logReactorSummaryLine( name, status, -1 );
+ }
+
+ private void logReactorSummaryLine( String name, String status, long time )
+ {
StringBuffer messageBuffer = new StringBuffer();
messageBuffer.append( name );
- int dotCount = 65;
+ int dotCount = 55;
dotCount -= name.length();
+ messageBuffer.append( " " );
+
for ( int i = 0; i < dotCount; i++ )
{
messageBuffer.append( '.' );
}
+ messageBuffer.append( " " );
+
messageBuffer.append( status );
+ if ( time >= 0 )
+ {
+ messageBuffer.append( " [" );
+
+ messageBuffer.append( getFormattedTime( time ) );
+
+ messageBuffer.append( "]" );
+ }
+
getLogger().info( messageBuffer.toString() );
+ }
+
+ private static String getFormattedTime( long time )
+ {
+ String pattern = "s.SSS's'";
+ if ( time / 60000L > 0 )
+ {
+ pattern = "m:s" + pattern;
+ if ( time / 3600000L > 0 )
+ {
+ pattern = "H:m" + pattern;
+ }
+ }
+ DateFormat fmt = new SimpleDateFormat( pattern );
+ fmt.setTimeZone( TimeZone.getTimeZone( "UTC" ) );
+ return fmt.format( new Date( time ) );
}
private MavenExecutionResponse dispatchErrorResponse( EventDispatcher dispatcher, String event,
Added: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/BuildFailure.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/BuildFailure.java?rev=307304&view=auto
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/BuildFailure.java (added)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/BuildFailure.java Sat Oct 8 08:35:39 2005
@@ -0,0 +1,54 @@
+package org.apache.maven.execution;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Describe a build failure in the reactor.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @version $Id$
+ */
+public class BuildFailure
+{
+ private final Exception cause;
+
+ private final String task;
+
+ private final long time;
+
+ BuildFailure( Exception cause, String task, long time )
+ {
+ this.cause = cause;
+ this.task = task;
+ this.time = time;
+ }
+
+ String getTask()
+ {
+ return task;
+ }
+
+ Exception getCause()
+ {
+ return cause;
+ }
+
+ public long getTime()
+ {
+ return time;
+ }
+}
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/BuildFailure.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/BuildFailure.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/BuildSuccess.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/BuildSuccess.java?rev=307304&view=auto
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/BuildSuccess.java (added)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/BuildSuccess.java Sat Oct 8 08:35:39 2005
@@ -0,0 +1,48 @@
+package org.apache.maven.execution;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.project.MavenProject;
+
+/**
+ * Describe a build success in the reactor.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @version $Id$
+ */
+public class BuildSuccess
+{
+ private final MavenProject project;
+
+ private final long time;
+
+ public BuildSuccess( MavenProject project, long time )
+ {
+ this.project = project;
+ this.time = time;
+ }
+
+ public MavenProject getProject()
+ {
+ return project;
+ }
+
+ public long getTime()
+ {
+ return time;
+ }
+}
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/BuildSuccess.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/BuildSuccess.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/ReactorManager.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/ReactorManager.java?rev=307304&r1=307303&r2=307304&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/ReactorManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/ReactorManager.java Sat Oct 8 08:35:39 2005
@@ -124,9 +124,9 @@
return blackList.contains( ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() ) );
}
- public void registerBuildFailure( MavenProject project, Exception error, String task )
+ public void registerBuildFailure( MavenProject project, Exception error, String task, long time )
{
- buildFailuresByProject.put( project.getId(), new BuildFailure( error, task ) );
+ buildFailuresByProject.put( project.getId(), new BuildFailure( error, task, time ) );
}
public boolean hasBuildFailures()
@@ -159,31 +159,19 @@
return buildSuccessesByProject.containsKey( project.getId() );
}
- public void registerBuildSuccess( MavenProject project )
+ public void registerBuildSuccess( MavenProject project, long time )
{
- buildSuccessesByProject.put( project.getId(), project );
+ buildSuccessesByProject.put( project.getId(), new BuildSuccess( project, time ) );
}
- private static class BuildFailure
+ public BuildFailure getBuildFailure( MavenProject project )
{
- private Exception cause;
-
- private String task;
-
- BuildFailure( Exception cause, String task )
- {
- this.cause = cause;
- this.task = task;
- }
-
- String getTask()
- {
- return task;
- }
+ return (BuildFailure) buildFailuresByProject.get( project.getId() );
+ }
- Exception getCause()
- {
- return cause;
- }
+ public BuildSuccess getBuildSuccess( MavenProject project )
+ {
+ return (BuildSuccess) buildSuccessesByProject.get( project.getId() );
}
+
}
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?rev=307304&r1=307303&r2=307304&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java Sat Oct 8 08:35:39 2005
@@ -224,6 +224,8 @@
// Event monitoring.
String event = MavenEvents.PROJECT_EXECUTION;
+ long buildStartTime = System.currentTimeMillis();
+
dispatcher.dispatchStart( event, rootProject.getId() + " ( " + segment + " )" );
try
@@ -240,24 +242,24 @@
catch ( MojoExecutionException e )
{
// TODO: should this be removed?
- handleExecutionFailure( rm, rootProject, e, task );
+ handleExecutionFailure( rm, rootProject, e, task, buildStartTime );
}
catch ( ArtifactResolutionException e )
{
// TODO: should this be removed?
- handleExecutionFailure( rm, rootProject, e, task );
+ handleExecutionFailure( rm, rootProject, e, task, buildStartTime );
}
catch ( MojoFailureException e )
{
- handleExecutionFailure( rm, rootProject, e, task );
+ handleExecutionFailure( rm, rootProject, e, task, buildStartTime );
}
catch ( ArtifactNotFoundException e )
{
- handleExecutionFailure( rm, rootProject, e, task );
+ handleExecutionFailure( rm, rootProject, e, task, buildStartTime );
}
}
- rm.registerBuildSuccess( rootProject );
+ rm.registerBuildSuccess( rootProject, System.currentTimeMillis() - buildStartTime );
dispatcher.dispatchEnd( event, rootProject.getId() + " ( " + segment + " )" );
}
@@ -307,6 +309,8 @@
// Event monitoring.
String event = MavenEvents.PROJECT_EXECUTION;
+ long buildStartTime = System.currentTimeMillis();
+
dispatcher.dispatchStart( event, currentProject.getId() + " ( " + segment + " )" );
try
@@ -322,24 +326,24 @@
catch ( MojoExecutionException e )
{
// TODO: should this be removed?
- handleExecutionFailure( rm, currentProject, e, task );
+ handleExecutionFailure( rm, currentProject, e, task, buildStartTime );
}
catch ( ArtifactResolutionException e )
{
// TODO: should this be removed?
- handleExecutionFailure( rm, currentProject, e, task );
+ handleExecutionFailure( rm, currentProject, e, task, buildStartTime );
}
catch ( MojoFailureException e )
{
- handleExecutionFailure( rm, currentProject, e, task );
+ handleExecutionFailure( rm, currentProject, e, task, buildStartTime );
}
catch ( ArtifactNotFoundException e )
{
- handleExecutionFailure( rm, currentProject, e, task );
+ handleExecutionFailure( rm, currentProject, e, task, buildStartTime );
}
}
- rm.registerBuildSuccess( currentProject );
+ rm.registerBuildSuccess( currentProject, System.currentTimeMillis() - buildStartTime );
dispatcher.dispatchEnd( event, currentProject.getId() + " ( " + segment + " )" );
}
@@ -368,12 +372,13 @@
}
}
- private void handleExecutionFailure( ReactorManager rm, MavenProject project, Exception e, String task )
+ private void handleExecutionFailure( ReactorManager rm, MavenProject project, Exception e, String task,
+ long buildStartTime )
throws MojoExecutionException, MojoFailureException, ArtifactNotFoundException, ArtifactResolutionException
{
if ( ReactorManager.FAIL_FAST.equals( rm.getFailureBehavior() ) )
{
- rm.registerBuildFailure( project, e, task );
+ rm.registerBuildFailure( project, e, task, System.currentTimeMillis() - buildStartTime );
if ( e instanceof MojoExecutionException )
{
@@ -400,7 +405,7 @@
}
else if ( ReactorManager.FAIL_AT_END.equals( rm.getFailureBehavior() ) )
{
- rm.registerBuildFailure( project, e, task );
+ rm.registerBuildFailure( project, e, task, System.currentTimeMillis() - buildStartTime );
rm.blackList( project );
}