handle mojo failure exception

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@293231 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-10-03 04:10:19 +00:00
parent a79d40793a
commit 86ef6a7f5f
3 changed files with 34 additions and 9 deletions

View File

@ -40,6 +40,7 @@ import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.PluginManager;
import org.apache.maven.plugin.PluginManagerException;
import org.apache.maven.plugin.PluginNotFoundException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugin.lifecycle.Execution;
@ -184,6 +185,10 @@ public class DefaultLifecycleExecutor
{
response.setException( e );
}
catch ( MojoFailureException e )
{
response.setException( e );
}
finally
{
response.setFinish( new Date() );
@ -194,7 +199,8 @@ public class DefaultLifecycleExecutor
private void executeTaskSegments( List taskSegments, ReactorManager rm, MavenSession session,
MavenProject rootProject, EventDispatcher dispatcher )
throws PluginNotFoundException, MojoExecutionException, ArtifactResolutionException, LifecycleExecutionException
throws PluginNotFoundException, MojoExecutionException, ArtifactResolutionException,
LifecycleExecutionException, MojoFailureException
{
for ( Iterator it = taskSegments.iterator(); it.hasNext(); )
{
@ -237,6 +243,10 @@ public class DefaultLifecycleExecutor
{
handleExecutionFailure( rm, rootProject, e, task );
}
catch ( MojoFailureException e )
{
handleExecutionFailure( rm, rootProject, e, task );
}
}
dispatcher.dispatchEnd( event, rootProject.getId() + " ( " + segment + " )" );
@ -305,6 +315,10 @@ public class DefaultLifecycleExecutor
{
handleExecutionFailure( rm, currentProject, e, task );
}
catch ( MojoFailureException e )
{
handleExecutionFailure( rm, currentProject, e, task );
}
}
dispatcher.dispatchEnd( event, currentProject.getId() + " ( " + segment + " )" );
@ -335,7 +349,7 @@ public class DefaultLifecycleExecutor
}
private void handleExecutionFailure( ReactorManager rm, MavenProject project, Exception e, String task )
throws MojoExecutionException, ArtifactResolutionException
throws MojoExecutionException, ArtifactResolutionException, MojoFailureException
{
if ( ReactorManager.FAIL_FAST.equals( rm.getFailureBehavior() ) )
{
@ -345,6 +359,10 @@ public class DefaultLifecycleExecutor
{
throw (MojoExecutionException) e;
}
if ( e instanceof MojoFailureException )
{
throw (MojoFailureException) e;
}
else if ( e instanceof ArtifactResolutionException )
{
throw (ArtifactResolutionException) e;
@ -467,7 +485,8 @@ public class DefaultLifecycleExecutor
}
private void executeGoal( String task, MavenSession session, MavenProject project )
throws LifecycleExecutionException, PluginNotFoundException, MojoExecutionException, ArtifactResolutionException
throws LifecycleExecutionException, PluginNotFoundException, MojoExecutionException,
ArtifactResolutionException, MojoFailureException
{
if ( phases.contains( task ) )
{
@ -483,7 +502,7 @@ public class DefaultLifecycleExecutor
private void executeGoalWithLifecycle( String task, MavenSession session, Map lifecycleMappings,
MavenProject project )
throws ArtifactResolutionException, LifecycleExecutionException, MojoExecutionException
throws ArtifactResolutionException, LifecycleExecutionException, MojoExecutionException, MojoFailureException
{
List goals = processGoalChain( task, lifecycleMappings );
@ -491,7 +510,7 @@ public class DefaultLifecycleExecutor
}
private void executeStandaloneGoal( String task, MavenSession session, MavenProject project )
throws ArtifactResolutionException, LifecycleExecutionException, MojoExecutionException
throws ArtifactResolutionException, LifecycleExecutionException, MojoExecutionException, MojoFailureException
{
// guaranteed to come from the CLI and not be part of a phase
MojoDescriptor mojoDescriptor = getMojoDescriptor( task, session, project, task, true );
@ -499,7 +518,7 @@ public class DefaultLifecycleExecutor
}
private void executeGoals( List goals, MavenSession session, MavenProject project )
throws LifecycleExecutionException, MojoExecutionException, ArtifactResolutionException
throws LifecycleExecutionException, MojoExecutionException, ArtifactResolutionException, MojoFailureException
{
for ( Iterator i = goals.iterator(); i.hasNext(); )
{
@ -674,7 +693,7 @@ public class DefaultLifecycleExecutor
}
private void forkLifecycle( MojoDescriptor mojoDescriptor, MavenSession session, MavenProject project )
throws LifecycleExecutionException, MojoExecutionException, ArtifactResolutionException
throws LifecycleExecutionException, MojoExecutionException, ArtifactResolutionException, MojoFailureException
{
PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
getLogger().info( "Preparing " + pluginDescriptor.getGoalPrefix() + ":" + mojoDescriptor.getGoal() );

View File

@ -310,7 +310,7 @@ public class DefaultPluginManager
// ----------------------------------------------------------------------
public void executeMojo( MavenProject project, MojoExecution mojoExecution, MavenSession session )
throws ArtifactResolutionException, PluginManagerException, MojoExecutionException
throws ArtifactResolutionException, PluginManagerException, MojoExecutionException, MojoFailureException
{
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
@ -413,6 +413,12 @@ public class DefaultPluginManager
throw e;
}
catch ( MojoFailureException e )
{
session.getEventDispatcher().dispatchError( event, goalExecId, e );
throw e;
}
finally
{

View File

@ -39,7 +39,7 @@ public interface PluginManager
String ROLE = PluginManager.class.getName();
void executeMojo( MavenProject project, MojoExecution execution, MavenSession session )
throws MojoExecutionException, PluginManagerException, ArtifactResolutionException;
throws MojoExecutionException, PluginManagerException, ArtifactResolutionException, MojoFailureException;
MavenReport getReport( MavenProject project, MojoExecution mojoExecution, MavenSession session )
throws PluginManagerException;