Author: brett
Date: Sun Oct  2 21:10:19 2005
New Revision: 293231

URL: http://svn.apache.org/viewcvs?rev=293231&view=rev
Log:
handle mojo failure exception

Modified:
    
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
    
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
    
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java

Modified: 
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
URL: 
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?rev=293231&r1=293230&r2=293231&view=diff
==============================================================================
--- 
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
 (original)
+++ 
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
 Sun Oct  2 21:10:19 2005
@@ -40,6 +40,7 @@
 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 @@
         {
             response.setException( e );
         }
+        catch ( MojoFailureException e )
+        {
+            response.setException( e );
+        }
         finally
         {
             response.setFinish( new Date() );
@@ -194,7 +199,8 @@
 
     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 @@
                             {
                                 handleExecutionFailure( rm, rootProject, e, 
task );
                             }
+                            catch ( MojoFailureException e )
+                            {
+                                handleExecutionFailure( rm, rootProject, e, 
task );
+                            }
                         }
 
                         dispatcher.dispatchEnd( event, rootProject.getId() + " 
( " + segment + " )" );
@@ -305,6 +315,10 @@
                                 {
                                     handleExecutionFailure( rm, 
currentProject, e, task );
                                 }
+                                catch ( MojoFailureException e )
+                                {
+                                    handleExecutionFailure( rm, 
currentProject, e, task );
+                                }
                             }
 
                             dispatcher.dispatchEnd( event, 
currentProject.getId() + " ( " + segment + " )" );
@@ -335,7 +349,7 @@
     }
 
     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 @@
             {
                 throw (MojoExecutionException) e;
             }
+            if ( e instanceof MojoFailureException )
+            {
+                throw (MojoFailureException) e;
+            }
             else if ( e instanceof ArtifactResolutionException )
             {
                 throw (ArtifactResolutionException) e;
@@ -467,7 +485,8 @@
     }
 
     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 @@
 
     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 @@
     }
 
     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 @@
     }
 
     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 @@
     }
 
     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() );

Modified: 
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL: 
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=293231&r1=293230&r2=293231&view=diff
==============================================================================
--- 
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
 (original)
+++ 
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
 Sun Oct  2 21:10:19 2005
@@ -310,7 +310,7 @@
     // ----------------------------------------------------------------------
 
     public void executeMojo( MavenProject project, MojoExecution 
mojoExecution, MavenSession session )
-        throws ArtifactResolutionException, PluginManagerException, 
MojoExecutionException
+        throws ArtifactResolutionException, PluginManagerException, 
MojoExecutionException, MojoFailureException
     {
         MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
 
@@ -408,6 +408,12 @@
             dispatcher.dispatchEnd( event, goalExecId );
         }
         catch ( MojoExecutionException e )
+        {
+            session.getEventDispatcher().dispatchError( event, goalExecId, e );
+
+            throw e;
+        }
+        catch ( MojoFailureException e )
         {
             session.getEventDispatcher().dispatchError( event, goalExecId, e );
 

Modified: 
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
URL: 
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java?rev=293231&r1=293230&r2=293231&view=diff
==============================================================================
--- 
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
 (original)
+++ 
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java
 Sun Oct  2 21:10:19 2005
@@ -39,7 +39,7 @@
     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;



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to