mirror of https://github.com/apache/maven.git
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. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@178836 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6ca4de295d
commit
fda1ed95c9
|
@ -22,6 +22,7 @@ import org.apache.maven.artifact.handler.manager.ArtifactHandlerNotFoundExceptio
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||||
import org.apache.maven.execution.MavenExecutionResponse;
|
import org.apache.maven.execution.MavenExecutionResponse;
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
|
import org.apache.maven.model.Goal;
|
||||||
import org.apache.maven.model.Plugin;
|
import org.apache.maven.model.Plugin;
|
||||||
import org.apache.maven.model.PluginManagement;
|
import org.apache.maven.model.PluginManagement;
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
|
@ -240,12 +241,16 @@ public class DefaultLifecycleExecutor
|
||||||
throw new LifecycleExecutionException( "Internal error in the plugin manager", e );
|
throw new LifecycleExecutionException( "Internal error in the plugin manager", e );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( plugin.isInheritanceApplied() || pluginDescriptor.isInheritedByDefault() )
|
||||||
|
{
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Look to see if the plugin configuration specifies particular mojos
|
// Look to see if the plugin configuration specifies particular mojos
|
||||||
// within the plugin. If this is the case then simply configure the
|
// within the plugin. If this is the case then simply configure the
|
||||||
// mojos the user has specified and ignore the rest.
|
// mojos the user has specified and ignore the rest.
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
Map goalMap = plugin.getGoalsAsMap();
|
||||||
|
|
||||||
for ( Iterator j = pluginDescriptor.getMojos().iterator(); j.hasNext(); )
|
for ( Iterator j = pluginDescriptor.getMojos().iterator(); j.hasNext(); )
|
||||||
{
|
{
|
||||||
MojoDescriptor mojoDescriptor = (MojoDescriptor) j.next();
|
MojoDescriptor mojoDescriptor = (MojoDescriptor) j.next();
|
||||||
|
@ -257,10 +262,21 @@ public class DefaultLifecycleExecutor
|
||||||
"The plugin " + artifactId + " was built with an older version of Maven" );
|
"The plugin " + artifactId + " was built with an older version of Maven" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( plugin.getGoals().isEmpty() || plugin.getGoalsAsMap().containsKey( mojoDescriptor.getGoal() ) )
|
Goal goal = (Goal) goalMap.get( mojoDescriptor.getGoal() );
|
||||||
|
|
||||||
|
if( goalMap.isEmpty() )
|
||||||
{
|
{
|
||||||
configureMojoPhaseBinding( mojoDescriptor, phaseMap, session.getSettings() );
|
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() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2050,9 +2050,9 @@
|
||||||
<version>4.0.0</version>
|
<version>4.0.0</version>
|
||||||
<code><![CDATA[
|
<code><![CDATA[
|
||||||
private Map goalMap = null;
|
private Map goalMap = null;
|
||||||
private boolean inheritanceApplied = false;
|
private boolean inheritanceApplied = true;
|
||||||
|
|
||||||
public void setInheritanceApplied()
|
public void unsetInheritanceApplied()
|
||||||
{
|
{
|
||||||
this.inheritanceApplied = true;
|
this.inheritanceApplied = true;
|
||||||
}
|
}
|
||||||
|
@ -2120,9 +2120,9 @@
|
||||||
<codeSegments>
|
<codeSegments>
|
||||||
<codeSegment>
|
<codeSegment>
|
||||||
<code><![CDATA[
|
<code><![CDATA[
|
||||||
private boolean inheritanceApplied = false;
|
private boolean inheritanceApplied = true;
|
||||||
|
|
||||||
public void setInheritanceApplied()
|
public void unsetInheritanceApplied()
|
||||||
{
|
{
|
||||||
this.inheritanceApplied = true;
|
this.inheritanceApplied = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class MojoDescriptor
|
||||||
|
|
||||||
private PluginDescriptor pluginDescriptor;
|
private PluginDescriptor pluginDescriptor;
|
||||||
|
|
||||||
private boolean inheritedByDefault = false;
|
private boolean inheritedByDefault = true;
|
||||||
|
|
||||||
public MojoDescriptor()
|
public MojoDescriptor()
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,6 +41,8 @@ public class PluginDescriptor
|
||||||
|
|
||||||
private String source;
|
private String source;
|
||||||
|
|
||||||
|
private boolean inheritedByDefault = true;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@ -178,4 +180,14 @@ public class PluginDescriptor
|
||||||
{
|
{
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isInheritedByDefault()
|
||||||
|
{
|
||||||
|
return inheritedByDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInheritedByDefault( boolean inheritedByDefault )
|
||||||
|
{
|
||||||
|
this.inheritedByDefault = inheritedByDefault;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,13 @@ public class PluginDescriptorBuilder
|
||||||
pluginDescriptor.setVersion( c.getChild( "version" ).getValue() );
|
pluginDescriptor.setVersion( c.getChild( "version" ).getValue() );
|
||||||
pluginDescriptor.setGoalPrefix( c.getChild( "goalPrefix" ).getValue() );
|
pluginDescriptor.setGoalPrefix( c.getChild( "goalPrefix" ).getValue() );
|
||||||
|
|
||||||
|
String inheritedByDefault = c.getChild( "inheritedByDefault" ).getValue();
|
||||||
|
|
||||||
|
if ( inheritedByDefault != null )
|
||||||
|
{
|
||||||
|
pluginDescriptor.setInheritedByDefault( Boolean.valueOf( inheritedByDefault ).booleanValue() );
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Components
|
// Components
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
|
@ -70,6 +70,8 @@ public class PluginDescriptorGenerator
|
||||||
|
|
||||||
element( w, "goalPrefix", pluginDescriptor.getGoalPrefix() );
|
element( w, "goalPrefix", pluginDescriptor.getGoalPrefix() );
|
||||||
|
|
||||||
|
element( w, "inheritedByDefault", "" + pluginDescriptor.isInheritedByDefault() );
|
||||||
|
|
||||||
w.startElement( "mojos" );
|
w.startElement( "mojos" );
|
||||||
|
|
||||||
for ( Iterator it = pluginDescriptor.getMojos().iterator(); it.hasNext(); )
|
for ( Iterator it = pluginDescriptor.getMojos().iterator(); it.hasNext(); )
|
||||||
|
|
|
@ -68,9 +68,9 @@ public final class ModelUtils
|
||||||
ModelUtils.mergePluginDefinitions( childPlugin, parentPlugin, handleAsInheritance );
|
ModelUtils.mergePluginDefinitions( childPlugin, parentPlugin, handleAsInheritance );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( handleAsInheritance )
|
if ( handleAsInheritance && parentInherited == null )
|
||||||
{
|
{
|
||||||
assembledPlugin.setInheritanceApplied();
|
assembledPlugin.unsetInheritanceApplied();
|
||||||
}
|
}
|
||||||
|
|
||||||
assembledPlugins.put( assembledPlugin.getKey(), assembledPlugin );
|
assembledPlugins.put( assembledPlugin.getKey(), assembledPlugin );
|
||||||
|
@ -142,9 +142,9 @@ public final class ModelUtils
|
||||||
assembledGoal = childGoal;
|
assembledGoal = childGoal;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( handleAsInheritance )
|
if ( handleAsInheritance && parentInherited == null )
|
||||||
{
|
{
|
||||||
assembledGoal.setInheritanceApplied();
|
assembledGoal.unsetInheritanceApplied();
|
||||||
}
|
}
|
||||||
|
|
||||||
assembledGoals.put( assembledGoal.getId(), assembledGoal );
|
assembledGoals.put( assembledGoal.getId(), assembledGoal );
|
||||||
|
@ -165,6 +165,7 @@ public final class ModelUtils
|
||||||
}
|
}
|
||||||
|
|
||||||
child.setGoals( new ArrayList( assembledGoals.values() ) );
|
child.setGoals( new ArrayList( assembledGoals.values() ) );
|
||||||
|
|
||||||
child.flushGoalMap();
|
child.flushGoalMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue