Author: jdcasey Date: Fri May 27 16:05:09 2005 New Revision: 178836 URL: http://svn.apache.org/viewcvs?rev=178836&view=rev Log: o changed the inheritanceApplied flag to be set by default, and unset if the plugin is merged to the child without <inherit/> 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 <inherit/> 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.
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java maven/components/trunk/maven-model/maven.mdo maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java maven/components/trunk/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.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=178836&r1=178835&r2=178836&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 Fri May 27 16:05:09 2005 @@ -22,6 +22,7 @@ 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 @@ { 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(); - - // TODO: remove later - if ( mojoDescriptor.getGoal() == null ) + // ---------------------------------------------------------------------- + // 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. + // ---------------------------------------------------------------------- + + 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() ); + } + } } } } Modified: maven/components/trunk/maven-model/maven.mdo URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-model/maven.mdo?rev=178836&r1=178835&r2=178836&view=diff ============================================================================== --- maven/components/trunk/maven-model/maven.mdo (original) +++ maven/components/trunk/maven-model/maven.mdo Fri May 27 16:05:09 2005 @@ -2050,9 +2050,9 @@ <version>4.0.0</version> <code><![CDATA[ private Map goalMap = null; - private boolean inheritanceApplied = false; + private boolean inheritanceApplied = true; - public void setInheritanceApplied() + public void unsetInheritanceApplied() { this.inheritanceApplied = true; } @@ -2120,9 +2120,9 @@ <codeSegments> <codeSegment> <code><![CDATA[ - private boolean inheritanceApplied = false; + private boolean inheritanceApplied = true; - public void setInheritanceApplied() + public void unsetInheritanceApplied() { this.inheritanceApplied = true; } Modified: maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java?rev=178836&r1=178835&r2=178836&view=diff ============================================================================== --- maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java (original) +++ maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java Fri May 27 16:05:09 2005 @@ -75,7 +75,7 @@ private PluginDescriptor pluginDescriptor; - private boolean inheritedByDefault = false; + private boolean inheritedByDefault = true; public MojoDescriptor() { Modified: maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java?rev=178836&r1=178835&r2=178836&view=diff ============================================================================== --- maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java (original) +++ maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java Fri May 27 16:05:09 2005 @@ -41,6 +41,8 @@ private String source; + private boolean inheritedByDefault = true; + // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- @@ -177,5 +179,15 @@ public String getSource() { return source; + } + + public boolean isInheritedByDefault() + { + return inheritedByDefault; + } + + public void setInheritedByDefault( boolean inheritedByDefault ) + { + this.inheritedByDefault = inheritedByDefault; } } Modified: maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java?rev=178836&r1=178835&r2=178836&view=diff ============================================================================== --- maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java (original) +++ maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java Fri May 27 16:05:09 2005 @@ -38,6 +38,13 @@ pluginDescriptor.setVersion( c.getChild( "version" ).getValue() ); pluginDescriptor.setGoalPrefix( c.getChild( "goalPrefix" ).getValue() ); + String inheritedByDefault = c.getChild( "inheritedByDefault" ).getValue(); + + if ( inheritedByDefault != null ) + { + pluginDescriptor.setInheritedByDefault( Boolean.valueOf( inheritedByDefault ).booleanValue() ); + } + // ---------------------------------------------------------------------- // Components // ---------------------------------------------------------------------- Modified: maven/components/trunk/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java?rev=178836&r1=178835&r2=178836&view=diff ============================================================================== --- maven/components/trunk/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java (original) +++ maven/components/trunk/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java Fri May 27 16:05:09 2005 @@ -70,7 +70,9 @@ element( w, "goalPrefix", pluginDescriptor.getGoalPrefix() ); - w.startElement( "mojos" ); + element( w, "inheritedByDefault", "" + pluginDescriptor.isInheritedByDefault() ); + + w.startElement( "mojos" ); for ( Iterator it = pluginDescriptor.getMojos().iterator(); it.hasNext(); ) { Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java?rev=178836&r1=178835&r2=178836&view=diff ============================================================================== --- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java (original) +++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java Fri May 27 16:05:09 2005 @@ -68,9 +68,9 @@ ModelUtils.mergePluginDefinitions( childPlugin, parentPlugin, handleAsInheritance ); } - if ( handleAsInheritance ) + if ( handleAsInheritance && parentInherited == null ) { - assembledPlugin.setInheritanceApplied(); + assembledPlugin.unsetInheritanceApplied(); } assembledPlugins.put( assembledPlugin.getKey(), assembledPlugin ); @@ -142,9 +142,9 @@ assembledGoal = childGoal; } - if ( handleAsInheritance ) + if ( handleAsInheritance && parentInherited == null ) { - assembledGoal.setInheritanceApplied(); + assembledGoal.unsetInheritanceApplied(); } assembledGoals.put( assembledGoal.getId(), assembledGoal ); @@ -165,6 +165,7 @@ } child.setGoals( new ArrayList( assembledGoals.values() ) ); + child.flushGoalMap(); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]