o pushing my changes back in with shane's

git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@769580 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2009-04-28 23:04:24 +00:00
parent c0d28d2ce4
commit 49c287754d
5 changed files with 37 additions and 39 deletions

View File

@ -21,9 +21,6 @@
import org.apache.maven.artifact.repository.ArtifactRepository;
import java.util.Iterator;
import java.util.List;
/**
* Metadata for the group directory of the repository.
*

View File

@ -23,16 +23,16 @@
import java.util.List;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.exception.DefaultExceptionHandler;
import org.apache.maven.exception.ExceptionHandler;
import org.apache.maven.exception.ExceptionSummary;
import org.apache.maven.execution.DefaultMavenExecutionResult;
import org.apache.maven.execution.DuplicateProjectException;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionResult;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.execution.RuntimeInformation;
import org.apache.maven.lifecycle.LifecycleExecutionException;
import org.apache.maven.lifecycle.LifecycleExecutor;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.ProjectBuildingException;
@ -98,25 +98,22 @@ public MavenExecutionResult execute( MavenExecutionRequest request )
try
{
lifecycleExecutor.execute( session );
}
catch ( LifecycleExecutionException e )
{
}
catch ( Exception e )
{
ExceptionHandler handler = new DefaultExceptionHandler();
// This will only be more then one if we have fail at end on and we collect
// them per project.
ExceptionSummary es = handler.handleException( result.getExceptions().get( 0 ) );
result.addException( e );
result.setExceptionSummary( es );
return result;
}
catch ( MojoFailureException e )
{
result.addException( e );
return result;
}
catch ( MojoExecutionException e )
{
result.addException( e );
return result;
}
result.setTopologicallySortedProjects( session.getReactorManager().getSortedProjects() );
result.setProject( session.getReactorManager().getTopLevelProject() );

View File

@ -24,6 +24,7 @@
import java.util.List;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.exception.ExceptionSummary;
import org.apache.maven.project.MavenProject;
/** @author Jason van Zyl */
@ -40,6 +41,8 @@ public class DefaultMavenExecutionResult
private ReactorManager reactorManager;
private ExceptionSummary exceptionSummary;
public MavenExecutionResult setProject( MavenProject project )
{
this.project = project;
@ -109,4 +112,16 @@ public MavenExecutionResult setReactorManager( ReactorManager reactorManager )
return this;
}
public MavenExecutionResult setExceptionSummary( ExceptionSummary exceptionSummary )
{
this.exceptionSummary = exceptionSummary;
return this;
}
public ExceptionSummary getExceptionSummary()
{
return exceptionSummary;
}
}

View File

@ -22,6 +22,7 @@
import java.util.List;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.exception.ExceptionSummary;
import org.apache.maven.project.MavenProject;
/**
@ -51,4 +52,7 @@ public interface MavenExecutionResult
MavenExecutionResult addException( Throwable e );
boolean hasExceptions();
MavenExecutionResult setExceptionSummary( ExceptionSummary exceptionSummary );
ExceptionSummary getExceptionSummary();
}

View File

@ -20,7 +20,6 @@
*/
import java.io.File;
import java.util.List;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.ParseException;
@ -34,8 +33,6 @@
import org.apache.maven.embedder.MavenEmbedderLogger;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionResult;
import org.apache.maven.lifecycle.LifecycleExecutor;
import org.apache.maven.plugin.MojoFailureException;
import org.codehaus.plexus.classworlds.ClassWorld;
/**
@ -148,6 +145,7 @@ else if ( debug || commandLine.hasOption( CLIManager.SHOW_VERSION ) )
MavenEmbedder mavenEmbedder;
MavenEmbedderLogger logger;
try
{
mavenEmbedder = new MavenEmbedder( configuration );
@ -167,26 +165,13 @@ else if ( debug || commandLine.hasOption( CLIManager.SHOW_VERSION ) )
}
MavenExecutionResult result = mavenEmbedder.execute( request );
//CLIReportingUtils.logResult( request, result, logger );
System.out.println( "exceptions: " + result.hasExceptions() );
System.out.println( result.getExceptions() );
Exception e = result.getExceptions().get( 0 );
if ( e instanceof MojoFailureException )
{
System.out.println( ((MojoFailureException)e).getLongMessage() );
}
else
{
System.out.println( e.getMessage() );
}
// The exception handling should be handled in Maven itself.
if ( result.hasExceptions() )
{
System.out.println( result.getExceptionSummary().getMessage() );
return 1;
}
else