mirror of https://github.com/apache/maven.git
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:
parent
c0d28d2ce4
commit
49c287754d
|
@ -21,9 +21,6 @@ package org.apache.maven.artifact.repository.metadata;
|
|||
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Metadata for the group directory of the repository.
|
||||
*
|
||||
|
|
|
@ -23,16 +23,16 @@ import java.util.Date;
|
|||
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;
|
||||
|
@ -99,24 +99,21 @@ public class DefaultMaven
|
|||
{
|
||||
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() );
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.Collections;
|
|||
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 class DefaultMavenExecutionResult
|
|||
|
||||
return this;
|
||||
}
|
||||
|
||||
public MavenExecutionResult setExceptionSummary( ExceptionSummary exceptionSummary )
|
||||
{
|
||||
this.exceptionSummary = exceptionSummary;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExceptionSummary getExceptionSummary()
|
||||
{
|
||||
return exceptionSummary;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.apache.maven.execution;
|
|||
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();
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.apache.maven.cli;
|
|||
*/
|
||||
|
||||
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.MavenEmbedderFileLogger;
|
|||
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 @@ public class MavenCli
|
|||
|
||||
MavenEmbedder mavenEmbedder;
|
||||
MavenEmbedderLogger logger;
|
||||
|
||||
try
|
||||
{
|
||||
mavenEmbedder = new MavenEmbedder( configuration );
|
||||
|
@ -168,25 +166,12 @@ public class MavenCli
|
|||
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue