Cleaning up reporting some more.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@604750 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2007-12-17 00:15:21 +00:00
parent b511c734a6
commit fbb4833982
6 changed files with 44 additions and 128 deletions

View File

@ -112,12 +112,12 @@ public ReactorManager createReactorManager( MavenExecutionRequest request,
}
catch ( ProjectBuildingException e )
{
result.addProjectBuildingException( e );
result.addException( e );
return null;
}
catch ( MavenExecutionException e )
{
result.addMavenExecutionException( e );
result.addException( e );
return null;
}
@ -138,13 +138,13 @@ public ReactorManager createReactorManager( MavenExecutionRequest request,
ProjectCycleException error = new ProjectCycleException( projects, message, e );
result.addBuildFailureException( error );
result.addException( error );
return null;
}
catch ( DuplicateProjectException e )
{
result.addDuplicateProjectException( e );
result.addException( e );
return null;
}
@ -194,7 +194,7 @@ public MavenExecutionResult execute( MavenExecutionRequest request )
if ( !tvr.isTaskValid() )
{
result.addBuildFailureException( tvr.generateInvalidTaskException() );
result.addException( tvr.generateInvalidTaskException() );
return result;
}
@ -223,12 +223,12 @@ public MavenExecutionResult execute( MavenExecutionRequest request )
}
catch ( LifecycleExecutionException e )
{
result.addLifecycleExecutionException( e );
result.addException( e );
return result;
}
catch ( BuildFailureException e )
{
result.addBuildFailureException( e );
result.addException( e );
return result;
}

View File

@ -19,14 +19,8 @@
* under the License.
*/
import org.apache.maven.BuildFailureException;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.extension.ExtensionScanningException;
import org.apache.maven.lifecycle.LifecycleExecutionException;
import org.apache.maven.project.DuplicateProjectException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.reactor.MavenExecutionException;
import java.util.ArrayList;
import java.util.Collections;
@ -87,56 +81,7 @@ public List getExceptions()
return exceptions == null ? Collections.EMPTY_LIST : exceptions;
}
public MavenExecutionResult addExtensionScanningException( ExtensionScanningException e )
{
addException( e );
return this;
}
public MavenExecutionResult addProjectBuildingException( ProjectBuildingException e )
{
addException( e );
return this;
}
public MavenExecutionResult addMavenExecutionException( MavenExecutionException e )
{
addException( e );
return this;
}
public MavenExecutionResult addBuildFailureException( BuildFailureException e )
{
addException( e );
return this;
}
public MavenExecutionResult addDuplicateProjectException( DuplicateProjectException e )
{
addException( e );
return this;
}
public MavenExecutionResult addLifecycleExecutionException( LifecycleExecutionException e )
{
addException( e );
return this;
}
public MavenExecutionResult addUnknownException( Throwable t )
{
addException( t );
return this;
}
private void addException( Throwable t )
public MavenExecutionResult addException( Throwable t )
{
if ( exceptions == null )
{
@ -144,6 +89,8 @@ private void addException( Throwable t )
}
exceptions.add( t );
return this;
}
public boolean hasExceptions()

View File

@ -19,14 +19,8 @@
* under the License.
*/
import org.apache.maven.BuildFailureException;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.extension.ExtensionScanningException;
import org.apache.maven.lifecycle.LifecycleExecutionException;
import org.apache.maven.project.DuplicateProjectException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.reactor.MavenExecutionException;
import java.util.List;
@ -54,13 +48,7 @@ public interface MavenExecutionResult
// - xmlpull parser exception
List getExceptions();
MavenExecutionResult addLifecycleExecutionException( LifecycleExecutionException e );
MavenExecutionResult addDuplicateProjectException( DuplicateProjectException duplicateProjectException );
MavenExecutionResult addBuildFailureException( BuildFailureException buildFailureException );
MavenExecutionResult addMavenExecutionException( MavenExecutionException e );
MavenExecutionResult addProjectBuildingException (ProjectBuildingException e );
MavenExecutionResult addExtensionScanningException( ExtensionScanningException e );
MavenExecutionResult addUnknownException( Throwable t );
MavenExecutionResult addException( Throwable e );
boolean hasExceptions();
}

View File

