From 2d01e12568f9e42d5039cb63f4156865a8acc5b5 Mon Sep 17 00:00:00 2001 From: Jason van Zyl Date: Sun, 8 Mar 2009 20:07:40 +0000 Subject: [PATCH] o reduce the signature of executeMojo in the pluginManager and propagate git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@751512 13f79535-47bb-0310-9956-ffa450edef68 --- .../lifecycle/DefaultLifecycleExecutor.java | 13 ------ .../maven/plugin/DefaultPluginManager.java | 40 +++++++++++++++---- .../apache/maven/plugin/PluginManager.java | 8 ++-- 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java index 9771c31fa4..0b1e70c762 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java @@ -54,7 +54,6 @@ import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugin.lifecycle.Execution; import org.apache.maven.plugin.lifecycle.Phase; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.artifact.InvalidDependencyVersionException; import org.apache.maven.reporting.MavenReport; import org.apache.maven.settings.Settings; import org.codehaus.plexus.component.annotations.Component; @@ -577,18 +576,6 @@ public class DefaultLifecycleExecutor { throw new LifecycleExecutionException( "Internal error in the plugin manager executing goal '" + 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 ); diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java index dc2712ab8c..ca8872fd96 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java @@ -414,7 +414,7 @@ public class DefaultPluginManager // ---------------------------------------------------------------------- public void executeMojo( MavenProject project, MojoExecution mojoExecution, MavenSession session ) - throws ArtifactResolutionException, MojoFailureException, ArtifactNotFoundException, InvalidDependencyVersionException, PluginManagerException, PluginConfigurationException + throws MojoFailureException, PluginExecutionException, PluginConfigurationException { MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); @@ -454,14 +454,32 @@ public class DefaultPluginManager projects = Collections.singleton( project ); } - for ( Iterator i = projects.iterator(); i.hasNext(); ) + //!!jvz What is this? We resolveTransitiveDependencies() and then a line later downDependencies()? That can't be right. We should also already + // know at this point that what we need to execute can't be found. This is the wrong time to find this out. + + try { - MavenProject p = (MavenProject) i.next(); + for ( Iterator i = projects.iterator(); i.hasNext(); ) + { + MavenProject p = (MavenProject) i.next(); - resolveTransitiveDependencies( session, repositorySystem, mojoDescriptor.isDependencyResolutionRequired(), p, mojoDescriptor.isAggregator() ); + resolveTransitiveDependencies( session, repositorySystem, mojoDescriptor.isDependencyResolutionRequired(), p, mojoDescriptor.isAggregator() ); + } + + downloadDependencies( project, session, repositorySystem ); + } + catch ( ArtifactResolutionException e ) + { + throw new PluginExecutionException( mojoExecution, project, e.getMessage() ); + } + catch ( InvalidDependencyVersionException e ) + { + throw new PluginExecutionException( mojoExecution, project, e.getMessage() ); + } + catch ( ArtifactNotFoundException e ) + { + throw new PluginExecutionException( mojoExecution, project, e.getMessage() ); } - - downloadDependencies( project, session, repositorySystem ); } String goalName = mojoDescriptor.getFullGoalName(); @@ -486,11 +504,11 @@ public class DefaultPluginManager } catch ( XmlPullParserException e ) { - throw new PluginManagerException( mojoDescriptor, project, "Failed to calculate concrete state for configuration of: " + mojoDescriptor.getHumanReadableKey(), e ); + throw new PluginExecutionException( mojoExecution, project, "Failed to calculate concrete state for configuration of: " + mojoDescriptor.getHumanReadableKey() ); } catch ( IOException e ) { - throw new PluginManagerException( mojoDescriptor, project, "Failed to calculate concrete state for configuration of: " + mojoDescriptor.getHumanReadableKey(), e ); + throw new PluginExecutionException( mojoExecution, project, "Failed to calculate concrete state for configuration of: " + mojoDescriptor.getHumanReadableKey() ); } } @@ -594,6 +612,12 @@ public class DefaultPluginManager throw e; } + catch ( PluginManagerException e ) + { + session.getEventDispatcher().dispatchError( event, goalExecId, e ); + + throw new PluginExecutionException( mojoExecution, project, e.getMessage() ); + } finally { if ( mojo != null ) diff --git a/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java index 35f7462a71..43a58b9131 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/PluginManager.java @@ -31,8 +31,8 @@ import org.apache.maven.reporting.MavenReport; public interface PluginManager { // - find the plugin [extension point: any client may wish to do whatever they choose] - // - load the plugin [extension point: we want to take them from a repository, some may take from disk or whatever] - // - configure the plugin + // - load the plugin into a classloader [extension point: we want to take them from a repository, some may take from disk or whatever] + // - configure the plugin [extension point] // - execute the plugin Plugin findPluginForPrefix( String prefix, MavenProject project, MavenSession session ); @@ -40,10 +40,8 @@ public interface PluginManager PluginDescriptor loadPlugin( Plugin plugin, MavenProject project, MavenSession session ) throws PluginLoaderException; - //!!jvz - // Clean up the exceptions returned. We should not be coupled to the repository layer. We need to generalize to allow a general plugin mechanism. void executeMojo( MavenProject project, MojoExecution execution, MavenSession session ) - throws ArtifactResolutionException, MojoFailureException, ArtifactNotFoundException, InvalidDependencyVersionException, PluginManagerException, PluginConfigurationException; + throws MojoFailureException, PluginExecutionException, PluginConfigurationException; //!!jvz // Reporting