From fda1ed95c9bec2f2544abd43cd7c7d1bc9d0c1ee Mon Sep 17 00:00:00 2001 From: John Dennis Casey Date: Fri, 27 May 2005 23:05:09 +0000 Subject: [PATCH] o changed the inheritanceApplied flag to be set by default, and unset if the plugin is merged to the child without being specified...this makes it work with isolated POMs. o changed the semantics of when the unsetInheritanceApplied() method is called...it's now only when is NOT set. o changed the default inheritByDefault attribute on MojoDescriptor to be true o added inheritByDefault to PluginDescriptor (even though we don't have tools supporting it yet), with semantics identical to MojoDescriptor o added generator/builder support for the inheritByDefault attribute of PluginDescriptor o added calculation of inheritanceApplied || inheritByDefault to lifecycle executor before allowing plugins/mojos to bind. o Everything builds, but we need some sort of IT to test the finer points. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@178836 13f79535-47bb-0310-9956-ffa450edef68 --- .../lifecycle/DefaultLifecycleExecutor.java | 50 ++++++++++++------- maven-model/maven.mdo | 8 +-- .../plugin/descriptor/MojoDescriptor.java | 2 +- .../plugin/descriptor/PluginDescriptor.java | 12 +++++ .../descriptor/PluginDescriptorBuilder.java | 7 +++ .../generator/PluginDescriptorGenerator.java | 4 +- .../org/apache/maven/project/ModelUtils.java | 9 ++-- 7 files changed, 65 insertions(+), 27 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 48177e6389..846b8d2028 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 @@ -22,6 +22,7 @@ import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundExceptio import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.execution.MavenExecutionResponse; import org.apache.maven.execution.MavenSession; +import org.apache.maven.model.Goal; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginManagement; import org.apache.maven.plugin.MojoExecutionException; @@ -239,27 +240,42 @@ public class DefaultLifecycleExecutor { throw new LifecycleExecutionException( "Internal error in the plugin manager", e ); } - - // ---------------------------------------------------------------------- - // Look to see if the plugin configuration specifies particular mojos - // within the plugin. If this is the case then simply configure the - // mojos the user has specified and ignore the rest. - // ---------------------------------------------------------------------- - - for ( Iterator j = pluginDescriptor.getMojos().iterator(); j.hasNext(); ) + + if( plugin.isInheritanceApplied() || pluginDescriptor.isInheritedByDefault() ) { - MojoDescriptor mojoDescriptor = (MojoDescriptor) j.next(); + // ---------------------------------------------------------------------- + // Look to see if the plugin configuration specifies particular mojos + // within the plugin. If this is the case then simply configure the + // mojos the user has specified and ignore the rest. + // ---------------------------------------------------------------------- - // TODO: remove later - if ( mojoDescriptor.getGoal() == null ) + Map goalMap = plugin.getGoalsAsMap(); + + for ( Iterator j = pluginDescriptor.getMojos().iterator(); j.hasNext(); ) { - throw new LifecycleExecutionException( - "The plugin " + artifactId + " was built with an older version of Maven" ); - } + MojoDescriptor mojoDescriptor = (MojoDescriptor) j.next(); - if ( plugin.getGoals().isEmpty() || plugin.getGoalsAsMap().containsKey( mojoDescriptor.getGoal() ) ) - { - configureMojoPhaseBinding( mojoDescriptor, phaseMap, session.getSettings() ); + // TODO: remove later + if ( mojoDescriptor.getGoal() == null ) + { + throw new LifecycleExecutionException( + "The plugin " + artifactId + " was built with an older version of Maven" ); + } + + Goal goal = (Goal) goalMap.get( mojoDescriptor.getGoal() ); + + if( goalMap.isEmpty() ) + { + configureMojoPhaseBinding( mojoDescriptor, phaseMap, session.getSettings() ); + } + else if ( goal != null ) + { + // We have to check to see that the inheritance rules have been applied before binding this mojo. + if( goal.isInheritanceApplied() || mojoDescriptor.isInheritedByDefault() ) + { + configureMojoPhaseBinding( mojoDescriptor, phaseMap, session.getSettings() ); + } + } } } } diff --git a/maven-model/maven.mdo b/maven-model/maven.mdo index c34d6e498c..d897dc56fa 100644 --- a/maven-model/maven.mdo +++ b/maven-model/maven.mdo @@ -2050,9 +2050,9 @@ 4.0.0