From 19311574e17d029a06975be56072125e10078cc8 Mon Sep 17 00:00:00 2001 From: John Dennis Casey Date: Fri, 8 Jun 2007 16:46:20 +0000 Subject: [PATCH] Try to assume that a plugin bound in the POM but not resolved during build-plan-building will be resolvable later. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@545558 13f79535-47bb-0310-9956-ffa450edef68 --- .../DefaultLifecycleBindingManager.java | 36 ++++++++++++++----- .../maven/lifecycle/plan/BuildPlan.java | 21 ++--------- .../lifecycle/plan/DefaultBuildPlanner.java | 2 +- .../src/main/mdo/maven-lifecycle.mdo | 14 +++++--- 4 files changed, 40 insertions(+), 33 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManager.java b/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManager.java index 6f2bec8916..654eb10af7 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManager.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManager.java @@ -275,20 +275,38 @@ public class DefaultLifecycleBindingManager } catch ( PluginLoaderException e ) { - throw new LifecycleLoaderException( "Failed to load plugin: " + plugin - + ". Reason: " + e.getMessage(), e ); + mojoBinding.setLateBound( true ); + + String message = "Failed to load plugin descriptor for: " + + plugin + + ". Assigning this plugin to be resolved again just prior to its execution. " + + "NOTE, This may affect assignment of the mojo: " + + mojoBinding.getGoal() + + " if its default phase (given in the plugin descriptor) is used."; + + if ( logger.isDebugEnabled() ) + { + logger.debug( message, e ); + } + else + { + logger.warn( message + " Check debug output (-X) for more information." ); + } } } - if ( pluginDescriptor.getMojos() == null ) + if ( pluginDescriptor != null ) { - logger.error( "Somehow, the PluginDescriptor for plugin: " + plugin.getKey() - + " contains no mojos. This is highly irregular. Ignoring..." ); - continue; - } + if ( pluginDescriptor.getMojos() == null ) + { + logger.error( "Somehow, the PluginDescriptor for plugin: " + plugin.getKey() + + " contains no mojos. This is highly irregular. Ignoring..." ); + continue; + } - MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal ); - phase = mojoDescriptor.getPhase(); + MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal ); + phase = mojoDescriptor.getPhase(); + } if ( phase == null ) { diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlan.java b/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlan.java index 48d8ca93b1..324674db35 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlan.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlan.java @@ -27,8 +27,6 @@ public class BuildPlan private final Map forkedPhases; - private final List lateBoundMojos; - private List renderedLifecycleMojos = new ArrayList(); private final Map directInvocationBindings; @@ -47,17 +45,15 @@ public class BuildPlan this.tasks = tasks; forkedDirectInvocations = new HashMap(); forkedPhases = new HashMap(); - lateBoundMojos = new ArrayList(); directInvocationBindings = new HashMap(); } - private BuildPlan( final LifecycleBindings bindings, final Map forkedDirectInvocations, final Map forkedPhases, final List lateBoundMojos, + private BuildPlan( final LifecycleBindings bindings, final Map forkedDirectInvocations, final Map forkedPhases, final Map directInvocationBindings, final List tasks ) { this.bindings = LifecycleUtils.cloneBindings( bindings ); this.forkedDirectInvocations = new HashMap( forkedDirectInvocations ); this.forkedPhases = new HashMap( forkedPhases ); - this.lateBoundMojos = new ArrayList( lateBoundMojos ); this.tasks = tasks; this.directInvocationBindings = new HashMap( directInvocationBindings ); } @@ -94,11 +90,6 @@ public class BuildPlan directInvocationBindings.put( key, binding ); } - public List getLateBoundMojos() - { - return lateBoundMojos; - } - public Map getDirectInvocationBindings() { return directInvocationBindings; @@ -136,14 +127,9 @@ public class BuildPlan invoke.addAll( forkedInvocations ); } - public void addLateBoundMojo( final MojoBinding mojoBinding ) - { - lateBoundMojos.add( MojoBindingUtils.createMojoBindingKey( mojoBinding, false ) ); - } - public BuildPlan copy( final List newTasks ) { - return new BuildPlan( bindings, forkedDirectInvocations, forkedPhases, lateBoundMojos, directInvocationBindings, newTasks ); + return new BuildPlan( bindings, forkedDirectInvocations, forkedPhases, directInvocationBindings, newTasks ); } public void resetExecutionProgress() @@ -214,8 +200,7 @@ public class BuildPlan private void addResolverIfLateBound( final MojoBinding mojoBinding, final List plan ) { - String key = MojoBindingUtils.createMojoBindingKey( mojoBinding, false ); - if ( lateBoundMojos.contains( key ) ) + if ( mojoBinding.isLateBound() ) { MojoBinding resolveBinding = StateManagementUtils.createResolveLateBoundMojoBinding( mojoBinding ); plan.add( resolveBinding ); diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DefaultBuildPlanner.java b/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DefaultBuildPlanner.java index 6a8517e6e6..bd946be2a2 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DefaultBuildPlanner.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DefaultBuildPlanner.java @@ -209,7 +209,7 @@ public class DefaultBuildPlanner logger.warn( message ); } - plan.addLateBoundMojo( mojoBinding ); + mojoBinding.setLateBound( true ); } return pluginDescriptor; diff --git a/maven-lifecycle/src/main/mdo/maven-lifecycle.mdo b/maven-lifecycle/src/main/mdo/maven-lifecycle.mdo index 3013f7b15c..0e85d19b24 100644 --- a/maven-lifecycle/src/main/mdo/maven-lifecycle.mdo +++ b/maven-lifecycle/src/main/mdo/maven-lifecycle.mdo @@ -619,20 +619,24 @@ boolean -