mirror of https://github.com/apache/maven.git
PR: MNG-721
list time taken per project in the reactor summary git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@307304 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7134d66a5c
commit
7ac27ec84c
|
@ -59,12 +59,15 @@ import org.codehaus.plexus.util.dag.CycleDetectedException;
|
|||
|
||||
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 @@ public class DefaultMaven
|
|||
|
||||
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 @@ public class DefaultMaven
|
|||
}
|
||||
else if ( rm.hasBuildSuccess( project ) )
|
||||
{
|
||||
logReactorSummaryLine( project.getName(), "SUCCESS" );
|
||||
logReactorSummaryLine( project.getName(), "SUCCESS", rm.getBuildSuccess( project ).getTime() );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -347,25 +350,59 @@ public class DefaultMaven
|
|||
}
|
||||
|
||||
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,
|
||||
String baseDirectory, Exception e )
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -124,9 +124,9 @@ public class ReactorManager
|
|||
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 @@ public class ReactorManager
|
|||
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;
|
||||
}
|
||||
|
||||
Exception getCause()
|
||||
{
|
||||
return cause;
|
||||
}
|
||||
return (BuildFailure) buildFailuresByProject.get( project.getId() );
|
||||
}
|
||||
|
||||
public BuildSuccess getBuildSuccess( MavenProject project )
|
||||
{
|
||||
return (BuildSuccess) buildSuccessesByProject.get( project.getId() );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -224,6 +224,8 @@ public class DefaultLifecycleExecutor
|
|||
// Event monitoring.
|
||||
String event = MavenEvents.PROJECT_EXECUTION;
|
||||
|
||||
long buildStartTime = System.currentTimeMillis();
|
||||
|
||||
dispatcher.dispatchStart( event, rootProject.getId() + " ( " + segment + " )" );
|
||||
|
||||
try
|
||||
|
@ -240,24 +242,24 @@ public class DefaultLifecycleExecutor
|
|||
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 @@ public class DefaultLifecycleExecutor
|
|||
// Event monitoring.
|
||||
String event = MavenEvents.PROJECT_EXECUTION;
|
||||
|
||||
long buildStartTime = System.currentTimeMillis();
|
||||
|
||||
dispatcher.dispatchStart( event, currentProject.getId() + " ( " + segment + " )" );
|
||||
|
||||
try
|
||||
|
@ -322,24 +326,24 @@ public class DefaultLifecycleExecutor
|
|||
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 @@ public class DefaultLifecycleExecutor
|
|||
}
|
||||
}
|
||||
|
||||
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 @@ public class DefaultLifecycleExecutor
|
|||
}
|
||||
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 );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue