mirror of https://github.com/apache/maven.git
PR: MNG-122
final exception cleanup - reduce the noise in the lifecycle executor, get rid of response object in favour of exception handling from DefaultMaven. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@320797 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
665759970a
commit
11df168337
|
@ -25,8 +25,27 @@ package org.apache.maven;
|
||||||
public class BuildFailureException
|
public class BuildFailureException
|
||||||
extends Exception
|
extends Exception
|
||||||
{
|
{
|
||||||
|
private String longMessage;
|
||||||
|
|
||||||
public BuildFailureException( String message )
|
public BuildFailureException( String message )
|
||||||
{
|
{
|
||||||
super( message );
|
super( message );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BuildFailureException( String message, String longMessage )
|
||||||
|
{
|
||||||
|
super( message );
|
||||||
|
this.longMessage = longMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BuildFailureException( String message, String longMessage, Throwable cause )
|
||||||
|
{
|
||||||
|
super( message, cause );
|
||||||
|
this.longMessage = longMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLongMessage()
|
||||||
|
{
|
||||||
|
return longMessage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,11 +18,10 @@ package org.apache.maven;
|
||||||
|
|
||||||
import org.apache.maven.artifact.manager.WagonManager;
|
import org.apache.maven.artifact.manager.WagonManager;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||||
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||||
|
import org.apache.maven.execution.BuildFailure;
|
||||||
import org.apache.maven.execution.MavenExecutionRequest;
|
import org.apache.maven.execution.MavenExecutionRequest;
|
||||||
import org.apache.maven.execution.MavenExecutionResponse;
|
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.execution.ReactorManager;
|
import org.apache.maven.execution.ReactorManager;
|
||||||
import org.apache.maven.execution.RuntimeInformation;
|
import org.apache.maven.execution.RuntimeInformation;
|
||||||
|
@ -31,8 +30,6 @@ import org.apache.maven.lifecycle.LifecycleExecutor;
|
||||||
import org.apache.maven.model.Profile;
|
import org.apache.maven.model.Profile;
|
||||||
import org.apache.maven.monitor.event.EventDispatcher;
|
import org.apache.maven.monitor.event.EventDispatcher;
|
||||||
import org.apache.maven.monitor.event.MavenEvents;
|
import org.apache.maven.monitor.event.MavenEvents;
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
|
||||||
import org.apache.maven.profiles.ProfileManager;
|
import org.apache.maven.profiles.ProfileManager;
|
||||||
import org.apache.maven.profiles.activation.ProfileActivationException;
|
import org.apache.maven.profiles.activation.ProfileActivationException;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
|
@ -71,14 +68,11 @@ import java.util.TimeZone;
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
|
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
* @todo unify error reporting. We should return one response, always - and let the CLI decide how to render it. The reactor response should contain individual project responses
|
|
||||||
*/
|
*/
|
||||||
public class DefaultMaven
|
public class DefaultMaven
|
||||||
extends AbstractLogEnabled
|
extends AbstractLogEnabled
|
||||||
implements Maven, Contextualizable
|
implements Maven, Contextualizable
|
||||||
{
|
{
|
||||||
public static File userDir = new File( System.getProperty( "user.dir" ) );
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Components
|
// Components
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@ -103,8 +97,103 @@ public class DefaultMaven
|
||||||
// Project execution
|
// Project execution
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
public MavenExecutionResponse execute( MavenExecutionRequest request )
|
public void execute( MavenExecutionRequest request )
|
||||||
throws SettingsConfigurationException, MavenExecutionException
|
throws MavenExecutionException
|
||||||
|
{
|
||||||
|
EventDispatcher dispatcher = request.getEventDispatcher();
|
||||||
|
|
||||||
|
String event = MavenEvents.REACTOR_EXECUTION;
|
||||||
|
|
||||||
|
dispatcher.dispatchStart( event, request.getBaseDirectory() );
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ReactorManager rm = doExecute( request, dispatcher );
|
||||||
|
|
||||||
|
// TODO: shoul all the logging be left to the CLI?
|
||||||
|
logReactorSummary( rm );
|
||||||
|
|
||||||
|
if ( rm.hasBuildFailures() )
|
||||||
|
{
|
||||||
|
logErrors( rm, request.isShowErrors() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logSuccess( rm );
|
||||||
|
}
|
||||||
|
|
||||||
|
stats( request.getStartTime() );
|
||||||
|
|
||||||
|
line();
|
||||||
|
|
||||||
|
dispatcher.dispatchEnd( event, request.getBaseDirectory() );
|
||||||
|
}
|
||||||
|
catch ( LifecycleExecutionException e )
|
||||||
|
{
|
||||||
|
dispatcher.dispatchError( event, request.getBaseDirectory(), e );
|
||||||
|
|
||||||
|
logError( e, request.isShowErrors() );
|
||||||
|
|
||||||
|
stats( request.getStartTime() );
|
||||||
|
|
||||||
|
line();
|
||||||
|
|
||||||
|
throw new MavenExecutionException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
catch ( BuildFailureException e )
|
||||||
|
{
|
||||||
|
dispatcher.dispatchError( event, request.getBaseDirectory(), e );
|
||||||
|
|
||||||
|
logFailure( e, request.isShowErrors() );
|
||||||
|
|
||||||
|
stats( request.getStartTime() );
|
||||||
|
|
||||||
|
line();
|
||||||
|
|
||||||
|
throw new MavenExecutionException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
catch ( Throwable t )
|
||||||
|
{
|
||||||
|
dispatcher.dispatchError( event, request.getBaseDirectory(), t );
|
||||||
|
|
||||||
|
logFatal( t );
|
||||||
|
|
||||||
|
stats( request.getStartTime() );
|
||||||
|
|
||||||
|
line();
|
||||||
|
|
||||||
|
throw new MavenExecutionException( "Error executing project within the reactor", t );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void logErrors( ReactorManager rm, boolean showErrors )
|
||||||
|
{
|
||||||
|
for ( Iterator it = rm.getSortedProjects().iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
MavenProject project = (MavenProject) it.next();
|
||||||
|
|
||||||
|
if ( rm.hasBuildFailure( project ) )
|
||||||
|
{
|
||||||
|
BuildFailure buildFailure = rm.getBuildFailure( project );
|
||||||
|
|
||||||
|
line();
|
||||||
|
|
||||||
|
getLogger().info(
|
||||||
|
"Error for project: " + project.getName() + " (during " + buildFailure.getTask() + ")" );
|
||||||
|
|
||||||
|
line();
|
||||||
|
|
||||||
|
logDiagnostics( buildFailure.getCause() );
|
||||||
|
|
||||||
|
logTrace( buildFailure.getCause(), showErrors );
|
||||||
|
|
||||||
|
line();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ReactorManager doExecute( MavenExecutionRequest request, EventDispatcher dispatcher )
|
||||||
|
throws MavenExecutionException, BuildFailureException, LifecycleExecutionException
|
||||||
{
|
{
|
||||||
if ( request.getSettings().isOffline() )
|
if ( request.getSettings().isOffline() )
|
||||||
{
|
{
|
||||||
|
@ -147,12 +236,10 @@ public class DefaultMaven
|
||||||
{
|
{
|
||||||
throw new MavenExecutionException( "Unable to configure Maven for execution", e );
|
throw new MavenExecutionException( "Unable to configure Maven for execution", e );
|
||||||
}
|
}
|
||||||
|
catch ( SettingsConfigurationException e )
|
||||||
EventDispatcher dispatcher = request.getEventDispatcher();
|
{
|
||||||
|
throw new MavenExecutionException( "Unable to configure Maven for execution", e );
|
||||||
String event = MavenEvents.REACTOR_EXECUTION;
|
}
|
||||||
|
|
||||||
dispatcher.dispatchStart( event, request.getBaseDirectory() );
|
|
||||||
|
|
||||||
ProfileManager globalProfileManager = request.getGlobalProfileManager();
|
ProfileManager globalProfileManager = request.getGlobalProfileManager();
|
||||||
|
|
||||||
|
@ -161,44 +248,11 @@ public class DefaultMaven
|
||||||
getLogger().info( "Scanning for projects..." );
|
getLogger().info( "Scanning for projects..." );
|
||||||
|
|
||||||
boolean foundProjects = true;
|
boolean foundProjects = true;
|
||||||
List projects;
|
List projects = getProjects( request, globalProfileManager );
|
||||||
try
|
if ( projects.isEmpty() )
|
||||||
{
|
{
|
||||||
List files = getProjectFiles( request );
|
projects.add( getSuperProject( request ) );
|
||||||
|
foundProjects = false;
|
||||||
projects = collectProjects( files, request.getLocalRepository(), request.isRecursive(),
|
|
||||||
request.getSettings(), globalProfileManager, !request.isReactorActive() );
|
|
||||||
|
|
||||||
// the reasoning here is that the list is still unsorted according to dependency, so the first project
|
|
||||||
// SHOULD BE the top-level, or the one we want to start with if we're doing an aggregated build.
|
|
||||||
|
|
||||||
if ( projects.isEmpty() )
|
|
||||||
{
|
|
||||||
MavenProject superProject = projectBuilder.buildStandaloneSuperProject( request.getLocalRepository() );
|
|
||||||
projects.add( superProject );
|
|
||||||
|
|
||||||
foundProjects = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch ( IOException e )
|
|
||||||
{
|
|
||||||
throw new MavenExecutionException( "Error processing projects for the reactor: ", e );
|
|
||||||
}
|
|
||||||
catch ( ArtifactResolutionException e )
|
|
||||||
{
|
|
||||||
return dispatchErrorResponse( dispatcher, event, request.getBaseDirectory(), e );
|
|
||||||
}
|
|
||||||
catch ( ProjectBuildingException e )
|
|
||||||
{
|
|
||||||
return dispatchErrorResponse( dispatcher, event, request.getBaseDirectory(), e );
|
|
||||||
}
|
|
||||||
catch ( ProfileActivationException e )
|
|
||||||
{
|
|
||||||
return dispatchErrorResponse( dispatcher, event, request.getBaseDirectory(), e );
|
|
||||||
}
|
|
||||||
catch ( BuildFailureException e )
|
|
||||||
{
|
|
||||||
return dispatchErrorResponse( dispatcher, event, request.getBaseDirectory(), e );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReactorManager rm;
|
ReactorManager rm;
|
||||||
|
@ -215,7 +269,8 @@ public class DefaultMaven
|
||||||
}
|
}
|
||||||
catch ( CycleDetectedException e )
|
catch ( CycleDetectedException e )
|
||||||
{
|
{
|
||||||
return dispatchErrorResponse( dispatcher, event, request.getBaseDirectory(), e );
|
throw new MavenExecutionException(
|
||||||
|
"The projects in the reactor contain a cyclic reference: " + e.getMessage(), e );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( rm.hasMultipleProjects() )
|
if ( rm.hasMultipleProjects() )
|
||||||
|
@ -233,113 +288,56 @@ public class DefaultMaven
|
||||||
|
|
||||||
session.setUsingPOMsFromFilesystem( foundProjects );
|
session.setUsingPOMsFromFilesystem( foundProjects );
|
||||||
|
|
||||||
try
|
lifecycleExecutor.execute( session, rm, dispatcher );
|
||||||
{
|
|
||||||
MavenExecutionResponse response = lifecycleExecutor.execute( session, rm, dispatcher );
|
|
||||||
|
|
||||||
// TODO: is this perhaps more appropriate in the CLI?
|
return rm;
|
||||||
if ( response.isExecutionFailure() )
|
|
||||||
{
|
|
||||||
dispatcher.dispatchError( event, request.getBaseDirectory(), response.getException() );
|
|
||||||
|
|
||||||
// TODO: yuck! Revisit when cleaning up the exception handling from the top down
|
|
||||||
Throwable exception = response.getException();
|
|
||||||
|
|
||||||
// TODO: replace all handling by buildfailureexception/mavenexecutionexception or lifecycleexecutionexception
|
|
||||||
if ( exception instanceof BuildFailureException )
|
|
||||||
{
|
|
||||||
logFailure( response, rm, exception, null );
|
|
||||||
}
|
|
||||||
else if ( exception instanceof MojoFailureException )
|
|
||||||
{
|
|
||||||
MojoFailureException e = (MojoFailureException) exception;
|
|
||||||
|
|
||||||
logFailure( response, rm, e, e.getLongMessage() );
|
|
||||||
}
|
|
||||||
else if ( exception instanceof MojoExecutionException )
|
|
||||||
{
|
|
||||||
// TODO: replace by above
|
|
||||||
if ( exception.getCause() == null )
|
|
||||||
{
|
|
||||||
MojoExecutionException e = (MojoExecutionException) exception;
|
|
||||||
|
|
||||||
logFailure( response, rm, e, e.getLongMessage() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO: throw exceptions like this, so "failures" are just that
|
|
||||||
logError( response );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( exception instanceof ArtifactNotFoundException )
|
|
||||||
{
|
|
||||||
logFailure( response, rm, exception, null );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO: this should be a "FATAL" exception, reported to the
|
|
||||||
// developers - however currently a LOT of
|
|
||||||
// "user" errors fall through the cracks (like invalid POMs, as
|
|
||||||
// one example)
|
|
||||||
logError( response );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
logSuccess( response, rm );
|
|
||||||
}
|
|
||||||
|
|
||||||
dispatcher.dispatchEnd( event, request.getBaseDirectory() );
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
catch ( LifecycleExecutionException e )
|
|
||||||
{
|
|
||||||
logFatal( e );
|
|
||||||
|
|
||||||
dispatcher.dispatchError( event, request.getBaseDirectory(), e );
|
|
||||||
|
|
||||||
throw new MavenExecutionException( "Error executing project within the reactor", e );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeReactorSummary( ReactorManager rm )
|
private MavenProject getSuperProject( MavenExecutionRequest request )
|
||||||
|
throws MavenExecutionException
|
||||||
{
|
{
|
||||||
// -------------------------
|
MavenProject superProject;
|
||||||
// Reactor Summary:
|
try
|
||||||
// -------------------------
|
|
||||||
// o project-name...........FAILED
|
|
||||||
// o project2-name..........SKIPPED (dependency build failed or was skipped)
|
|
||||||
// o project-3-name.........SUCCESS
|
|
||||||
|
|
||||||
line();
|
|
||||||
getLogger().info( "Reactor Summary:" );
|
|
||||||
line();
|
|
||||||
|
|
||||||
for ( Iterator it = rm.getSortedProjects().iterator(); it.hasNext(); )
|
|
||||||
{
|
{
|
||||||
MavenProject project = (MavenProject) it.next();
|
superProject = projectBuilder.buildStandaloneSuperProject( request.getLocalRepository() );
|
||||||
|
|
||||||
if ( rm.hasBuildFailure( project ) )
|
|
||||||
{
|
|
||||||
logReactorSummaryLine( project.getName(), "FAILED", rm.getBuildFailure( project ).getTime() );
|
|
||||||
}
|
|
||||||
else if ( rm.isBlackListed( project ) )
|
|
||||||
{
|
|
||||||
logReactorSummaryLine( project.getName(), "SKIPPED (dependency build failed or was skipped)" );
|
|
||||||
}
|
|
||||||
else if ( rm.hasBuildSuccess( project ) )
|
|
||||||
{
|
|
||||||
logReactorSummaryLine( project.getName(), "SUCCESS", rm.getBuildSuccess( project ).getTime() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
logReactorSummaryLine( project.getName(), "NOT BUILT" );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
catch ( ProjectBuildingException e )
|
||||||
|
{
|
||||||
|
throw new MavenExecutionException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
return superProject;
|
||||||
|
}
|
||||||
|
|
||||||
getLogger().info( "" );
|
private List getProjects( MavenExecutionRequest request, ProfileManager globalProfileManager )
|
||||||
getLogger().info( "" );
|
throws MavenExecutionException, BuildFailureException
|
||||||
|
{
|
||||||
|
List projects;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List files = getProjectFiles( request );
|
||||||
|
|
||||||
|
projects = collectProjects( files, request.getLocalRepository(), request.isRecursive(),
|
||||||
|
request.getSettings(), globalProfileManager, !request.isReactorActive() );
|
||||||
|
|
||||||
|
}
|
||||||
|
catch ( IOException e )
|
||||||
|
{
|
||||||
|
throw new MavenExecutionException( "Error processing projects for the reactor: " + e.getMessage(), e );
|
||||||
|
}
|
||||||
|
catch ( ArtifactResolutionException e )
|
||||||
|
{
|
||||||
|
throw new MavenExecutionException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
catch ( ProjectBuildingException e )
|
||||||
|
{
|
||||||
|
throw new MavenExecutionException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
catch ( ProfileActivationException e )
|
||||||
|
{
|
||||||
|
throw new MavenExecutionException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
return projects;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logReactorSummaryLine( String name, String status )
|
private void logReactorSummaryLine( String name, String status )
|
||||||
|
@ -396,20 +394,6 @@ public class DefaultMaven
|
||||||
return fmt.format( new Date( time ) );
|
return fmt.format( new Date( time ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
private MavenExecutionResponse dispatchErrorResponse( EventDispatcher dispatcher, String event,
|
|
||||||
String baseDirectory, Exception e )
|
|
||||||
{
|
|
||||||
dispatcher.dispatchError( event, baseDirectory, e );
|
|
||||||
|
|
||||||
MavenExecutionResponse response = new MavenExecutionResponse();
|
|
||||||
response.setStart( new Date() );
|
|
||||||
response.setFinish( new Date() );
|
|
||||||
response.setException( e );
|
|
||||||
logError( response );
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List collectProjects( List files, ArtifactRepository localRepository, boolean recursive, Settings settings,
|
private List collectProjects( List files, ArtifactRepository localRepository, boolean recursive, Settings settings,
|
||||||
ProfileManager globalProfileManager, boolean isRoot )
|
ProfileManager globalProfileManager, boolean isRoot )
|
||||||
throws ArtifactResolutionException, ProjectBuildingException, ProfileActivationException,
|
throws ArtifactResolutionException, ProjectBuildingException, ProfileActivationException,
|
||||||
|
@ -606,134 +590,141 @@ public class DefaultMaven
|
||||||
{
|
{
|
||||||
line();
|
line();
|
||||||
|
|
||||||
getLogger().error( "FATAL ERROR" );
|
getLogger().info( "FATAL ERROR" );
|
||||||
|
|
||||||
line();
|
line();
|
||||||
|
|
||||||
diagnoseError( error );
|
logDiagnostics( error );
|
||||||
|
|
||||||
line();
|
logTrace( error, true );
|
||||||
|
|
||||||
getLogger().error( "FATAL ERROR" );
|
|
||||||
|
|
||||||
line();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void logError( MavenExecutionResponse r )
|
protected void logError( Exception e, boolean showErrors )
|
||||||
{
|
{
|
||||||
line();
|
line();
|
||||||
|
|
||||||
getLogger().error( "BUILD ERROR" );
|
getLogger().info( "BUILD ERROR" );
|
||||||
|
|
||||||
line();
|
line();
|
||||||
|
|
||||||
diagnoseError( r.getException() );
|
logDiagnostics( e );
|
||||||
|
|
||||||
line();
|
logTrace( e, showErrors );
|
||||||
|
|
||||||
getLogger().error( "BUILD ERROR" );
|
|
||||||
|
|
||||||
line();
|
|
||||||
|
|
||||||
stats( r.getStart(), r.getFinish() );
|
|
||||||
|
|
||||||
line();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void diagnoseError( Throwable error )
|
protected void logFailure( BuildFailureException e, boolean showErrors )
|
||||||
{
|
{
|
||||||
String message = null;
|
|
||||||
if ( errorDiagnostics != null )
|
|
||||||
{
|
|
||||||
message = errorDiagnostics.diagnose( error );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( message == null )
|
|
||||||
{
|
|
||||||
message = error.getMessage();
|
|
||||||
}
|
|
||||||
|
|
||||||
getLogger().info( "Diagnosis: " + message );
|
|
||||||
|
|
||||||
line();
|
|
||||||
|
|
||||||
// TODO: needs to honour -e
|
|
||||||
if ( getLogger().isDebugEnabled() )
|
|
||||||
{
|
|
||||||
getLogger().debug( "Trace:\n", error );
|
|
||||||
|
|
||||||
line();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void logFailure( MavenExecutionResponse r, ReactorManager rm, Throwable error, String longMessage )
|
|
||||||
{
|
|
||||||
if ( rm.hasMultipleProjects() && r.executedMultipleProjects() )
|
|
||||||
{
|
|
||||||
writeReactorSummary( rm );
|
|
||||||
}
|
|
||||||
line();
|
line();
|
||||||
|
|
||||||
getLogger().info( "BUILD FAILURE" );
|
getLogger().info( "BUILD FAILURE" );
|
||||||
|
|
||||||
line();
|
line();
|
||||||
|
|
||||||
|
logDiagnostics( e );
|
||||||
|
|
||||||
|
if ( e.getLongMessage() != null )
|
||||||
|
{
|
||||||
|
getLogger().info( e.getLongMessage() );
|
||||||
|
|
||||||
|
line();
|
||||||
|
}
|
||||||
|
|
||||||
|
logTrace( e, showErrors );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void logTrace( Throwable t, boolean showErrors )
|
||||||
|
{
|
||||||
|
if ( getLogger().isDebugEnabled() )
|
||||||
|
{
|
||||||
|
getLogger().debug( "Trace", t );
|
||||||
|
|
||||||
|
line();
|
||||||
|
}
|
||||||
|
else if ( showErrors )
|
||||||
|
{
|
||||||
|
getLogger().error( "Trace", t );
|
||||||
|
|
||||||
|
line();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getLogger().info( "For more information, run Maven with the -e switch" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void logDiagnostics( Throwable t )
|
||||||
|
{
|
||||||
String message = null;
|
String message = null;
|
||||||
if ( errorDiagnostics != null )
|
if ( errorDiagnostics != null )
|
||||||
{
|
{
|
||||||
message = errorDiagnostics.diagnose( error );
|
message = errorDiagnostics.diagnose( t );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( message == null )
|
if ( message == null )
|
||||||
{
|
{
|
||||||
message = "Reason: " + error.getMessage();
|
message = t.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
getLogger().info( message );
|
getLogger().error( message );
|
||||||
|
|
||||||
line();
|
|
||||||
|
|
||||||
if ( longMessage != null )
|
|
||||||
{
|
|
||||||
getLogger().info( longMessage );
|
|
||||||
|
|
||||||
line();
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: needs to honour -e
|
|
||||||
if ( getLogger().isDebugEnabled() )
|
|
||||||
{
|
|
||||||
getLogger().debug( "Trace", error );
|
|
||||||
|
|
||||||
line();
|
|
||||||
}
|
|
||||||
|
|
||||||
stats( r.getStart(), r.getFinish() );
|
|
||||||
|
|
||||||
line();
|
line();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void logSuccess( MavenExecutionResponse r, ReactorManager rm )
|
protected void logSuccess( ReactorManager rm )
|
||||||
{
|
{
|
||||||
if ( rm.hasMultipleProjects() && r.executedMultipleProjects() )
|
|
||||||
{
|
|
||||||
writeReactorSummary( rm );
|
|
||||||
}
|
|
||||||
|
|
||||||
line();
|
line();
|
||||||
|
|
||||||
getLogger().info( "BUILD SUCCESSFUL" );
|
getLogger().info( "BUILD SUCCESSFUL" );
|
||||||
|
|
||||||
line();
|
line();
|
||||||
|
|
||||||
stats( r.getStart(), r.getFinish() );
|
|
||||||
|
|
||||||
line();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void stats( Date start, Date finish )
|
private void logReactorSummary( ReactorManager rm )
|
||||||
{
|
{
|
||||||
|
if ( rm.hasMultipleProjects() && rm.executedMultipleProjects() )
|
||||||
|
{
|
||||||
|
// -------------------------
|
||||||
|
// Reactor Summary:
|
||||||
|
// -------------------------
|
||||||
|
// o project-name...........FAILED
|
||||||
|
// o project2-name..........SKIPPED (dependency build failed or was skipped)
|
||||||
|
// o project-3-name.........SUCCESS
|
||||||
|
|
||||||
|
line();
|
||||||
|
getLogger().info( "Reactor Summary:" );
|
||||||
|
line();
|
||||||
|
|
||||||
|
for ( Iterator it = rm.getSortedProjects().iterator(); it.hasNext(); )
|
||||||
|
{
|
||||||
|
MavenProject project = (MavenProject) it.next();
|
||||||
|
|
||||||
|
if ( rm.hasBuildFailure( project ) )
|
||||||
|
{
|
||||||
|
logReactorSummaryLine( project.getName(), "FAILED", rm.getBuildFailure( project ).getTime() );
|
||||||
|
}
|
||||||
|
else if ( rm.isBlackListed( project ) )
|
||||||
|
{
|
||||||
|
logReactorSummaryLine( project.getName(), "SKIPPED (dependency build failed or was skipped)" );
|
||||||
|
}
|
||||||
|
else if ( rm.hasBuildSuccess( project ) )
|
||||||
|
{
|
||||||
|
logReactorSummaryLine( project.getName(), "SUCCESS", rm.getBuildSuccess( project ).getTime() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logReactorSummaryLine( project.getName(), "NOT BUILT" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getLogger().info( "" );
|
||||||
|
getLogger().info( "" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void stats( Date start )
|
||||||
|
{
|
||||||
|
Date finish = new Date();
|
||||||
|
|
||||||
long time = finish.getTime() - start.getTime();
|
long time = finish.getTime() - start.getTime();
|
||||||
|
|
||||||
getLogger().info( "Total time: " + formatTime( time ) );
|
getLogger().info( "Total time: " + formatTime( time ) );
|
||||||
|
@ -793,6 +784,7 @@ public class DefaultMaven
|
||||||
{
|
{
|
||||||
List files = Collections.EMPTY_LIST;
|
List files = Collections.EMPTY_LIST;
|
||||||
|
|
||||||
|
File userDir = new File( System.getProperty( "user.dir" ) );
|
||||||
if ( request.isReactorActive() )
|
if ( request.isReactorActive() )
|
||||||
{
|
{
|
||||||
// TODO: should we now include the pom.xml in the current directory?
|
// TODO: should we now include the pom.xml in the current directory?
|
||||||
|
|
|
@ -17,7 +17,6 @@ package org.apache.maven;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.execution.MavenExecutionRequest;
|
import org.apache.maven.execution.MavenExecutionRequest;
|
||||||
import org.apache.maven.execution.MavenExecutionResponse;
|
|
||||||
import org.apache.maven.reactor.MavenExecutionException;
|
import org.apache.maven.reactor.MavenExecutionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,6 +31,6 @@ public interface Maven
|
||||||
|
|
||||||
String RELEASE_POMv4 = "release-pom.xml";
|
String RELEASE_POMv4 = "release-pom.xml";
|
||||||
|
|
||||||
MavenExecutionResponse execute( MavenExecutionRequest request )
|
void execute( MavenExecutionRequest request )
|
||||||
throws MavenExecutionException, SettingsConfigurationException;
|
throws MavenExecutionException;
|
||||||
}
|
}
|
|
@ -33,7 +33,6 @@ import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
||||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||||
import org.apache.maven.execution.DefaultMavenExecutionRequest;
|
import org.apache.maven.execution.DefaultMavenExecutionRequest;
|
||||||
import org.apache.maven.execution.MavenExecutionRequest;
|
import org.apache.maven.execution.MavenExecutionRequest;
|
||||||
import org.apache.maven.execution.MavenExecutionResponse;
|
|
||||||
import org.apache.maven.execution.ReactorManager;
|
import org.apache.maven.execution.ReactorManager;
|
||||||
import org.apache.maven.monitor.event.DefaultEventDispatcher;
|
import org.apache.maven.monitor.event.DefaultEventDispatcher;
|
||||||
import org.apache.maven.monitor.event.DefaultEventMonitor;
|
import org.apache.maven.monitor.event.DefaultEventMonitor;
|
||||||
|
@ -218,7 +217,7 @@ public class MavenCli
|
||||||
}
|
}
|
||||||
|
|
||||||
request = createRequest( commandLine, settings, eventDispatcher, loggerManager, profileManager,
|
request = createRequest( commandLine, settings, eventDispatcher, loggerManager, profileManager,
|
||||||
executionProperties );
|
executionProperties, showErrors );
|
||||||
|
|
||||||
setProjectFileOptions( commandLine, request );
|
setProjectFileOptions( commandLine, request );
|
||||||
|
|
||||||
|
@ -245,30 +244,16 @@ public class MavenCli
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MavenExecutionResponse response;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
response = maven.execute( request );
|
maven.execute( request );
|
||||||
}
|
}
|
||||||
catch ( MavenExecutionException e )
|
catch ( MavenExecutionException e )
|
||||||
{
|
{
|
||||||
showFatalError( "Error executing Maven for a project", e, showErrors );
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
catch ( SettingsConfigurationException e )
|
|
||||||
{
|
|
||||||
showError( e.getMessage(), e, showErrors );
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( response != null && response.isExecutionFailure() )
|
return 0;
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Settings buildSettings( CommandLine commandLine )
|
private static Settings buildSettings( CommandLine commandLine )
|
||||||
|
@ -382,7 +367,8 @@ public class MavenCli
|
||||||
|
|
||||||
private static MavenExecutionRequest createRequest( CommandLine commandLine, Settings settings,
|
private static MavenExecutionRequest createRequest( CommandLine commandLine, Settings settings,
|
||||||
EventDispatcher eventDispatcher, LoggerManager loggerManager,
|
EventDispatcher eventDispatcher, LoggerManager loggerManager,
|
||||||
ProfileManager profileManager, Properties executionProperties )
|
ProfileManager profileManager, Properties executionProperties,
|
||||||
|
boolean showErrors )
|
||||||
throws ComponentLookupException
|
throws ComponentLookupException
|
||||||
{
|
{
|
||||||
MavenExecutionRequest request;
|
MavenExecutionRequest request;
|
||||||
|
@ -393,7 +379,7 @@ public class MavenCli
|
||||||
|
|
||||||
request = new DefaultMavenExecutionRequest( localRepository, settings, eventDispatcher,
|
request = new DefaultMavenExecutionRequest( localRepository, settings, eventDispatcher,
|
||||||
commandLine.getArgList(), userDir.getPath(), profileManager,
|
commandLine.getArgList(), userDir.getPath(), profileManager,
|
||||||
executionProperties );
|
executionProperties, showErrors );
|
||||||
|
|
||||||
// TODO [BP]: do we set one per mojo? where to do it?
|
// TODO [BP]: do we set one per mojo? where to do it?
|
||||||
Logger logger = loggerManager.getLoggerForComponent( Mojo.ROLE );
|
Logger logger = loggerManager.getLoggerForComponent( Mojo.ROLE );
|
||||||
|
|
|
@ -37,12 +37,12 @@ public class BuildFailure
|
||||||
this.time = time;
|
this.time = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getTask()
|
public String getTask()
|
||||||
{
|
{
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
|
||||||
Exception getCause()
|
public Exception getCause()
|
||||||
{
|
{
|
||||||
return cause;
|
return cause;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,9 +62,12 @@ public class DefaultMavenExecutionRequest
|
||||||
|
|
||||||
private final Date startTime;
|
private final Date startTime;
|
||||||
|
|
||||||
|
private final boolean showErrors;
|
||||||
|
|
||||||
public DefaultMavenExecutionRequest( ArtifactRepository localRepository, Settings settings,
|
public DefaultMavenExecutionRequest( ArtifactRepository localRepository, Settings settings,
|
||||||
EventDispatcher eventDispatcher, List goals, String baseDirectory,
|
EventDispatcher eventDispatcher, List goals, String baseDirectory,
|
||||||
ProfileManager globalProfileManager, Properties executionProperties )
|
ProfileManager globalProfileManager, Properties executionProperties,
|
||||||
|
boolean showErrors )
|
||||||
{
|
{
|
||||||
this.localRepository = localRepository;
|
this.localRepository = localRepository;
|
||||||
|
|
||||||
|
@ -81,6 +84,8 @@ public class DefaultMavenExecutionRequest
|
||||||
this.executionProperties = executionProperties;
|
this.executionProperties = executionProperties;
|
||||||
|
|
||||||
this.startTime = new Date();
|
this.startTime = new Date();
|
||||||
|
|
||||||
|
this.showErrors = showErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Settings getSettings()
|
public Settings getSettings()
|
||||||
|
@ -181,4 +186,9 @@ public class DefaultMavenExecutionRequest
|
||||||
{
|
{
|
||||||
return startTime;
|
return startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isShowErrors()
|
||||||
|
{
|
||||||
|
return showErrors;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,4 +69,6 @@ public interface MavenExecutionRequest
|
||||||
Properties getExecutionProperties();
|
Properties getExecutionProperties();
|
||||||
|
|
||||||
Date getStartTime();
|
Date getStartTime();
|
||||||
|
|
||||||
|
boolean isShowErrors();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,91 +0,0 @@
|
||||||
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 java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
|
||||||
* @version $Id$
|
|
||||||
*/
|
|
||||||
public class MavenExecutionResponse
|
|
||||||
{
|
|
||||||
private Throwable exception;
|
|
||||||
|
|
||||||
private Date start;
|
|
||||||
|
|
||||||
private Date finish;
|
|
||||||
|
|
||||||
private boolean executedMultipleProjects;
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Execution failure
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
public boolean isExecutionFailure()
|
|
||||||
{
|
|
||||||
return exception != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Error
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
public Throwable getException()
|
|
||||||
{
|
|
||||||
return exception;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setException( Throwable exception )
|
|
||||||
{
|
|
||||||
this.exception = exception;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Timing
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
public Date getStart()
|
|
||||||
{
|
|
||||||
return start;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStart( Date start )
|
|
||||||
{
|
|
||||||
this.start = start;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getFinish()
|
|
||||||
{
|
|
||||||
return finish;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFinish( Date finish )
|
|
||||||
{
|
|
||||||
this.finish = finish;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean executedMultipleProjects()
|
|
||||||
{
|
|
||||||
return executedMultipleProjects;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExecutedMultipleProjects( boolean executedMultipleProjects )
|
|
||||||
{
|
|
||||||
this.executedMultipleProjects = executedMultipleProjects;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -50,7 +50,7 @@ public class MavenSession
|
||||||
|
|
||||||
private final String executionRootDir;
|
private final String executionRootDir;
|
||||||
|
|
||||||
private boolean usingPOMsFromFilesystem;
|
private boolean usingPOMsFromFilesystem = true;
|
||||||
|
|
||||||
private final Properties executionProperties;
|
private final Properties executionProperties;
|
||||||
|
|
||||||
|
|
|
@ -183,4 +183,8 @@ public class ReactorManager
|
||||||
return (BuildSuccess) buildSuccessesByProject.get( getProjectKey( project ) );
|
return (BuildSuccess) buildSuccessesByProject.get( getProjectKey( project ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean executedMultipleProjects()
|
||||||
|
{
|
||||||
|
return buildFailuresByProject.size() + buildSuccessesByProject.size() > 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||||
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
|
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
|
||||||
import org.apache.maven.execution.MavenExecutionResponse;
|
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.execution.ReactorManager;
|
import org.apache.maven.execution.ReactorManager;
|
||||||
import org.apache.maven.extension.ExtensionManager;
|
import org.apache.maven.extension.ExtensionManager;
|
||||||
|
@ -47,6 +46,7 @@ import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||||
import org.apache.maven.plugin.lifecycle.Execution;
|
import org.apache.maven.plugin.lifecycle.Execution;
|
||||||
import org.apache.maven.plugin.lifecycle.Phase;
|
import org.apache.maven.plugin.lifecycle.Phase;
|
||||||
|
import org.apache.maven.plugin.version.PluginVersionNotFoundException;
|
||||||
import org.apache.maven.plugin.version.PluginVersionResolutionException;
|
import org.apache.maven.plugin.version.PluginVersionResolutionException;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||||
|
@ -61,7 +61,6 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -107,8 +106,8 @@ public class DefaultLifecycleExecutor
|
||||||
* @param rm
|
* @param rm
|
||||||
* @param dispatcher
|
* @param dispatcher
|
||||||
*/
|
*/
|
||||||
public MavenExecutionResponse execute( MavenSession session, ReactorManager rm, EventDispatcher dispatcher )
|
public void execute( MavenSession session, ReactorManager rm, EventDispatcher dispatcher )
|
||||||
throws LifecycleExecutionException
|
throws BuildFailureException, LifecycleExecutionException
|
||||||
{
|
{
|
||||||
// TODO: This is dangerous, particularly when it's just a collection of loose-leaf projects being built
|
// TODO: This is dangerous, particularly when it's just a collection of loose-leaf projects being built
|
||||||
// within the same reactor (using an inclusion pattern to gather them up)...
|
// within the same reactor (using an inclusion pattern to gather them up)...
|
||||||
|
@ -125,65 +124,21 @@ public class DefaultLifecycleExecutor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MavenExecutionResponse response = new MavenExecutionResponse();
|
if ( goals.isEmpty() )
|
||||||
|
|
||||||
response.setStart( session.getStartTime() );
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
if ( goals.isEmpty() )
|
throw new BuildFailureException( "You must specify at least one goal. Try 'install'" );
|
||||||
{
|
|
||||||
// TODO: delete
|
|
||||||
throw new NoGoalsSpecifiedException( "You must specify at least one goal. Try 'install'" );
|
|
||||||
}
|
|
||||||
|
|
||||||
List taskSegments = segmentTaskListByAggregationNeeds( goals, session, rootProject );
|
|
||||||
|
|
||||||
// TODO: probably don't want to do all this up front
|
|
||||||
findExtensions( session );
|
|
||||||
|
|
||||||
executeTaskSegments( taskSegments, rm, session, rootProject, dispatcher, response );
|
|
||||||
|
|
||||||
if ( ReactorManager.FAIL_AT_END.equals( rm.getFailureBehavior() ) && rm.hasBuildFailures() )
|
|
||||||
{
|
|
||||||
response.setException( new BuildFailureException( "One or more projects failed to build." ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch ( MojoExecutionException e )
|
|
||||||
{
|
|
||||||
response.setException( e );
|
|
||||||
}
|
|
||||||
catch ( ArtifactNotFoundException e )
|
|
||||||
{
|
|
||||||
response.setException( e );
|
|
||||||
}
|
|
||||||
catch ( ArtifactResolutionException e )
|
|
||||||
{
|
|
||||||
response.setException( e );
|
|
||||||
}
|
|
||||||
catch ( NoGoalsSpecifiedException e )
|
|
||||||
{
|
|
||||||
response.setException( e );
|
|
||||||
}
|
|
||||||
catch ( MojoFailureException e )
|
|
||||||
{
|
|
||||||
response.setException( e );
|
|
||||||
}
|
|
||||||
catch ( PluginNotFoundException e )
|
|
||||||
{
|
|
||||||
response.setException( e );
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
response.setFinish( new Date() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
List taskSegments = segmentTaskListByAggregationNeeds( goals, session, rootProject );
|
||||||
|
|
||||||
|
// TODO: probably don't want to do all this up front
|
||||||
|
findExtensions( session );
|
||||||
|
|
||||||
|
executeTaskSegments( taskSegments, rm, session, rootProject, dispatcher );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void findExtensions( MavenSession session )
|
private void findExtensions( MavenSession session )
|
||||||
throws ArtifactNotFoundException, ArtifactResolutionException, LifecycleExecutionException,
|
throws LifecycleExecutionException
|
||||||
PluginNotFoundException
|
|
||||||
{
|
{
|
||||||
for ( Iterator i = session.getSortedProjects().iterator(); i.hasNext(); )
|
for ( Iterator i = session.getSortedProjects().iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
|
@ -200,18 +155,31 @@ public class DefaultLifecycleExecutor
|
||||||
{
|
{
|
||||||
throw new LifecycleExecutionException( "Unable to initialise extensions", e );
|
throw new LifecycleExecutionException( "Unable to initialise extensions", e );
|
||||||
}
|
}
|
||||||
|
catch ( ArtifactResolutionException e )
|
||||||
|
{
|
||||||
|
throw new LifecycleExecutionException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
catch ( ArtifactNotFoundException e )
|
||||||
|
{
|
||||||
|
throw new LifecycleExecutionException( e.getMessage(), e );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Map handlers = findArtifactTypeHandlers( project, session.getSettings(), session.getLocalRepository() );
|
try
|
||||||
artifactHandlerManager.addHandlers( handlers );
|
{
|
||||||
|
Map handlers = findArtifactTypeHandlers( project, session.getSettings(), session.getLocalRepository() );
|
||||||
|
artifactHandlerManager.addHandlers( handlers );
|
||||||
|
}
|
||||||
|
catch ( PluginNotFoundException e )
|
||||||
|
{
|
||||||
|
throw new LifecycleExecutionException( e.getMessage(), e );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeTaskSegments( List taskSegments, ReactorManager rm, MavenSession session,
|
private void executeTaskSegments( List taskSegments, ReactorManager rm, MavenSession session,
|
||||||
MavenProject rootProject, EventDispatcher dispatcher,
|
MavenProject rootProject, EventDispatcher dispatcher )
|
||||||
MavenExecutionResponse response )
|
throws LifecycleExecutionException, BuildFailureException
|
||||||
throws ArtifactNotFoundException, MojoExecutionException, LifecycleExecutionException, MojoFailureException,
|
|
||||||
ArtifactResolutionException, PluginNotFoundException
|
|
||||||
{
|
{
|
||||||
for ( Iterator it = taskSegments.iterator(); it.hasNext(); )
|
for ( Iterator it = taskSegments.iterator(); it.hasNext(); )
|
||||||
{
|
{
|
||||||
|
@ -238,27 +206,18 @@ public class DefaultLifecycleExecutor
|
||||||
String target = rootProject.getId() + " ( " + segment + " )";
|
String target = rootProject.getId() + " ( " + segment + " )";
|
||||||
dispatcher.dispatchStart( event, target );
|
dispatcher.dispatchStart( event, target );
|
||||||
|
|
||||||
try
|
// only call once, with the top-level project (assumed to be provided as a parameter)...
|
||||||
|
for ( Iterator goalIterator = segment.getTasks().iterator(); goalIterator.hasNext(); )
|
||||||
{
|
{
|
||||||
// only call once, with the top-level project (assumed to be provided as a parameter)...
|
String task = (String) goalIterator.next();
|
||||||
for ( Iterator goalIterator = segment.getTasks().iterator(); goalIterator.hasNext(); )
|
|
||||||
{
|
|
||||||
String task = (String) goalIterator.next();
|
|
||||||
|
|
||||||
executeGoalAndHandleFailures( task, session, rootProject, response, dispatcher, event, rm,
|
executeGoalAndHandleFailures( task, session, rootProject, dispatcher, event, rm, buildStartTime,
|
||||||
buildStartTime, target );
|
target );
|
||||||
}
|
|
||||||
|
|
||||||
rm.registerBuildSuccess( rootProject, System.currentTimeMillis() - buildStartTime );
|
|
||||||
|
|
||||||
dispatcher.dispatchEnd( event, target );
|
|
||||||
}
|
}
|
||||||
catch ( LifecycleExecutionException e )
|
|
||||||
{
|
|
||||||
dispatcher.dispatchError( event, target, e );
|
|
||||||
|
|
||||||
throw e;
|
rm.registerBuildSuccess( rootProject, System.currentTimeMillis() - buildStartTime );
|
||||||
}
|
|
||||||
|
dispatcher.dispatchEnd( event, target );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -278,8 +237,6 @@ public class DefaultLifecycleExecutor
|
||||||
{
|
{
|
||||||
List sortedProjects = session.getSortedProjects();
|
List sortedProjects = session.getSortedProjects();
|
||||||
|
|
||||||
response.setExecutedMultipleProjects( true );
|
|
||||||
|
|
||||||
// iterate over projects, and execute on each...
|
// iterate over projects, and execute on each...
|
||||||
for ( Iterator projectIterator = sortedProjects.iterator(); projectIterator.hasNext(); )
|
for ( Iterator projectIterator = sortedProjects.iterator(); projectIterator.hasNext(); )
|
||||||
{
|
{
|
||||||
|
@ -304,26 +261,17 @@ public class DefaultLifecycleExecutor
|
||||||
String target = currentProject.getId() + " ( " + segment + " )";
|
String target = currentProject.getId() + " ( " + segment + " )";
|
||||||
dispatcher.dispatchStart( event, target );
|
dispatcher.dispatchStart( event, target );
|
||||||
|
|
||||||
try
|
for ( Iterator goalIterator = segment.getTasks().iterator(); goalIterator.hasNext(); )
|
||||||
{
|
{
|
||||||
for ( Iterator goalIterator = segment.getTasks().iterator(); goalIterator.hasNext(); )
|
String task = (String) goalIterator.next();
|
||||||
{
|
|
||||||
String task = (String) goalIterator.next();
|
|
||||||
|
|
||||||
executeGoalAndHandleFailures( task, session, currentProject, response, dispatcher,
|
executeGoalAndHandleFailures( task, session, currentProject, dispatcher, event, rm,
|
||||||
event, rm, buildStartTime, target );
|
buildStartTime, target );
|
||||||
}
|
|
||||||
|
|
||||||
rm.registerBuildSuccess( currentProject, System.currentTimeMillis() - buildStartTime );
|
|
||||||
|
|
||||||
dispatcher.dispatchEnd( event, target );
|
|
||||||
}
|
}
|
||||||
catch ( LifecycleExecutionException e )
|
|
||||||
{
|
|
||||||
dispatcher.dispatchError( event, target, e );
|
|
||||||
|
|
||||||
throw e;
|
rm.registerBuildSuccess( currentProject, System.currentTimeMillis() - buildStartTime );
|
||||||
}
|
|
||||||
|
dispatcher.dispatchEnd( event, target );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -344,93 +292,52 @@ public class DefaultLifecycleExecutor
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeGoalAndHandleFailures( String task, MavenSession session, MavenProject project,
|
private void executeGoalAndHandleFailures( String task, MavenSession session, MavenProject project,
|
||||||
MavenExecutionResponse response, EventDispatcher dispatcher,
|
EventDispatcher dispatcher, String event, ReactorManager rm,
|
||||||
String event, ReactorManager rm, long buildStartTime, String target )
|
long buildStartTime, String target )
|
||||||
throws LifecycleExecutionException, MojoExecutionException, MojoFailureException, ArtifactNotFoundException,
|
throws BuildFailureException, LifecycleExecutionException
|
||||||
ArtifactResolutionException, PluginNotFoundException
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
executeGoal( task, session, project, response );
|
executeGoal( task, session, project );
|
||||||
}
|
}
|
||||||
catch ( MojoExecutionException e )
|
catch ( LifecycleExecutionException e )
|
||||||
{
|
{
|
||||||
dispatcher.dispatchError( event, target, e );
|
dispatcher.dispatchError( event, target, e );
|
||||||
|
|
||||||
handleExecutionFailure( rm, project, e, task, buildStartTime );
|
if ( handleExecutionFailure( rm, project, e, task, buildStartTime ) )
|
||||||
|
{
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch ( ArtifactResolutionException e )
|
catch ( BuildFailureException e )
|
||||||
{
|
{
|
||||||
dispatcher.dispatchError( event, target, e );
|
dispatcher.dispatchError( event, target, e );
|
||||||
|
|
||||||
handleExecutionFailure( rm, project, e, task, buildStartTime );
|
if ( handleExecutionFailure( rm, project, e, task, buildStartTime ) )
|
||||||
}
|
{
|
||||||
catch ( MojoFailureException e )
|
throw e;
|
||||||
{
|
}
|
||||||
// TODO: should be dispatchFailure?
|
|
||||||
dispatcher.dispatchError( event, target, e );
|
|
||||||
|
|
||||||
handleExecutionFailure( rm, project, e, task, buildStartTime );
|
|
||||||
}
|
|
||||||
catch ( ArtifactNotFoundException e )
|
|
||||||
{
|
|
||||||
// TODO: should be dispatchFailure?
|
|
||||||
dispatcher.dispatchError( event, target, e );
|
|
||||||
|
|
||||||
handleExecutionFailure( rm, project, e, task, buildStartTime );
|
|
||||||
}
|
|
||||||
catch ( InvalidDependencyVersionException e )
|
|
||||||
{
|
|
||||||
// TODO: should be dispatchFailure?
|
|
||||||
dispatcher.dispatchError( event, target, e );
|
|
||||||
|
|
||||||
handleExecutionFailure( rm, project, e, task, buildStartTime );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleExecutionFailure( ReactorManager rm, MavenProject project, Exception e, String task,
|
private boolean handleExecutionFailure( ReactorManager rm, MavenProject project, Exception e, String task,
|
||||||
long buildStartTime )
|
long buildStartTime )
|
||||||
throws MojoExecutionException, MojoFailureException, ArtifactNotFoundException, ArtifactResolutionException
|
|
||||||
{
|
{
|
||||||
|
rm.registerBuildFailure( project, e, task, System.currentTimeMillis() - buildStartTime );
|
||||||
|
|
||||||
if ( ReactorManager.FAIL_FAST.equals( rm.getFailureBehavior() ) )
|
if ( ReactorManager.FAIL_FAST.equals( rm.getFailureBehavior() ) )
|
||||||
{
|
{
|
||||||
rm.registerBuildFailure( project, e, task, System.currentTimeMillis() - buildStartTime );
|
return true;
|
||||||
|
|
||||||
if ( e instanceof MojoExecutionException )
|
|
||||||
{
|
|
||||||
throw (MojoExecutionException) e;
|
|
||||||
}
|
|
||||||
if ( e instanceof MojoFailureException )
|
|
||||||
{
|
|
||||||
throw (MojoFailureException) e;
|
|
||||||
}
|
|
||||||
else if ( e instanceof ArtifactNotFoundException )
|
|
||||||
{
|
|
||||||
throw (ArtifactNotFoundException) e;
|
|
||||||
}
|
|
||||||
else if ( e instanceof ArtifactResolutionException )
|
|
||||||
{
|
|
||||||
throw (ArtifactResolutionException) e;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getLogger().error( "Attempt to register inappropriate build-failure Exception.", e );
|
|
||||||
|
|
||||||
throw new IllegalArgumentException( "Inappropriate build-failure Exception: " + e );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if ( ReactorManager.FAIL_AT_END.equals( rm.getFailureBehavior() ) )
|
else if ( ReactorManager.FAIL_AT_END.equals( rm.getFailureBehavior() ) )
|
||||||
{
|
{
|
||||||
rm.registerBuildFailure( project, e, task, System.currentTimeMillis() - buildStartTime );
|
|
||||||
|
|
||||||
rm.blackList( project );
|
rm.blackList( project );
|
||||||
}
|
}
|
||||||
// FIXME: how about the other cases?
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List segmentTaskListByAggregationNeeds( List tasks, MavenSession session, MavenProject project )
|
private List segmentTaskListByAggregationNeeds( List tasks, MavenSession session, MavenProject project )
|
||||||
throws LifecycleExecutionException, ArtifactNotFoundException, PluginNotFoundException,
|
throws LifecycleExecutionException, BuildFailureException
|
||||||
ArtifactResolutionException
|
|
||||||
{
|
{
|
||||||
List segments = new ArrayList();
|
List segments = new ArrayList();
|
||||||
|
|
||||||
|
@ -526,34 +433,39 @@ public class DefaultLifecycleExecutor
|
||||||
return segments;
|
return segments;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeGoal( String task, MavenSession session, MavenProject project, MavenExecutionResponse response )
|
private void executeGoal( String task, MavenSession session, MavenProject project )
|
||||||
throws LifecycleExecutionException, ArtifactNotFoundException, MojoExecutionException,
|
throws LifecycleExecutionException, BuildFailureException
|
||||||
ArtifactResolutionException, MojoFailureException, InvalidDependencyVersionException, PluginNotFoundException
|
|
||||||
{
|
{
|
||||||
if ( getPhaseToLifecycleMap().containsKey( task ) )
|
try
|
||||||
{
|
{
|
||||||
Lifecycle lifecycle = getLifecycleForPhase( task );
|
if ( getPhaseToLifecycleMap().containsKey( task ) )
|
||||||
|
{
|
||||||
|
Lifecycle lifecycle = getLifecycleForPhase( task );
|
||||||
|
|
||||||
// we have a lifecycle phase, so lets bind all the necessary goals
|
// we have a lifecycle phase, so lets bind all the necessary goals
|
||||||
Map lifecycleMappings = constructLifecycleMappings( session, task, project, lifecycle );
|
Map lifecycleMappings = constructLifecycleMappings( session, task, project, lifecycle );
|
||||||
executeGoalWithLifecycle( task, session, lifecycleMappings, project, response, lifecycle );
|
executeGoalWithLifecycle( task, session, lifecycleMappings, project, lifecycle );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
executeStandaloneGoal( task, session, project );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
catch ( PluginNotFoundException e )
|
||||||
{
|
{
|
||||||
executeStandaloneGoal( task, session, project, response );
|
throw new BuildFailureException( "A required plugin was not found", e.getMessage(), e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeGoalWithLifecycle( String task, MavenSession session, Map lifecycleMappings,
|
private void executeGoalWithLifecycle( String task, MavenSession session, Map lifecycleMappings,
|
||||||
MavenProject project, MavenExecutionResponse response, Lifecycle lifecycle )
|
MavenProject project, Lifecycle lifecycle )
|
||||||
throws ArtifactResolutionException, LifecycleExecutionException, MojoExecutionException, MojoFailureException,
|
throws LifecycleExecutionException, BuildFailureException, PluginNotFoundException
|
||||||
ArtifactNotFoundException, InvalidDependencyVersionException, PluginNotFoundException
|
|
||||||
{
|
{
|
||||||
List goals = processGoalChain( task, lifecycleMappings, lifecycle );
|
List goals = processGoalChain( task, lifecycleMappings, lifecycle );
|
||||||
|
|
||||||
if ( !goals.isEmpty() )
|
if ( !goals.isEmpty() )
|
||||||
{
|
{
|
||||||
executeGoals( goals, session, project, response );
|
executeGoals( goals, session, project );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -561,19 +473,16 @@ public class DefaultLifecycleExecutor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeStandaloneGoal( String task, MavenSession session, MavenProject project,
|
private void executeStandaloneGoal( String task, MavenSession session, MavenProject project )
|
||||||
MavenExecutionResponse response )
|
throws LifecycleExecutionException, BuildFailureException, PluginNotFoundException
|
||||||
throws ArtifactResolutionException, LifecycleExecutionException, MojoExecutionException, MojoFailureException,
|
|
||||||
ArtifactNotFoundException, InvalidDependencyVersionException, PluginNotFoundException
|
|
||||||
{
|
{
|
||||||
// guaranteed to come from the CLI and not be part of a phase
|
// guaranteed to come from the CLI and not be part of a phase
|
||||||
MojoDescriptor mojoDescriptor = getMojoDescriptor( task, session, project, task, true );
|
MojoDescriptor mojoDescriptor = getMojoDescriptor( task, session, project, task, true );
|
||||||
executeGoals( Collections.singletonList( new MojoExecution( mojoDescriptor ) ), session, project, response );
|
executeGoals( Collections.singletonList( new MojoExecution( mojoDescriptor ) ), session, project );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeGoals( List goals, MavenSession session, MavenProject project, MavenExecutionResponse response )
|
private void executeGoals( List goals, MavenSession session, MavenProject project )
|
||||||
throws LifecycleExecutionException, MojoExecutionException, ArtifactResolutionException, MojoFailureException,
|
throws LifecycleExecutionException, BuildFailureException, PluginNotFoundException
|
||||||
ArtifactNotFoundException, InvalidDependencyVersionException, PluginNotFoundException
|
|
||||||
{
|
{
|
||||||
for ( Iterator i = goals.iterator(); i.hasNext(); )
|
for ( Iterator i = goals.iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
|
@ -583,7 +492,7 @@ public class DefaultLifecycleExecutor
|
||||||
|
|
||||||
if ( mojoDescriptor.getExecutePhase() != null || mojoDescriptor.getExecuteGoal() != null )
|
if ( mojoDescriptor.getExecutePhase() != null || mojoDescriptor.getExecuteGoal() != null )
|
||||||
{
|
{
|
||||||
forkLifecycle( mojoDescriptor, session, project, response );
|
forkLifecycle( mojoDescriptor, session, project );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( mojoDescriptor.isRequiresReports() )
|
if ( mojoDescriptor.isRequiresReports() )
|
||||||
|
@ -599,7 +508,7 @@ public class DefaultLifecycleExecutor
|
||||||
|
|
||||||
if ( descriptor.getExecutePhase() != null )
|
if ( descriptor.getExecutePhase() != null )
|
||||||
{
|
{
|
||||||
forkLifecycle( descriptor, session, project, response );
|
forkLifecycle( descriptor, session, project );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -613,12 +522,35 @@ public class DefaultLifecycleExecutor
|
||||||
throw new LifecycleExecutionException( "Internal error in the plugin manager executing goal '" +
|
throw new LifecycleExecutionException( "Internal error in the plugin manager executing goal '" +
|
||||||
mojoDescriptor.getId() + "': " + e.getMessage(), e );
|
mojoDescriptor.getId() + "': " + e.getMessage(), e );
|
||||||
}
|
}
|
||||||
|
catch ( ArtifactNotFoundException e )
|
||||||
|
{
|
||||||
|
throw new LifecycleExecutionException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
catch ( InvalidDependencyVersionException e )
|
||||||
|
{
|
||||||
|
throw new LifecycleExecutionException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
catch ( ArtifactResolutionException e )
|
||||||
|
{
|
||||||
|
throw new LifecycleExecutionException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
catch ( MojoFailureException e )
|
||||||
|
{
|
||||||
|
throw new BuildFailureException( e.getMessage(), e.getLongMessage(), e );
|
||||||
|
}
|
||||||
|
catch ( MojoExecutionException e )
|
||||||
|
{
|
||||||
|
throw new LifecycleExecutionException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
catch ( PluginConfigurationException e )
|
||||||
|
{
|
||||||
|
throw new LifecycleExecutionException( e.getMessage(), e );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List getReports( MavenProject project, MojoExecution mojoExecution, MavenSession session )
|
private List getReports( MavenProject project, MojoExecution mojoExecution, MavenSession session )
|
||||||
throws ArtifactResolutionException, LifecycleExecutionException, ArtifactNotFoundException,
|
throws LifecycleExecutionException, PluginNotFoundException
|
||||||
PluginNotFoundException
|
|
||||||
{
|
{
|
||||||
List reportPlugins = project.getReportPlugins();
|
List reportPlugins = project.getReportPlugins();
|
||||||
|
|
||||||
|
@ -704,8 +636,7 @@ public class DefaultLifecycleExecutor
|
||||||
|
|
||||||
private List getReports( ReportPlugin reportPlugin, ReportSet reportSet, MavenProject project, MavenSession session,
|
private List getReports( ReportPlugin reportPlugin, ReportSet reportSet, MavenProject project, MavenSession session,
|
||||||
MojoExecution mojoExecution )
|
MojoExecution mojoExecution )
|
||||||
throws ArtifactResolutionException, ArtifactNotFoundException, LifecycleExecutionException,
|
throws LifecycleExecutionException, PluginNotFoundException
|
||||||
PluginNotFoundException
|
|
||||||
{
|
{
|
||||||
PluginDescriptor pluginDescriptor = verifyReportPlugin( reportPlugin, project, session );
|
PluginDescriptor pluginDescriptor = verifyReportPlugin( reportPlugin, project, session );
|
||||||
|
|
||||||
|
@ -747,23 +678,27 @@ public class DefaultLifecycleExecutor
|
||||||
throw new LifecycleExecutionException(
|
throw new LifecycleExecutionException(
|
||||||
"Error getting reports from the plugin '" + reportPlugin.getKey() + "'", e );
|
"Error getting reports from the plugin '" + reportPlugin.getKey() + "'", e );
|
||||||
}
|
}
|
||||||
|
catch ( ArtifactNotFoundException e )
|
||||||
|
{
|
||||||
|
throw new LifecycleExecutionException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
catch ( ArtifactResolutionException e )
|
||||||
|
{
|
||||||
|
throw new LifecycleExecutionException( e.getMessage(), e );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return reports;
|
return reports;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void forkLifecycle( MojoDescriptor mojoDescriptor, MavenSession session, MavenProject project,
|
private void forkLifecycle( MojoDescriptor mojoDescriptor, MavenSession session, MavenProject project )
|
||||||
MavenExecutionResponse response )
|
throws LifecycleExecutionException, BuildFailureException, PluginNotFoundException
|
||||||
throws LifecycleExecutionException, MojoExecutionException, ArtifactResolutionException, MojoFailureException,
|
|
||||||
ArtifactNotFoundException, InvalidDependencyVersionException, PluginNotFoundException
|
|
||||||
{
|
{
|
||||||
PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
|
PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
|
||||||
getLogger().info( "Preparing " + pluginDescriptor.getGoalPrefix() + ":" + mojoDescriptor.getGoal() );
|
getLogger().info( "Preparing " + pluginDescriptor.getGoalPrefix() + ":" + mojoDescriptor.getGoal() );
|
||||||
|
|
||||||
if ( mojoDescriptor.isAggregator() )
|
if ( mojoDescriptor.isAggregator() )
|
||||||
{
|
{
|
||||||
response.setExecutedMultipleProjects( true );
|
|
||||||
|
|
||||||
for ( Iterator i = session.getSortedProjects().iterator(); i.hasNext(); )
|
for ( Iterator i = session.getSortedProjects().iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
MavenProject reactorProject = (MavenProject) i.next();
|
MavenProject reactorProject = (MavenProject) i.next();
|
||||||
|
@ -774,19 +709,17 @@ public class DefaultLifecycleExecutor
|
||||||
|
|
||||||
line();
|
line();
|
||||||
|
|
||||||
forkProjectLifecycle( mojoDescriptor, session, reactorProject, response );
|
forkProjectLifecycle( mojoDescriptor, session, reactorProject );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
forkProjectLifecycle( mojoDescriptor, session, project, response );
|
forkProjectLifecycle( mojoDescriptor, session, project );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void forkProjectLifecycle( MojoDescriptor mojoDescriptor, MavenSession session, MavenProject project,
|
private void forkProjectLifecycle( MojoDescriptor mojoDescriptor, MavenSession session, MavenProject project )
|
||||||
MavenExecutionResponse response )
|
throws LifecycleExecutionException, BuildFailureException, PluginNotFoundException
|
||||||
throws ArtifactResolutionException, LifecycleExecutionException, MojoExecutionException, MojoFailureException,
|
|
||||||
ArtifactNotFoundException, InvalidDependencyVersionException, PluginNotFoundException
|
|
||||||
{
|
{
|
||||||
PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
|
PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
|
||||||
|
|
||||||
|
@ -852,25 +785,25 @@ public class DefaultLifecycleExecutor
|
||||||
{
|
{
|
||||||
Lifecycle lifecycle = getLifecycleForPhase( targetPhase );
|
Lifecycle lifecycle = getLifecycleForPhase( targetPhase );
|
||||||
|
|
||||||
executeGoalWithLifecycle( targetPhase, session, lifecycleMappings, executionProject, response, lifecycle );
|
executeGoalWithLifecycle( targetPhase, session, lifecycleMappings, executionProject, lifecycle );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
String goal = mojoDescriptor.getExecuteGoal();
|
String goal = mojoDescriptor.getExecuteGoal();
|
||||||
MojoDescriptor desc = getMojoDescriptor( pluginDescriptor, goal );
|
MojoDescriptor desc = getMojoDescriptor( pluginDescriptor, goal );
|
||||||
executeGoals( Collections.singletonList( new MojoExecution( desc ) ), session, executionProject, response );
|
executeGoals( Collections.singletonList( new MojoExecution( desc ) ), session, executionProject );
|
||||||
}
|
}
|
||||||
project.setExecutionProject( executionProject );
|
project.setExecutionProject( executionProject );
|
||||||
}
|
}
|
||||||
|
|
||||||
private Lifecycle getLifecycleForPhase( String phase )
|
private Lifecycle getLifecycleForPhase( String phase )
|
||||||
throws LifecycleExecutionException
|
throws BuildFailureException, LifecycleExecutionException
|
||||||
{
|
{
|
||||||
Lifecycle lifecycle = (Lifecycle) getPhaseToLifecycleMap().get( phase );
|
Lifecycle lifecycle = (Lifecycle) getPhaseToLifecycleMap().get( phase );
|
||||||
|
|
||||||
if ( lifecycle == null )
|
if ( lifecycle == null )
|
||||||
{
|
{
|
||||||
throw new LifecycleExecutionException( "Unable to find lifecycle for phase '" + phase + "'" );
|
throw new BuildFailureException( "Unable to find lifecycle for phase '" + phase + "'" );
|
||||||
}
|
}
|
||||||
return lifecycle;
|
return lifecycle;
|
||||||
}
|
}
|
||||||
|
@ -922,8 +855,7 @@ public class DefaultLifecycleExecutor
|
||||||
|
|
||||||
private Map constructLifecycleMappings( MavenSession session, String selectedPhase, MavenProject project,
|
private Map constructLifecycleMappings( MavenSession session, String selectedPhase, MavenProject project,
|
||||||
Lifecycle lifecycle )
|
Lifecycle lifecycle )
|
||||||
throws ArtifactResolutionException, LifecycleExecutionException, ArtifactNotFoundException,
|
throws LifecycleExecutionException, BuildFailureException, PluginNotFoundException
|
||||||
PluginNotFoundException
|
|
||||||
{
|
{
|
||||||
// first, bind those associated with the packaging
|
// first, bind those associated with the packaging
|
||||||
Map lifecycleMappings = bindLifecycleForPackaging( session, selectedPhase, project, lifecycle );
|
Map lifecycleMappings = bindLifecycleForPackaging( session, selectedPhase, project, lifecycle );
|
||||||
|
@ -941,8 +873,7 @@ public class DefaultLifecycleExecutor
|
||||||
|
|
||||||
private Map bindLifecycleForPackaging( MavenSession session, String selectedPhase, MavenProject project,
|
private Map bindLifecycleForPackaging( MavenSession session, String selectedPhase, MavenProject project,
|
||||||
Lifecycle lifecycle )
|
Lifecycle lifecycle )
|
||||||
throws ArtifactResolutionException, LifecycleExecutionException, ArtifactNotFoundException,
|
throws LifecycleExecutionException, BuildFailureException, PluginNotFoundException
|
||||||
PluginNotFoundException
|
|
||||||
{
|
{
|
||||||
Map mappings = findMappingsForLifecycle( session, project, lifecycle );
|
Map mappings = findMappingsForLifecycle( session, project, lifecycle );
|
||||||
|
|
||||||
|
@ -985,8 +916,7 @@ public class DefaultLifecycleExecutor
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map findMappingsForLifecycle( MavenSession session, MavenProject project, Lifecycle lifecycle )
|
private Map findMappingsForLifecycle( MavenSession session, MavenProject project, Lifecycle lifecycle )
|
||||||
throws ArtifactResolutionException, LifecycleExecutionException, ArtifactNotFoundException,
|
throws LifecycleExecutionException, PluginNotFoundException
|
||||||
PluginNotFoundException
|
|
||||||
{
|
{
|
||||||
String packaging = project.getPackaging();
|
String packaging = project.getPackaging();
|
||||||
Map mappings = null;
|
Map mappings = null;
|
||||||
|
@ -1035,8 +965,7 @@ public class DefaultLifecycleExecutor
|
||||||
|
|
||||||
private Object findExtension( MavenProject project, String role, String roleHint, Settings settings,
|
private Object findExtension( MavenProject project, String role, String roleHint, Settings settings,
|
||||||
ArtifactRepository localRepository )
|
ArtifactRepository localRepository )
|
||||||
throws ArtifactResolutionException, ArtifactNotFoundException, LifecycleExecutionException,
|
throws LifecycleExecutionException, PluginNotFoundException
|
||||||
PluginNotFoundException
|
|
||||||
{
|
{
|
||||||
Object pluginComponent = null;
|
Object pluginComponent = null;
|
||||||
|
|
||||||
|
@ -1072,8 +1001,7 @@ public class DefaultLifecycleExecutor
|
||||||
* lookup directly, or have them passed in
|
* lookup directly, or have them passed in
|
||||||
*/
|
*/
|
||||||
private Map findArtifactTypeHandlers( MavenProject project, Settings settings, ArtifactRepository localRepository )
|
private Map findArtifactTypeHandlers( MavenProject project, Settings settings, ArtifactRepository localRepository )
|
||||||
throws ArtifactResolutionException, ArtifactNotFoundException, LifecycleExecutionException,
|
throws LifecycleExecutionException, PluginNotFoundException
|
||||||
PluginNotFoundException
|
|
||||||
{
|
{
|
||||||
Map map = new HashMap();
|
Map map = new HashMap();
|
||||||
for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext(); )
|
for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext(); )
|
||||||
|
@ -1123,8 +1051,7 @@ public class DefaultLifecycleExecutor
|
||||||
* @param session
|
* @param session
|
||||||
*/
|
*/
|
||||||
private void bindPluginToLifecycle( Plugin plugin, MavenSession session, Map phaseMap, MavenProject project )
|
private void bindPluginToLifecycle( Plugin plugin, MavenSession session, Map phaseMap, MavenProject project )
|
||||||
throws LifecycleExecutionException, ArtifactResolutionException, ArtifactNotFoundException,
|
throws LifecycleExecutionException, PluginNotFoundException
|
||||||
PluginNotFoundException
|
|
||||||
{
|
{
|
||||||
PluginDescriptor pluginDescriptor;
|
PluginDescriptor pluginDescriptor;
|
||||||
Settings settings = session.getSettings();
|
Settings settings = session.getSettings();
|
||||||
|
@ -1159,8 +1086,7 @@ public class DefaultLifecycleExecutor
|
||||||
|
|
||||||
private PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings,
|
private PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings,
|
||||||
ArtifactRepository localRepository )
|
ArtifactRepository localRepository )
|
||||||
throws ArtifactResolutionException, LifecycleExecutionException, ArtifactNotFoundException,
|
throws LifecycleExecutionException, PluginNotFoundException
|
||||||
PluginNotFoundException
|
|
||||||
{
|
{
|
||||||
PluginDescriptor pluginDescriptor;
|
PluginDescriptor pluginDescriptor;
|
||||||
try
|
try
|
||||||
|
@ -1174,22 +1100,33 @@ public class DefaultLifecycleExecutor
|
||||||
}
|
}
|
||||||
catch ( PluginVersionResolutionException e )
|
catch ( PluginVersionResolutionException e )
|
||||||
{
|
{
|
||||||
throw new LifecycleExecutionException( "Error resolving plugin version", e );
|
throw new LifecycleExecutionException( "Error resolving plugin version: " + e.getMessage(), e );
|
||||||
}
|
}
|
||||||
catch ( InvalidVersionSpecificationException e )
|
catch ( InvalidVersionSpecificationException e )
|
||||||
{
|
{
|
||||||
throw new LifecycleExecutionException( "Error resolving plugin version", e );
|
throw new LifecycleExecutionException( e.getMessage(), e );
|
||||||
}
|
}
|
||||||
catch ( InvalidPluginException e )
|
catch ( InvalidPluginException e )
|
||||||
{
|
{
|
||||||
throw new LifecycleExecutionException( "Error resolving plugin version", e );
|
throw new LifecycleExecutionException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
catch ( ArtifactNotFoundException e )
|
||||||
|
{
|
||||||
|
throw new LifecycleExecutionException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
catch ( ArtifactResolutionException e )
|
||||||
|
{
|
||||||
|
throw new LifecycleExecutionException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
catch ( PluginVersionNotFoundException e )
|
||||||
|
{
|
||||||
|
throw new LifecycleExecutionException( e.getMessage(), e );
|
||||||
}
|
}
|
||||||
return pluginDescriptor;
|
return pluginDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PluginDescriptor verifyReportPlugin( ReportPlugin plugin, MavenProject project, MavenSession session )
|
private PluginDescriptor verifyReportPlugin( ReportPlugin plugin, MavenProject project, MavenSession session )
|
||||||
throws ArtifactResolutionException, LifecycleExecutionException, ArtifactNotFoundException,
|
throws LifecycleExecutionException, PluginNotFoundException
|
||||||
PluginNotFoundException
|
|
||||||
{
|
{
|
||||||
PluginDescriptor pluginDescriptor;
|
PluginDescriptor pluginDescriptor;
|
||||||
try
|
try
|
||||||
|
@ -1203,15 +1140,27 @@ public class DefaultLifecycleExecutor
|
||||||
}
|
}
|
||||||
catch ( PluginVersionResolutionException e )
|
catch ( PluginVersionResolutionException e )
|
||||||
{
|
{
|
||||||
throw new LifecycleExecutionException( "Error resolving plugin version", e );
|
throw new LifecycleExecutionException( "Error resolving plugin version: " + e.getMessage(), e );
|
||||||
}
|
}
|
||||||
catch ( InvalidVersionSpecificationException e )
|
catch ( InvalidVersionSpecificationException e )
|
||||||
{
|
{
|
||||||
throw new LifecycleExecutionException( "Error resolving plugin version", e );
|
throw new LifecycleExecutionException( e.getMessage(), e );
|
||||||
}
|
}
|
||||||
catch ( InvalidPluginException e )
|
catch ( InvalidPluginException e )
|
||||||
{
|
{
|
||||||
throw new LifecycleExecutionException( "Error resolving plugin version", e );
|
throw new LifecycleExecutionException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
catch ( ArtifactNotFoundException e )
|
||||||
|
{
|
||||||
|
throw new LifecycleExecutionException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
catch ( ArtifactResolutionException e )
|
||||||
|
{
|
||||||
|
throw new LifecycleExecutionException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
catch ( PluginVersionNotFoundException e )
|
||||||
|
{
|
||||||
|
throw new LifecycleExecutionException( e.getMessage(), e );
|
||||||
}
|
}
|
||||||
return pluginDescriptor;
|
return pluginDescriptor;
|
||||||
}
|
}
|
||||||
|
@ -1227,7 +1176,8 @@ public class DefaultLifecycleExecutor
|
||||||
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );
|
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );
|
||||||
if ( mojoDescriptor == null )
|
if ( mojoDescriptor == null )
|
||||||
{
|
{
|
||||||
throw new LifecycleExecutionException( "Goal from the POM '" + goal + "' was not found in the plugin" );
|
throw new LifecycleExecutionException(
|
||||||
|
"'" + goal + "' was specified in an execution, but not found in the plugin" );
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have to check to see that the inheritance rules have been applied before binding this mojo.
|
// We have to check to see that the inheritance rules have been applied before binding this mojo.
|
||||||
|
@ -1303,8 +1253,7 @@ public class DefaultLifecycleExecutor
|
||||||
|
|
||||||
private MojoDescriptor getMojoDescriptor( String task, MavenSession session, MavenProject project,
|
private MojoDescriptor getMojoDescriptor( String task, MavenSession session, MavenProject project,
|
||||||
String invokedVia, boolean canUsePrefix )
|
String invokedVia, boolean canUsePrefix )
|
||||||
throws LifecycleExecutionException, ArtifactNotFoundException, PluginNotFoundException,
|
throws BuildFailureException, LifecycleExecutionException, PluginNotFoundException
|
||||||
ArtifactResolutionException
|
|
||||||
{
|
{
|
||||||
String goal;
|
String goal;
|
||||||
Plugin plugin;
|
Plugin plugin;
|
||||||
|
@ -1398,7 +1347,7 @@ public class DefaultLifecycleExecutor
|
||||||
{
|
{
|
||||||
String message = "Invalid task '" + task + "': you must specify a valid lifecycle phase, or" +
|
String message = "Invalid task '" + task + "': you must specify a valid lifecycle phase, or" +
|
||||||
" a goal in the format plugin:goal or pluginGroupId:pluginArtifactId:pluginVersion:goal";
|
" a goal in the format plugin:goal or pluginGroupId:pluginArtifactId:pluginVersion:goal";
|
||||||
throw new LifecycleExecutionException( message );
|
throw new BuildFailureException( message );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( pluginDescriptor == null )
|
if ( pluginDescriptor == null )
|
||||||
|
@ -1413,7 +1362,7 @@ public class DefaultLifecycleExecutor
|
||||||
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );
|
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );
|
||||||
if ( mojoDescriptor == null )
|
if ( mojoDescriptor == null )
|
||||||
{
|
{
|
||||||
throw new LifecycleExecutionException( "Required goal not found: " + task );
|
throw new BuildFailureException( "Required goal not found: " + task );
|
||||||
}
|
}
|
||||||
|
|
||||||
return mojoDescriptor;
|
return mojoDescriptor;
|
||||||
|
|
|
@ -16,7 +16,7 @@ package org.apache.maven.lifecycle;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.execution.MavenExecutionResponse;
|
import org.apache.maven.BuildFailureException;
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.execution.ReactorManager;
|
import org.apache.maven.execution.ReactorManager;
|
||||||
import org.apache.maven.monitor.event.EventDispatcher;
|
import org.apache.maven.monitor.event.EventDispatcher;
|
||||||
|
@ -29,7 +29,7 @@ public interface LifecycleExecutor
|
||||||
{
|
{
|
||||||
String ROLE = LifecycleExecutor.class.getName();
|
String ROLE = LifecycleExecutor.class.getName();
|
||||||
|
|
||||||
MavenExecutionResponse execute( MavenSession session, ReactorManager rpm, EventDispatcher dispatcher )
|
void execute( MavenSession session, ReactorManager rpm, EventDispatcher dispatcher )
|
||||||
throws LifecycleExecutionException;
|
throws LifecycleExecutionException, BuildFailureException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@ import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||||
import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder;
|
import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder;
|
||||||
import org.apache.maven.plugin.logging.Log;
|
import org.apache.maven.plugin.logging.Log;
|
||||||
import org.apache.maven.plugin.version.PluginVersionManager;
|
import org.apache.maven.plugin.version.PluginVersionManager;
|
||||||
|
import org.apache.maven.plugin.version.PluginVersionNotFoundException;
|
||||||
import org.apache.maven.plugin.version.PluginVersionResolutionException;
|
import org.apache.maven.plugin.version.PluginVersionResolutionException;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.project.MavenProjectBuilder;
|
import org.apache.maven.project.MavenProjectBuilder;
|
||||||
|
@ -147,7 +148,8 @@ public class DefaultPluginManager
|
||||||
public PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings,
|
public PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings,
|
||||||
ArtifactRepository localRepository )
|
ArtifactRepository localRepository )
|
||||||
throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException,
|
throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException,
|
||||||
InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException
|
InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException,
|
||||||
|
PluginVersionNotFoundException
|
||||||
{
|
{
|
||||||
// TODO: this should be possibly outside
|
// TODO: this should be possibly outside
|
||||||
// All version-resolution logic has been moved to DefaultPluginVersionManager.
|
// All version-resolution logic has been moved to DefaultPluginVersionManager.
|
||||||
|
@ -238,7 +240,7 @@ public class DefaultPluginManager
|
||||||
* manager which executes before the plugin is instantiated
|
* manager which executes before the plugin is instantiated
|
||||||
*/
|
*/
|
||||||
private void checkRequiredMavenVersion( Plugin plugin, ArtifactRepository localRepository, List remoteRepositories )
|
private void checkRequiredMavenVersion( Plugin plugin, ArtifactRepository localRepository, List remoteRepositories )
|
||||||
throws PluginVersionResolutionException
|
throws PluginVersionResolutionException, InvalidPluginException
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -260,8 +262,8 @@ public class DefaultPluginManager
|
||||||
}
|
}
|
||||||
catch ( ProjectBuildingException e )
|
catch ( ProjectBuildingException e )
|
||||||
{
|
{
|
||||||
throw new PluginVersionResolutionException( plugin.getGroupId(), plugin.getArtifactId(),
|
throw new InvalidPluginException(
|
||||||
"Unable to build project for plugin", e );
|
"Unable to build project for plugin '" + plugin.getKey() + "': " + e.getMessage(), e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,7 +315,7 @@ public class DefaultPluginManager
|
||||||
|
|
||||||
public void executeMojo( MavenProject project, MojoExecution mojoExecution, MavenSession session )
|
public void executeMojo( MavenProject project, MojoExecution mojoExecution, MavenSession session )
|
||||||
throws ArtifactResolutionException, MojoExecutionException, MojoFailureException, ArtifactNotFoundException,
|
throws ArtifactResolutionException, MojoExecutionException, MojoFailureException, ArtifactNotFoundException,
|
||||||
InvalidDependencyVersionException, PluginManagerException
|
InvalidDependencyVersionException, PluginManagerException, PluginConfigurationException
|
||||||
{
|
{
|
||||||
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
|
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
|
||||||
|
|
||||||
|
@ -359,28 +361,20 @@ public class DefaultPluginManager
|
||||||
|
|
||||||
Mojo plugin;
|
Mojo plugin;
|
||||||
|
|
||||||
try
|
PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
|
||||||
|
String goalId = mojoDescriptor.getGoal();
|
||||||
|
String groupId = pluginDescriptor.getGroupId();
|
||||||
|
String artifactId = pluginDescriptor.getArtifactId();
|
||||||
|
String executionId = mojoExecution.getExecutionId();
|
||||||
|
Xpp3Dom dom = project.getGoalConfiguration( groupId, artifactId, executionId, goalId );
|
||||||
|
Xpp3Dom reportDom = project.getReportConfiguration( groupId, artifactId, executionId );
|
||||||
|
dom = Xpp3Dom.mergeXpp3Dom( dom, reportDom );
|
||||||
|
if ( mojoExecution.getConfiguration() != null )
|
||||||
{
|
{
|
||||||
PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
|
dom = Xpp3Dom.mergeXpp3Dom( dom, mojoExecution.getConfiguration() );
|
||||||
String goalId = mojoDescriptor.getGoal();
|
}
|
||||||
String groupId = pluginDescriptor.getGroupId();
|
|
||||||
String artifactId = pluginDescriptor.getArtifactId();
|
|
||||||
String executionId = mojoExecution.getExecutionId();
|
|
||||||
Xpp3Dom dom = project.getGoalConfiguration( groupId, artifactId, executionId, goalId );
|
|
||||||
Xpp3Dom reportDom = project.getReportConfiguration( groupId, artifactId, executionId );
|
|
||||||
dom = Xpp3Dom.mergeXpp3Dom( dom, reportDom );
|
|
||||||
if ( mojoExecution.getConfiguration() != null )
|
|
||||||
{
|
|
||||||
dom = Xpp3Dom.mergeXpp3Dom( dom, mojoExecution.getConfiguration() );
|
|
||||||
}
|
|
||||||
|
|
||||||
plugin = getConfiguredMojo( session, dom, project, false, mojoExecution );
|
plugin = getConfiguredMojo( session, dom, project, false, mojoExecution );
|
||||||
}
|
|
||||||
catch ( PluginConfigurationException e )
|
|
||||||
{
|
|
||||||
String msg = "Error configuring plugin for execution of '" + goalName + "'.";
|
|
||||||
throw new MojoExecutionException( msg, e );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Event monitoring.
|
// Event monitoring.
|
||||||
String event = MavenEvents.MOJO_EXECUTION;
|
String event = MavenEvents.MOJO_EXECUTION;
|
||||||
|
@ -457,7 +451,8 @@ public class DefaultPluginManager
|
||||||
|
|
||||||
public PluginDescriptor verifyReportPlugin( ReportPlugin reportPlugin, MavenProject project, MavenSession session )
|
public PluginDescriptor verifyReportPlugin( ReportPlugin reportPlugin, MavenProject project, MavenSession session )
|
||||||
throws PluginVersionResolutionException, ArtifactResolutionException, ArtifactNotFoundException,
|
throws PluginVersionResolutionException, ArtifactResolutionException, ArtifactNotFoundException,
|
||||||
InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException
|
InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException,
|
||||||
|
PluginVersionNotFoundException
|
||||||
{
|
{
|
||||||
String version = reportPlugin.getVersion();
|
String version = reportPlugin.getVersion();
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.model.Plugin;
|
import org.apache.maven.model.Plugin;
|
||||||
import org.apache.maven.model.ReportPlugin;
|
import org.apache.maven.model.ReportPlugin;
|
||||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||||
|
import org.apache.maven.plugin.version.PluginVersionNotFoundException;
|
||||||
import org.apache.maven.plugin.version.PluginVersionResolutionException;
|
import org.apache.maven.plugin.version.PluginVersionResolutionException;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||||
|
@ -43,7 +44,7 @@ public interface PluginManager
|
||||||
|
|
||||||
void executeMojo( MavenProject project, MojoExecution execution, MavenSession session )
|
void executeMojo( MavenProject project, MojoExecution execution, MavenSession session )
|
||||||
throws MojoExecutionException, ArtifactResolutionException, MojoFailureException, ArtifactNotFoundException,
|
throws MojoExecutionException, ArtifactResolutionException, MojoFailureException, ArtifactNotFoundException,
|
||||||
InvalidDependencyVersionException, PluginManagerException;
|
InvalidDependencyVersionException, PluginManagerException, PluginConfigurationException;
|
||||||
|
|
||||||
MavenReport getReport( MavenProject project, MojoExecution mojoExecution, MavenSession session )
|
MavenReport getReport( MavenProject project, MojoExecution mojoExecution, MavenSession session )
|
||||||
throws ArtifactNotFoundException, PluginConfigurationException, PluginManagerException,
|
throws ArtifactNotFoundException, PluginConfigurationException, PluginManagerException,
|
||||||
|
@ -56,11 +57,13 @@ public interface PluginManager
|
||||||
PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings,
|
PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings,
|
||||||
ArtifactRepository localRepository )
|
ArtifactRepository localRepository )
|
||||||
throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException,
|
throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException,
|
||||||
InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException;
|
InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException,
|
||||||
|
PluginVersionNotFoundException;
|
||||||
|
|
||||||
PluginDescriptor verifyReportPlugin( ReportPlugin reportPlugin, MavenProject project, MavenSession session )
|
PluginDescriptor verifyReportPlugin( ReportPlugin reportPlugin, MavenProject project, MavenSession session )
|
||||||
throws PluginVersionResolutionException, ArtifactResolutionException, ArtifactNotFoundException,
|
throws PluginVersionResolutionException, ArtifactResolutionException, ArtifactNotFoundException,
|
||||||
InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException;
|
InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException,
|
||||||
|
PluginVersionNotFoundException;
|
||||||
|
|
||||||
Object getPluginComponent( Plugin plugin, String role, String roleHint )
|
Object getPluginComponent( Plugin plugin, String role, String roleHint )
|
||||||
throws PluginManagerException, ComponentLookupException;
|
throws PluginManagerException, ComponentLookupException;
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||||
import org.apache.maven.execution.RuntimeInformation;
|
import org.apache.maven.execution.RuntimeInformation;
|
||||||
import org.apache.maven.model.Plugin;
|
import org.apache.maven.model.Plugin;
|
||||||
import org.apache.maven.model.ReportPlugin;
|
import org.apache.maven.model.ReportPlugin;
|
||||||
|
import org.apache.maven.plugin.InvalidPluginException;
|
||||||
import org.apache.maven.plugin.registry.MavenPluginRegistryBuilder;
|
import org.apache.maven.plugin.registry.MavenPluginRegistryBuilder;
|
||||||
import org.apache.maven.plugin.registry.PluginRegistry;
|
import org.apache.maven.plugin.registry.PluginRegistry;
|
||||||
import org.apache.maven.plugin.registry.PluginRegistryUtils;
|
import org.apache.maven.plugin.registry.PluginRegistryUtils;
|
||||||
|
@ -74,21 +75,21 @@ public class DefaultPluginVersionManager
|
||||||
|
|
||||||
public String resolvePluginVersion( String groupId, String artifactId, MavenProject project, Settings settings,
|
public String resolvePluginVersion( String groupId, String artifactId, MavenProject project, Settings settings,
|
||||||
ArtifactRepository localRepository )
|
ArtifactRepository localRepository )
|
||||||
throws PluginVersionResolutionException
|
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException
|
||||||
{
|
{
|
||||||
return resolvePluginVersion( groupId, artifactId, project, settings, localRepository, false );
|
return resolvePluginVersion( groupId, artifactId, project, settings, localRepository, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
public String resolveReportPluginVersion( String groupId, String artifactId, MavenProject project,
|
public String resolveReportPluginVersion( String groupId, String artifactId, MavenProject project,
|
||||||
Settings settings, ArtifactRepository localRepository )
|
Settings settings, ArtifactRepository localRepository )
|
||||||
throws PluginVersionResolutionException
|
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException
|
||||||
{
|
{
|
||||||
return resolvePluginVersion( groupId, artifactId, project, settings, localRepository, true );
|
return resolvePluginVersion( groupId, artifactId, project, settings, localRepository, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
private String resolvePluginVersion( String groupId, String artifactId, MavenProject project, Settings settings,
|
private String resolvePluginVersion( String groupId, String artifactId, MavenProject project, Settings settings,
|
||||||
ArtifactRepository localRepository, boolean resolveAsReportPlugin )
|
ArtifactRepository localRepository, boolean resolveAsReportPlugin )
|
||||||
throws PluginVersionResolutionException
|
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException
|
||||||
{
|
{
|
||||||
// first pass...if the plugin is specified in the pom, try to retrieve the version from there.
|
// first pass...if the plugin is specified in the pom, try to retrieve the version from there.
|
||||||
String version = getVersionFromPluginConfig( groupId, artifactId, project, resolveAsReportPlugin );
|
String version = getVersionFromPluginConfig( groupId, artifactId, project, resolveAsReportPlugin );
|
||||||
|
@ -214,8 +215,8 @@ public class DefaultPluginVersionManager
|
||||||
// if we still haven't found a version, then fail early before we get into the update goop.
|
// if we still haven't found a version, then fail early before we get into the update goop.
|
||||||
if ( StringUtils.isEmpty( version ) )
|
if ( StringUtils.isEmpty( version ) )
|
||||||
{
|
{
|
||||||
throw new PluginVersionResolutionException( groupId, artifactId,
|
throw new PluginVersionNotFoundException( groupId, artifactId,
|
||||||
"Failed to resolve a valid version for this plugin" );
|
"Failed to resolve a valid version for this plugin" );
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the plugin registry is inactive, then the rest of this goop is useless...
|
// if the plugin registry is inactive, then the rest of this goop is useless...
|
||||||
|
@ -625,7 +626,7 @@ public class DefaultPluginVersionManager
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
throw new PluginVersionResolutionException( groupId, artifactId,
|
throw new PluginVersionResolutionException( groupId, artifactId,
|
||||||
"Error readin plugin registry: " + e.getMessage(), e );
|
"Error reading plugin registry: " + e.getMessage(), e );
|
||||||
}
|
}
|
||||||
catch ( XmlPullParserException e )
|
catch ( XmlPullParserException e )
|
||||||
{
|
{
|
||||||
|
@ -644,7 +645,7 @@ public class DefaultPluginVersionManager
|
||||||
|
|
||||||
private String resolveMetaVersion( String groupId, String artifactId, MavenProject project,
|
private String resolveMetaVersion( String groupId, String artifactId, MavenProject project,
|
||||||
ArtifactRepository localRepository, String metaVersionId )
|
ArtifactRepository localRepository, String metaVersionId )
|
||||||
throws PluginVersionResolutionException
|
throws PluginVersionResolutionException, InvalidPluginException
|
||||||
{
|
{
|
||||||
Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, metaVersionId );
|
Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, metaVersionId );
|
||||||
|
|
||||||
|
@ -677,8 +678,8 @@ public class DefaultPluginVersionManager
|
||||||
}
|
}
|
||||||
catch ( ProjectBuildingException e )
|
catch ( ProjectBuildingException e )
|
||||||
{
|
{
|
||||||
throw new PluginVersionResolutionException( groupId, artifactId,
|
throw new InvalidPluginException( "Unable to build project information for plugin '" +
|
||||||
"Unable to build resolve plugin project information", e );
|
ArtifactUtils.versionlessKey( groupId, artifactId ) + "': " + e.getMessage(), e );
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean pluginValid = true;
|
boolean pluginValid = true;
|
||||||
|
|
|
@ -17,6 +17,7 @@ package org.apache.maven.plugin.version;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.plugin.InvalidPluginException;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.settings.Settings;
|
import org.apache.maven.settings.Settings;
|
||||||
|
|
||||||
|
@ -26,10 +27,10 @@ public interface PluginVersionManager
|
||||||
|
|
||||||
String resolvePluginVersion( String groupId, String artifactId, MavenProject project, Settings settings,
|
String resolvePluginVersion( String groupId, String artifactId, MavenProject project, Settings settings,
|
||||||
ArtifactRepository localRepository )
|
ArtifactRepository localRepository )
|
||||||
throws PluginVersionResolutionException;
|
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException;
|
||||||
|
|
||||||
String resolveReportPluginVersion( String groupId, String artifactId, MavenProject project, Settings settings,
|
String resolveReportPluginVersion( String groupId, String artifactId, MavenProject project, Settings settings,
|
||||||
ArtifactRepository localRepository )
|
ArtifactRepository localRepository )
|
||||||
throws PluginVersionResolutionException;
|
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.apache.maven.lifecycle;
|
package org.apache.maven.plugin.version;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2001-2005 The Apache Software Foundation.
|
* Copyright 2001-2005 The Apache Software Foundation.
|
||||||
|
@ -16,17 +16,29 @@ package org.apache.maven.lifecycle;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
public class PluginVersionNotFoundException
|
||||||
* Exception indicating there were no goals given.
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
|
||||||
* @version $Id$
|
|
||||||
*/
|
|
||||||
public class NoGoalsSpecifiedException
|
|
||||||
extends Exception
|
extends Exception
|
||||||
{
|
{
|
||||||
public NoGoalsSpecifiedException( String message )
|
private final String groupId;
|
||||||
|
|
||||||
|
private final String artifactId;
|
||||||
|
|
||||||
|
public PluginVersionNotFoundException( String groupId, String artifactId, String baseMessage )
|
||||||
{
|
{
|
||||||
super( message );
|
super( "Error resolving version for \'" + groupId + ":" + artifactId + "\': " + baseMessage );
|
||||||
|
|
||||||
|
this.groupId = groupId;
|
||||||
|
this.artifactId = artifactId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getGroupId()
|
||||||
|
{
|
||||||
|
return groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getArtifactId()
|
||||||
|
{
|
||||||
|
return artifactId;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -32,6 +32,7 @@ import org.apache.maven.plugin.PluginNotFoundException;
|
||||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||||
import org.apache.maven.plugin.descriptor.Parameter;
|
import org.apache.maven.plugin.descriptor.Parameter;
|
||||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||||
|
import org.apache.maven.plugin.version.PluginVersionNotFoundException;
|
||||||
import org.apache.maven.plugin.version.PluginVersionResolutionException;
|
import org.apache.maven.plugin.version.PluginVersionResolutionException;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.project.MavenProjectBuilder;
|
import org.apache.maven.project.MavenProjectBuilder;
|
||||||
|
@ -336,7 +337,13 @@ public class DescribeMojo
|
||||||
}
|
}
|
||||||
catch ( PluginNotFoundException e )
|
catch ( PluginNotFoundException e )
|
||||||
{
|
{
|
||||||
throw new MojoExecutionException( "Plugin does not exist: " + e.getMessage(), e );
|
getLog().debug( "Unable to find plugin", e );
|
||||||
|
throw new MojoFailureException( "Plugin does not exist: " + e.getMessage() );
|
||||||
|
}
|
||||||
|
catch ( PluginVersionNotFoundException e )
|
||||||
|
{
|
||||||
|
getLog().debug( "Unable to find plugin version", e );
|
||||||
|
throw new MojoFailureException( e.getMessage() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,9 +32,11 @@ import org.apache.maven.model.PluginManagement;
|
||||||
import org.apache.maven.model.ReportPlugin;
|
import org.apache.maven.model.ReportPlugin;
|
||||||
import org.apache.maven.model.Reporting;
|
import org.apache.maven.model.Reporting;
|
||||||
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
|
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
|
||||||
|
import org.apache.maven.plugin.InvalidPluginException;
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
import org.apache.maven.plugin.MojoFailureException;
|
||||||
import org.apache.maven.plugin.version.PluginVersionManager;
|
import org.apache.maven.plugin.version.PluginVersionManager;
|
||||||
|
import org.apache.maven.plugin.version.PluginVersionNotFoundException;
|
||||||
import org.apache.maven.plugin.version.PluginVersionResolutionException;
|
import org.apache.maven.plugin.version.PluginVersionResolutionException;
|
||||||
import org.apache.maven.plugins.release.helpers.ProjectScmRewriter;
|
import org.apache.maven.plugins.release.helpers.ProjectScmRewriter;
|
||||||
import org.apache.maven.plugins.release.helpers.ProjectVersionResolver;
|
import org.apache.maven.plugins.release.helpers.ProjectVersionResolver;
|
||||||
|
@ -940,9 +942,17 @@ public class PrepareReleaseMojo
|
||||||
}
|
}
|
||||||
catch ( PluginVersionResolutionException e )
|
catch ( PluginVersionResolutionException e )
|
||||||
{
|
{
|
||||||
getLog().debug( "Error resolving plugin version", e );
|
throw new MojoExecutionException(
|
||||||
throw new MojoFailureException(
|
"Cannot resolve version for plugin '" + plugin.getKey() + "': " + e.getMessage(), e );
|
||||||
"Cannot resolve version for plugin '" + plugin.getKey() + "': " + e.getMessage() );
|
}
|
||||||
|
catch ( InvalidPluginException e )
|
||||||
|
{
|
||||||
|
throw new MojoExecutionException(
|
||||||
|
"Cannot resolve version for plugin '" + plugin.getKey() + "': " + e.getMessage(), e );
|
||||||
|
}
|
||||||
|
catch ( PluginVersionNotFoundException e )
|
||||||
|
{
|
||||||
|
throw new MojoFailureException( e.getMessage() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ArtifactUtils.isSnapshot( version ) )
|
if ( ArtifactUtils.isSnapshot( version ) )
|
||||||
|
@ -977,9 +987,17 @@ public class PrepareReleaseMojo
|
||||||
}
|
}
|
||||||
catch ( PluginVersionResolutionException e )
|
catch ( PluginVersionResolutionException e )
|
||||||
{
|
{
|
||||||
getLog().debug( "Error resolving report version", e );
|
throw new MojoExecutionException(
|
||||||
throw new MojoFailureException(
|
"Cannot resolve version for report '" + plugin.getKey() + "': " + e.getMessage(), e );
|
||||||
"Cannot resolve version for report '" + plugin.getKey() + "': " + e.getMessage() );
|
}
|
||||||
|
catch ( InvalidPluginException e )
|
||||||
|
{
|
||||||
|
throw new MojoExecutionException(
|
||||||
|
"Cannot resolve version for plugin '" + plugin.getKey() + "': " + e.getMessage(), e );
|
||||||
|
}
|
||||||
|
catch ( PluginVersionNotFoundException e )
|
||||||
|
{
|
||||||
|
throw new MojoFailureException( e.getMessage() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ArtifactUtils.isSnapshot( version ) )
|
if ( ArtifactUtils.isSnapshot( version ) )
|
||||||
|
|
Loading…
Reference in New Issue