@ -4,7 +4,6 @@
import org.apache.maven.embedder.MavenEmbedderLogger;
import org.apache.maven.errors.CoreErrorReporter;
import org.apache.maven.errors.DefaultCoreErrorReporter;
import org.apache.maven.execution.BuildFailure;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionResult;
import org.apache.maven.execution.ReactorManager;
@ -102,9 +101,22 @@ public static void logResult( MavenExecutionRequest request,
logReactorSummary( reactorManager, logger );
boolean printSuccess = true;
if ( ( reactorManager != null ) && reactorManager.hasBuildFailures() )
{
logErrors( reactorManager, request.isShowErrors(), logger );
for ( Iterator i = result.getExceptions().iterator(); i.hasNext(); )
{
Exception e = (Exception) i.next();
showError( e, request.isShowErrors(), request.getErrorReporter(), logger );
}
line( logger );
if ( !request.isShowErrors() )
{
logger.info( "For more information, run with the -e flag" );
line( logger );
}
if ( !ReactorManager.FAIL_NEVER.equals( reactorManager.getFailureBehavior() ) )
{
@ -115,6 +127,7 @@ public static void logResult( MavenExecutionRequest request,
stats( request.getStartTime(), logger );
line( logger );
printSuccess = false;
}
else
{
@ -122,16 +135,7 @@ public static void logResult( MavenExecutionRequest request,
}
}
if ( result.hasExceptions() )
{
for ( Iterator i = result.getExceptions().iterator(); i.hasNext(); )
{
Exception e = (Exception) i.next();
showError( e, request.isShowErrors(), request.getErrorReporter(), logger );
}
}
else
if ( printSuccess )
{
line( logger );
@ -147,41 +151,21 @@ public static void logResult( MavenExecutionRequest request,
logger.close();
}
private static void logErrors( ReactorManager rm,
boolean showErrors,
MavenEmbedderLogger logger )
{
for ( Iterator it = rm.getSortedProjects().iterator(); it.hasNext(); )
{
MavenProject project = (MavenProject) it.next();
if ( rm.hasBuildFailure( project ) )
{
BuildFailure buildFailure = rm.getBuildFailure( project );
logger.info( "Error for project: " + project.getName() + " (during "
+ buildFailure.getTask() + ")" );
line( logger );
}
}
if ( !showErrors )
{
logger.info( "For more information, run Maven with the -e switch" );
line( logger );
}
}
static void showError( String message,
Exception e,
boolean showErrors )
{
showError( message, e, showErrors, new DefaultCoreErrorReporter(), new MavenEmbedderConsoleLogger() );
MavenEmbedderLogger logger = new MavenEmbedderConsoleLogger();
showError( message, e, showErrors, new DefaultCoreErrorReporter(), logger );
if ( !showErrors )
{
logger.info( "For more information, run with the -e flag" );
}
}
static void showError( Exception e,
private static void showError( Exception e,
boolean show,
CoreErrorReporter reporter,
MavenEmbedderLogger logger )
@ -196,7 +180,7 @@ static void showError( Exception e,
* @param showStackTraces
* @param logger
*/
public static void showError( String message,
static void showError( String message,
Exception e,
boolean showStackTraces,
CoreErrorReporter reporter,
@ -223,10 +207,6 @@ public static void showError( String message,
e.printStackTrace( new PrintWriter( writer ) );
}
else
{
writer.write( "For more information, run with the -e flag" );
}
logger.error( writer.toString() );
}

View File

@ -395,15 +395,15 @@ public MavenExecutionResult readProjectWithDependencies( MavenExecutionRequest r
}
catch ( MavenEmbedderException e )
{
return result.addUnknownException( e );
return result.addException( e );
}
catch ( ProjectBuildingException e )
{
return result.addProjectBuildingException( e );
return result.addException( e );
}
catch ( ExtensionScanningException e )
{
return result.addExtensionScanningException( e );
return result.addException( e );
}
ReactorManager reactorManager = maven.createReactorManager( request, result );
@ -424,7 +424,7 @@ public MavenExecutionResult readProjectWithDependencies( MavenExecutionRequest r
}
catch ( ProjectBuildingException e )
{
return result.addProjectBuildingException( e );
return result.addException( e );
}
if ( reactorManager.hasMultipleProjects() )
@ -803,7 +803,7 @@ public MavenExecutionResult execute( MavenExecutionRequest request )
{
MavenExecutionResult result = new DefaultMavenExecutionResult();
result.addUnknownException( e );
result.addException( e );
return result;
}

View File

@ -110,7 +110,8 @@ public MavenExecutionRequest populateDefaults( MavenExecutionRequest request,
snapshotPolicy( request, configuration );
localRepository( request, configuration );
// TODO: Can we remove this second call?
// localRepository( request, configuration );
checksumPolicy( request, configuration );