Author: jdcasey
Date: Thu May 31 16:11:47 2007
New Revision: 543308
URL: http://svn.apache.org/viewvc?view=rev&rev=543308
Log:
OPEN - issue MNG-3027: forked execution does not get configuration from the POM
http://jira.codehaus.org/browse/MNG-3027
Adding reporting section to sources of plugin configuration when mojos are
forked from a report mojo. Also, improving detection/addition of report mojos
from a plugin, when no report-set is defined.
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/BindingUtils.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManager.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultMojoBindingFactory.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/LifecycleBindingManager.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/MojoBindingFactory.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlan.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DefaultBuildPlanner.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/ResolveLateBoundPluginMojo.java
maven/components/trunk/maven-core/src/main/resources/META-INF/maven/plugin.xml
maven/components/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/binding/DefaultMojoBindingFactoryTest.java
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
URL:
http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?view=diff&rev=543308&r1=543307&r2=543308
==============================================================================
---
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
Thu May 31 16:11:47 2007
@@ -95,7 +95,7 @@
/**
* Execute a task. Each task may be a phase in the lifecycle or the
execution of a mojo.
- *
+ *
* @param session
* @param rm
* @param dispatcher
@@ -547,7 +547,7 @@
/**
* @todo Not particularly happy about this. Would like WagonManager and
ArtifactTypeHandlerManager to be able to
* lookup directly, or have them passed in
- *
+ *
* @todo Move this sort of thing to the tail end of the project-building
process
*/
private Map findArtifactTypeHandlers( final MavenSession session )
@@ -644,7 +644,9 @@
final
MavenProject project )
throws LifecycleSpecificationException, PluginLoaderException,
LifecycleLoaderException
{
- MojoBinding binding = mojoBindingFactory.parseMojoBinding( task,
project, true );
+ // we don't need to include report configuration here, since we're
just looking for
+ // an @aggregator flag...
+ MojoBinding binding = mojoBindingFactory.parseMojoBinding( task,
project, true, false );
PluginDescriptor descriptor = pluginLoader.loadPlugin( binding,
project );
MojoDescriptor mojoDescriptor = descriptor.getMojo( binding.getGoal()
);
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/BindingUtils.java
URL:
http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/BindingUtils.java?view=diff&rev=543308&r1=543307&r2=543308
==============================================================================
---
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/BindingUtils.java
(original)
+++
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/BindingUtils.java
Thu May 31 16:11:47 2007
@@ -11,6 +11,7 @@
import org.apache.maven.model.PluginManagement;
import org.apache.maven.model.ReportPlugin;
import org.apache.maven.model.ReportSet;
+import org.apache.maven.model.Reporting;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ModelUtils;
@@ -37,7 +38,7 @@
static Map buildPluginMap( MavenProject project )
{
Map pluginMap = new HashMap();
-
+
if ( project != null )
{
Build build = project.getBuild();
@@ -56,14 +57,40 @@
}
/**
+ * Builds a mapping of groupId:artifactId --> ReportPlugin from the
POM. If a plugin is listed
+ * without a groupId, the [EMAIL PROTECTED]
BindingUtils#createPluginKey(Plugin)} method will fill it in
+ * using org.apache.maven.plugins.
+ */
+ static Map buildReportPluginMap( MavenProject project )
+ {
+ Map pluginMap = new HashMap();
+
+ if ( project != null )
+ {
+ Reporting reporting = project.getReporting();
+ if ( reporting != null )
+ {
+ for ( Iterator it = reporting.getPlugins().iterator();
it.hasNext(); )
+ {
+ ReportPlugin plugin = (ReportPlugin) it.next();
+
+ pluginMap.put( createPluginKey( plugin.getGroupId(),
plugin.getArtifactId() ), plugin );
+ }
+ }
+ }
+
+ return pluginMap;
+ }
+
+ /**
* Builds a mapping of groupId:artifactId --> Plugin from a
PluginContainer, such as the build
- * or pluginManagement section of a POM. If a plugin is listed without a
groupId, the
+ * or pluginManagement section of a POM. If a plugin is listed without a
groupId, the
* [EMAIL PROTECTED] BindingUtils#createPluginKey(Plugin)} method will
fill it in using org.apache.maven.plugins.
*/
static Map buildPluginMap( PluginContainer pluginContainer )
{
Map pluginMap = new HashMap();
-
+
if ( pluginContainer != null )
{
for ( Iterator it = pluginContainer.getPlugins().iterator();
it.hasNext(); )
@@ -87,7 +114,7 @@
}
/**
- * Create a key for use in looking up Plugin instances from mappings. The
key consists of
+ * Create a key for use in looking up Plugin instances from mappings. The
key consists of
* groupId:artifactId, where groupId == org.apache.maven.plugins if the
supplied groupId
* value == null.
*/
@@ -102,7 +129,7 @@
*/
static Object mergeConfigurations( ReportPlugin reportPlugin, ReportSet
reportSet )
{
- if ( reportPlugin == null && reportSet == null )
+ if ( ( reportPlugin == null ) && ( reportSet == null ) )
{
return null;
}
@@ -121,12 +148,12 @@
}
/**
- * Merge the Plugin and PluginExecution configurations, with the
PluginExecution configuration
+ * Merge the Plugin and PluginExecution configurations, with the
PluginExecution configuration
* taking precedence.
*/
static Object mergeConfigurations( Plugin plugin, PluginExecution
execution )
{
- if ( plugin == null && execution == null )
+ if ( ( plugin == null ) && ( execution == null ) )
{
return null;
}
@@ -167,15 +194,17 @@
return Xpp3Dom.mergeXpp3Dom( new Xpp3Dom( dominantConfig ),
recessiveConfig );
}
}
-
+
/**
* Inject any plugin configuration available from the specified POM into
the MojoBinding, after
* first merging in the applicable configuration from the POM's
pluginManagement section.
*/
- static void injectProjectConfiguration( MojoBinding binding, MavenProject
project )
+ static void injectProjectConfiguration( MojoBinding binding, MavenProject
project, boolean includeReportConfig )
{
Map pluginMap = buildPluginMap( project );
- Plugin plugin = (Plugin) pluginMap.get( createPluginKey(
binding.getGroupId(), binding.getArtifactId() ) );
+
+ String key = createPluginKey( binding.getGroupId(),
binding.getArtifactId() );
+ Plugin plugin = (Plugin) pluginMap.get( key );
if ( plugin == null )
{
@@ -183,17 +212,41 @@
plugin.setGroupId( binding.getGroupId() );
plugin.setArtifactId( binding.getArtifactId() );
}
-
+
injectPluginManagementInfo( plugin, project );
PluginExecution exec = (PluginExecution)
plugin.getExecutionsAsMap().get( binding.getExecutionId() );
- binding.setConfiguration( mergeConfigurations( plugin, exec ) );
+ Object configuration = mergeConfigurations( plugin, exec );
+
+ if ( includeReportConfig )
+ {
+ ReportPlugin reportPlugin = (ReportPlugin)
BindingUtils.buildReportPluginMap( project ).get( key );
+ if ( reportPlugin != null )
+ {
+ Map reportSets = reportPlugin.getReportSetsAsMap();
+
+ ReportSet reportSet = null;
+ if ( ( reportSets != null ) && ( exec != null ) )
+ {
+ reportSet = (ReportSet) reportSets.get( exec.getId() );
+ }
+
+ Object reportConfig = BindingUtils.mergeConfigurations(
reportPlugin, reportSet );
+
+ // NOTE: This looks weird, but we must retain some consistency
with
+ // dominance of plugin configs, regardless of whether they're
report
+ // mojos or not.
+ configuration = mergeRawConfigurations( reportConfig,
configuration );
+ }
+ }
+
+ binding.setConfiguration( configuration );
}
/**
- * Inject any plugin configuration available from the specified POM into
the MojoBindings
- * present in the given LifecycleBindings instance, after first merging in
the configuration
+ * Inject any plugin configuration available from the specified POM into
the MojoBindings
+ * present in the given LifecycleBindings instance, after first merging in
the configuration
* from the POM's pluginManagement section.
*/
static void injectProjectConfiguration( LifecycleBindings bindings,
MavenProject project )
@@ -221,7 +274,7 @@
plugin.setGroupId( mojo.getGroupId() );
plugin.setArtifactId( mojo.getArtifactId() );
}
-
+
injectPluginManagementInfo( plugin, project );
PluginExecution exec = (PluginExecution)
plugin.getExecutionsAsMap().get( mojo.getExecutionId() );
@@ -242,24 +295,24 @@
{
return;
}
-
+
Build build = project.getBuild();
if ( build == null )
{
return;
}
-
+
PluginManagement plugMgmt = build.getPluginManagement();
if ( plugMgmt == null )
{
return;
}
-
+
Map plugMgmtMap = buildPluginMap( plugMgmt );
-
+
String key = createPluginKey( plugin );
Plugin mgmtPlugin = (Plugin) plugMgmtMap.get( key );
-
+
if ( mgmtPlugin != null )
{
ModelUtils.mergePluginDefinitions( plugin, mgmtPlugin, false );
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManager.java
URL:
http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManager.java?view=diff&rev=543308&r1=543307&r2=543308
==============================================================================
---
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManager.java
(original)
+++
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultLifecycleBindingManager.java
Thu May 31 16:11:47 2007
@@ -18,6 +18,8 @@
import org.apache.maven.plugin.loader.PluginLoader;
import org.apache.maven.plugin.loader.PluginLoaderException;
import org.apache.maven.project.MavenProject;
+import org.apache.maven.reporting.MavenReport;
+import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.collections.ActiveMap;
import
org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.logging.LogEnabled;
@@ -29,18 +31,18 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.StringTokenizer;
/**
* Responsible for the gross construction of LifecycleBindings, or mappings of
MojoBinding instances to different parts
* of the three lifecycles: clean, build, and site. Also, handles transcribing
these LifecycleBindings instances into
* lists of MojoBinding's, which can be consumed by the LifecycleExecutor.
- *
+ *
* @author jdcasey
- *
+ *
*/
-public class DefaultLifecycleBindingManager implements
LifecycleBindingManager, LogEnabled
+public class DefaultLifecycleBindingManager
+ implements LifecycleBindingManager, LogEnabled
{
private ActiveMap bindingsByPackaging;
@@ -314,7 +316,8 @@
* plugin. Inject mojo configuration from the POM into all appropriate
MojoBinding instances.
*/
public LifecycleBindings getPluginLifecycleOverlay( final PluginDescriptor
pluginDescriptor,
- final String
lifecycleId, final MavenProject project )
+ final String
lifecycleId, final MavenProject project,
+ final boolean
includeReportConfig )
throws LifecycleLoaderException, LifecycleSpecificationException
{
Lifecycle lifecycleOverlay = null;
@@ -381,7 +384,7 @@
MojoBinding binding;
if ( goal.indexOf( ":" ) > 0 )
{
- binding = mojoBindingFactory.parseMojoBinding( goal,
project, false );
+ binding = mojoBindingFactory.parseMojoBinding( goal,
project, false, includeReportConfig );
}
else
{
@@ -447,7 +450,7 @@
{
if ( project.getModel().getReports() != null )
{
- logger.error( "Plugin contains a <reports/> section: this is
IGNORED - please use <reporting/> instead." );
+ logger.warn( "Plugin contains a <reports/> section: this is
IGNORED - please use <reporting/> instead." );
}
List reportPlugins = getReportPluginsForProject( project );
@@ -553,14 +556,25 @@
+ e.getMessage(), e );
}
- String pluginKey = BindingUtils.createPluginKey(
reportPlugin.getGroupId(), reportPlugin.getArtifactId() );
- Plugin plugin = (Plugin) BindingUtils.buildPluginMap( project ).get(
pluginKey );
-
List reports = new ArrayList();
for ( Iterator i = pluginDescriptor.getMojos().iterator();
i.hasNext(); )
{
MojoDescriptor mojoDescriptor = (MojoDescriptor) i.next();
+
+ // FIXME: Can't we be smarter about what is and what is not a
report???
+ try
+ {
+ if ( !isReport( mojoDescriptor ) )
+ {
+ continue;
+ }
+ }
+ catch ( ClassNotFoundException e )
+ {
+ throw new LifecycleLoaderException( "Failed while verifying
that mojo: " + mojoDescriptor.getId() + " is a report mojo. Reason: " +
e.getMessage(), e );
+ }
+
// TODO: check ID is correct for reports
// if the POM configured no reports, give all from plugin
if ( ( reportSet == null ) || reportSet.getReports().contains(
mojoDescriptor.getGoal() ) )
@@ -579,34 +593,24 @@
binding.setExecutionId( id );
binding.setOrigin( "POM" );
- Object reportConfig = BindingUtils.mergeConfigurations(
reportPlugin, reportSet );
-
- if ( plugin == null )
- {
- plugin = new Plugin();
- plugin.setGroupId( pluginDescriptor.getGroupId() );
- plugin.setArtifactId( pluginDescriptor.getArtifactId() );
- }
-
- BindingUtils.injectPluginManagementInfo( plugin, project );
-
- Map execMap = plugin.getExecutionsAsMap();
- PluginExecution exec = (PluginExecution) execMap.get( id );
-
- Object pluginConfig = plugin.getConfiguration();
- if ( exec != null )
- {
- pluginConfig = BindingUtils.mergeConfigurations( plugin,
exec );
- }
-
- reportConfig = BindingUtils.mergeRawConfigurations(
reportConfig, pluginConfig );
-
- binding.setConfiguration( reportConfig );
+ BindingUtils.injectProjectConfiguration( binding, project,
true );
reports.add( binding );
}
}
return reports;
+ }
+
+ private boolean isReport( MojoDescriptor mojoDescriptor )
+ throws ClassNotFoundException
+ {
+ ClassRealm classRealm =
mojoDescriptor.getPluginDescriptor().getClassRealm();
+ String impl = mojoDescriptor.getImplementation();
+
+ Class mojoClass = classRealm.loadClass( impl );
+ Class reportClass = classRealm.loadClass( MavenReport.class.getName()
);
+
+ return reportClass.isAssignableFrom( mojoClass );
}
}
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultMojoBindingFactory.java
URL:
http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultMojoBindingFactory.java?view=diff&rev=543308&r1=543307&r2=543308
==============================================================================
---
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultMojoBindingFactory.java
(original)
+++
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/DefaultMojoBindingFactory.java
Thu May 31 16:11:47 2007
@@ -13,7 +13,7 @@
/**
* Responsible for constructing or parsing MojoBinding instances from one of
several sources, potentially
* using the [EMAIL PROTECTED] PluginLoader} to resolve any plugin prefixes
first.
- *
+ *
* @author jdcasey
*
*/
@@ -28,7 +28,7 @@
* If a plugin-prefix is allowed and used, resolve the prefix and use the
resulting PluginDescriptor
* to set groupId and artifactId on the MojoBinding instance.
*/
- public MojoBinding parseMojoBinding( String bindingSpec, MavenProject
project, boolean allowPrefixReference )
+ public MojoBinding parseMojoBinding( String bindingSpec, MavenProject
project, boolean allowPrefixReference, boolean includeReportConfig )
throws LifecycleSpecificationException, LifecycleLoaderException
{
StringTokenizer tok = new StringTokenizer( bindingSpec, ":" );
@@ -61,9 +61,9 @@
}
binding = createMojoBinding( pluginDescriptor.getGroupId(),
pluginDescriptor.getArtifactId(),
- pluginDescriptor.getVersion(),
tok.nextToken(), project );
+ pluginDescriptor.getVersion(),
tok.nextToken(), project, includeReportConfig );
}
- else if ( numTokens == 3 || numTokens == 4 )
+ else if ( ( numTokens == 3 ) || ( numTokens == 4 ) )
{
binding = new MojoBinding();
@@ -78,7 +78,7 @@
String goal = tok.nextToken();
- binding = createMojoBinding( groupId, artifactId, version, goal,
project );
+ binding = createMojoBinding( groupId, artifactId, version, goal,
project, includeReportConfig );
}
else
{
@@ -95,7 +95,7 @@
* Create a new MojoBinding instance with the specified information, and
inject POM configurations
* appropriate to that mojo before returning it.
*/
- public MojoBinding createMojoBinding( String groupId, String artifactId,
String version, String goal, MavenProject project )
+ public MojoBinding createMojoBinding( String groupId, String artifactId,
String version, String goal, MavenProject project, boolean includeReportConfig )
{
MojoBinding binding = new MojoBinding();
@@ -104,7 +104,7 @@
binding.setVersion( version );
binding.setGoal( goal );
- BindingUtils.injectProjectConfiguration( binding, project );
+ BindingUtils.injectProjectConfiguration( binding, project,
includeReportConfig );
return binding;
}
@@ -119,15 +119,15 @@
{
try
{
- return parseMojoBinding( bindingSpec, null, false );
+ return parseMojoBinding( bindingSpec, null, false, false );
}
catch ( LifecycleLoaderException e )
{
IllegalStateException error = new IllegalStateException(
e.getMessage()
+ "\n\nTHIS SHOULD BE IMPOSSIBLE DUE TO THE USAGE OF THE
PLUGIN-LOADER." );
-
+
error.initCause( e );
-
+
throw error;
}
}
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/LifecycleBindingManager.java
URL:
http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/LifecycleBindingManager.java?view=diff&rev=543308&r1=543307&r2=543308
==============================================================================
---
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/LifecycleBindingManager.java
(original)
+++
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/LifecycleBindingManager.java
Thu May 31 16:11:47 2007
@@ -12,9 +12,9 @@
* Responsible for the gross construction of LifecycleBindings, or mappings of
MojoBinding instances to different parts
* of the three lifecycles: clean, build, and site. Also, handles transcribing
these LifecycleBindings instances into
* lists of MojoBinding's, which can be consumed by the LifecycleExecutor.
- *
+ *
* @author jdcasey
- *
+ *
*/
public interface LifecycleBindingManager
{
@@ -45,7 +45,7 @@
* plugin. Inject mojo configuration from the POM into all appropriate
MojoBinding instances.
*/
LifecycleBindings getPluginLifecycleOverlay( PluginDescriptor
pluginDescriptor, String lifecycleId,
- MavenProject project )
+ MavenProject project, boolean
includeReportConfig )
throws LifecycleLoaderException, LifecycleSpecificationException;
/**
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/MojoBindingFactory.java
URL:
http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/MojoBindingFactory.java?view=diff&rev=543308&r1=543307&r2=543308
==============================================================================
---
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/MojoBindingFactory.java
(original)
+++
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/binding/MojoBindingFactory.java
Thu May 31 16:11:47 2007
@@ -9,7 +9,7 @@
/**
* Responsible for constructing or parsing MojoBinding instances from one of
several sources, potentially
* using the [EMAIL PROTECTED] PluginLoader} to resolve any plugin prefixes
first.
- *
+ *
* @author jdcasey
*
*/
@@ -23,14 +23,14 @@
* If a plugin-prefix is allowed and used, resolve the prefix and use the
resulting PluginDescriptor
* to set groupId and artifactId on the MojoBinding instance.
*/
- MojoBinding parseMojoBinding( String bindingSpec, MavenProject project,
boolean allowPrefixReference )
+ MojoBinding parseMojoBinding( String bindingSpec, MavenProject project,
boolean allowPrefixReference, boolean includeReportConfig )
throws LifecycleSpecificationException, LifecycleLoaderException;
/**
* Create a new MojoBinding instance with the specified information, and
inject POM configurations
* appropriate to that mojo before returning it.
*/
- MojoBinding createMojoBinding( String groupId, String artifactId, String
version, String goal, MavenProject project );
+ MojoBinding createMojoBinding( String groupId, String artifactId, String
version, String goal, MavenProject project, boolean includeReportConfig );
/**
* Simplified version of [EMAIL PROTECTED]
MojoBindingFactory#parseMojoBinding(String, MavenProject, boolean)}
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlan.java
URL:
http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlan.java?view=diff&rev=543308&r1=543307&r2=543308
==============================================================================
---
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlan.java
(original)
+++
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlan.java
Thu May 31 16:11:47 2007
@@ -23,7 +23,9 @@
private final List tasks;
- private final Map forks;
+ private final Map forkedDirectInvocations;
+
+ private final Map forkedPhases;
private final List lateBoundMojos;
@@ -43,16 +45,18 @@
{
this.bindings = bindings;
this.tasks = tasks;
- forks = new HashMap();
+ forkedDirectInvocations = new HashMap();
+ forkedPhases = new HashMap();
lateBoundMojos = new ArrayList();
directInvocationBindings = new HashMap();
}
- private BuildPlan( final LifecycleBindings bindings, final Map forks,
final List lateBoundMojos,
+ private BuildPlan( final LifecycleBindings bindings, final Map
forkedDirectInvocations, final Map forkedPhases, final List lateBoundMojos,
final Map directInvocationBindings, final List tasks )
{
this.bindings = LifecycleUtils.cloneBindings( bindings );
- this.forks = new HashMap( forks );
+ this.forkedDirectInvocations = new HashMap( forkedDirectInvocations );
+ this.forkedPhases = new HashMap( forkedPhases );
this.lateBoundMojos = new ArrayList( lateBoundMojos );
this.tasks = tasks;
this.directInvocationBindings = new HashMap( directInvocationBindings
);
@@ -100,23 +104,36 @@
return directInvocationBindings;
}
- public Map getForks()
+ public Map getForkedDirectInvocations()
+ {
+ return forkedDirectInvocations;
+ }
+
+ public Map getForkedPhases()
{
- return forks;
+ return forkedPhases;
}
public void addForkedExecution( final MojoBinding mojoBinding, final
BuildPlan plan )
{
String key = MojoBindingUtils.createMojoBindingKey( mojoBinding, false
);
- forks.put( key, plan );
+ forkedPhases.put( key, plan );
}
public void addForkedExecution( final MojoBinding mojoBinding, final List
forkedInvocations )
{
String key = MojoBindingUtils.createMojoBindingKey( mojoBinding, false
);
- forks.put( key, forkedInvocations );
+ List invoke = (List) forkedDirectInvocations.get( key );
+
+ if ( invoke == null )
+ {
+ invoke = new ArrayList();
+ forkedDirectInvocations.put( key, invoke );
+ }
+
+ invoke.addAll( forkedInvocations );
}
public void addLateBoundMojo( final MojoBinding mojoBinding )
@@ -126,12 +143,17 @@
public BuildPlan copy( final List newTasks )
{
- return new BuildPlan( bindings, forks, lateBoundMojos,
directInvocationBindings, newTasks );
+ return new BuildPlan( bindings, forkedDirectInvocations, forkedPhases,
lateBoundMojos, directInvocationBindings, newTasks );
}
public void resetExecutionProgress()
{
renderedLifecycleMojos = new ArrayList();
+ for ( Iterator it = forkedPhases.values().iterator(); it.hasNext(); )
+ {
+ BuildPlan plan = (BuildPlan) it.next();
+ plan.resetExecutionProgress();
+ }
}
public List renderExecutionPlan( final Stack executionStack )
@@ -207,69 +229,54 @@
String key = MojoBindingUtils.createMojoBindingKey( mojoBinding, false
);
- // let's see if we have any forks...
- Object fork = forks.get( key );
-
executionStack.push( key );
try
{
- if ( fork != null )
+ List forkedBindings = new ArrayList();
+
+ BuildPlan forkedPlan = (BuildPlan) forkedPhases.get( key );
+
+ // if we have a forked build plan, recurse into it and retrieve
the execution plan.
+ if ( forkedPlan != null )
{
- List forkedBindings = new ArrayList();
+ forkedBindings = forkedPlan.renderExecutionPlan(
executionStack );
+ }
- // if the fork is a build plan, recurse into it and retrieve
the execution plan.
- if ( fork instanceof BuildPlan )
- {
- forkedBindings = ( (BuildPlan) fork ).renderExecutionPlan(
executionStack );
- }
- // leave room for new kinds of forks, and do some extra
validation...
- // if this is a list, it's a list of direct mojo
invocations...we have to see if they have their own
- // forks.
- else if ( fork instanceof List )
+ List directInvocations = (List) forkedDirectInvocations.get( key );
+
+ // leave room for new kinds of forks, and do some extra
validation...
+ // if this is a list, it's a list of direct mojo invocations...we
have to see if they have their own
+ // forks.
+ if ( directInvocations != null )
+ {
+ for ( Iterator it = directInvocations.iterator();
it.hasNext(); )
{
- List directInvocations = (List) fork;
- for ( Iterator it = directInvocations.iterator();
it.hasNext(); )
- {
- MojoBinding invocation = (MojoBinding) it.next();
+ MojoBinding invocation = (MojoBinding) it.next();
- String invocationKey =
MojoBindingUtils.createMojoBindingKey( invocation, false );
+ String invocationKey =
MojoBindingUtils.createMojoBindingKey( invocation, false );
- if ( executionStack.contains( invocationKey ) )
- {
- continue;
- }
-
- executionStack.push(
MojoBindingUtils.createMojoBindingKey( mojoBinding, false ) );
-
- try
- {
- addResolverIfLateBound( invocation, forkedBindings
);
- forkedBindings.addAll( findForkedBindings(
invocation, executionStack ) );
- }
- finally
- {
- executionStack.pop();
- }
+ if ( executionStack.contains( invocationKey ) )
+ {
+ continue;
}
- }
- if ( !forkedBindings.isEmpty() )
- {
- bindings.add(
StateManagementUtils.createStartForkedExecutionMojoBinding() );
- bindings.addAll( forkedBindings );
- bindings.add(
StateManagementUtils.createEndForkedExecutionMojoBinding() );
+ addResolverIfLateBound( invocation, forkedBindings );
+ forkedBindings.addAll( findForkedBindings( invocation,
executionStack ) );
}
+ }
- bindings.add( mojoBinding );
-
- if ( !forkedBindings.isEmpty() )
- {
- bindings.add(
StateManagementUtils.createClearForkedExecutionMojoBinding() );
- }
+ if ( !forkedBindings.isEmpty() )
+ {
+ bindings.add(
StateManagementUtils.createStartForkedExecutionMojoBinding() );
+ bindings.addAll( forkedBindings );
+ bindings.add(
StateManagementUtils.createEndForkedExecutionMojoBinding() );
}
- else
+
+ bindings.add( mojoBinding );
+
+ if ( !forkedBindings.isEmpty() )
{
- bindings.add( mojoBinding );
+ bindings.add(
StateManagementUtils.createClearForkedExecutionMojoBinding() );
}
}
finally
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DefaultBuildPlanner.java
URL:
http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DefaultBuildPlanner.java?view=diff&rev=543308&r1=543307&r2=543308
==============================================================================
---
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DefaultBuildPlanner.java
(original)
+++
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DefaultBuildPlanner.java
Thu May 31 16:11:47 2007
@@ -27,9 +27,9 @@
* MojoBinding instances that carry all the information necessary to execute a
mojo, including configuration from the
* POM and other sources. NOTE: the build plan may be constructed of a main
lifecycle binding-set, plus any number of
* lifecycle modifiers and direct-invocation modifiers, to handle cases of
forked execution.
- *
+ *
* @author jdcasey
- *
+ *
*/
public class DefaultBuildPlanner
implements BuildPlanner, LogEnabled
@@ -78,7 +78,9 @@
if ( !LifecycleUtils.isValidPhaseName( task ) )
{
- MojoBinding binding = mojoBindingFactory.parseMojoBinding(
task, project, true );
+ logger.warn( "Assuming that mojo: \'" + task + "\' does NOT
need configuration from the <reporting /> section of the POM." );
+
+ MojoBinding binding = mojoBindingFactory.parseMojoBinding(
task, project, true, false );
plan.addDirectInvocationBinding( task, binding );
}
}
@@ -124,7 +126,7 @@
+ pluginDescriptor.getId() +
"." );
}
- findForkModifiers( mojoBinding, pluginDescriptor, plan, project );
+ findForkModifiers( mojoBinding, pluginDescriptor, plan, project, false
);
}
/**
@@ -172,7 +174,7 @@
if ( pd != null )
{
- findForkModifiers( reportBinding, pd, plan,
project );
+ findForkModifiers( reportBinding, pd, plan,
project, true );
}
}
}
@@ -218,7 +220,7 @@
* forked execution, along with any new mojos/lifecycles that entails.
*/
private void findForkModifiers( final MojoBinding mojoBinding, final
PluginDescriptor pluginDescriptor,
- final BuildPlan plan, final MavenProject
project )
+ final BuildPlan plan, final MavenProject
project, final boolean includeReportConfig )
throws LifecyclePlannerException, LifecycleSpecificationException,
LifecycleLoaderException
{
String referencingGoal = mojoBinding.getGoal();
@@ -233,11 +235,11 @@
if ( mojoDescriptor.getExecuteGoal() != null )
{
- recurseSingleMojoFork( mojoBinding, pluginDescriptor, plan,
project );
+ recurseSingleMojoFork( mojoBinding, pluginDescriptor, plan,
project, includeReportConfig );
}
else if ( mojoDescriptor.getExecutePhase() != null )
{
- recursePhaseMojoFork( mojoBinding, pluginDescriptor, plan, project
);
+ recursePhaseMojoFork( mojoBinding, pluginDescriptor, plan,
project, includeReportConfig );
}
}
@@ -245,13 +247,14 @@
* Constructs the lifecycle bindings used to execute a particular fork,
given the forking mojo binding. If the mojo
* binding specifies a lifecycle overlay, this method will add that into
the forked lifecycle, and calculate the
* bindings to inject based on the phase in that new lifecycle which
should be executed.
- *
+ *
* Hands off to the
* [EMAIL PROTECTED]
DefaultBuildPlanner#modifyBuildPlanForForkedLifecycle(MojoBinding,
PluginDescriptor, ModifiablePlanElement, LifecycleBindings, MavenProject,
LinkedList, List)}
* method to handle the actual plan modification.
*/
private void recursePhaseMojoFork( final MojoBinding mojoBinding, final
PluginDescriptor pluginDescriptor,
- final BuildPlan plan, final
MavenProject project )
+ final BuildPlan plan, final
MavenProject project,
+ final boolean includeReportConfig )
throws LifecyclePlannerException, LifecycleSpecificationException,
LifecycleLoaderException
{
String referencingGoal = mojoBinding.getGoal();
@@ -279,7 +282,7 @@
try
{
overlayBindings =
- lifecycleBindingManager.getPluginLifecycleOverlay(
pluginDescriptor, executeLifecycle, project );
+ lifecycleBindingManager.getPluginLifecycleOverlay(
pluginDescriptor, executeLifecycle, project, includeReportConfig );
}
catch ( LifecycleLoaderException e )
{
@@ -302,7 +305,7 @@
* method to actually inject the modification.
*/
private void recurseSingleMojoFork( final MojoBinding mojoBinding, final
PluginDescriptor pluginDescriptor,
- final BuildPlan plan, final
MavenProject project )
+ final BuildPlan plan, final
MavenProject project, final boolean includeReportConfig )
throws LifecyclePlannerException, LifecycleSpecificationException,
LifecycleLoaderException
{
String referencingGoal = mojoBinding.getGoal();
@@ -325,7 +328,7 @@
MojoBinding binding =
mojoBindingFactory.createMojoBinding(
pluginDescriptor.getGroupId(), pluginDescriptor.getArtifactId(),
-
pluginDescriptor.getVersion(), executeGoal, project );
+
pluginDescriptor.getVersion(), executeGoal, project, includeReportConfig );
binding.setOrigin( "Forked from " + referencingGoal );
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/ResolveLateBoundPluginMojo.java
URL:
http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/ResolveLateBoundPluginMojo.java?view=diff&rev=543308&r1=543307&r2=543308
==============================================================================
---
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/ResolveLateBoundPluginMojo.java
(original)
+++
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/statemgmt/ResolveLateBoundPluginMojo.java
Thu May 31 16:11:47 2007
@@ -28,13 +28,15 @@
private String goal;
+ private boolean includeReportConfig = false;
+
private MavenProject project;
private MojoBindingFactory bindingFactory;
public void execute() throws MojoExecutionException, MojoFailureException
{
- MojoBinding binding = bindingFactory.createMojoBinding( groupId,
artifactId, version, artifactId, project );
+ MojoBinding binding = bindingFactory.createMojoBinding( groupId,
artifactId, version, artifactId, project, includeReportConfig );
try
{
PluginDescriptor descriptor = pluginLoader.loadPlugin( binding,
project );
Modified:
maven/components/trunk/maven-core/src/main/resources/META-INF/maven/plugin.xml
URL:
http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/resources/META-INF/maven/plugin.xml?view=diff&rev=543308&r1=543307&r2=543308
==============================================================================
---
maven/components/trunk/maven-core/src/main/resources/META-INF/maven/plugin.xml
(original)
+++
maven/components/trunk/maven-core/src/main/resources/META-INF/maven/plugin.xml
Thu May 31 16:11:47 2007
@@ -162,6 +162,13 @@
<editable>true</editable>
<description>The mojo's goal that we're looking for, as an extra
validation step.</description>
</parameter>
+ <parameter>
+ <name>includeReportConfig</name>
+ <type>boolean</type>
+ <required>false</required>
+ <editable>true</editable>
+ <description>Whether the mojo should include plugin-configuration
from the reporting section.</description>
+ </parameter>
</parameters>
<configuration>
<project implementation="org.apache.maven.project.MavenProject"
default-value="${project}"/>
@@ -169,6 +176,7 @@
<artifactId
implementation="java.lang.String">${artifactId}</artifactId>
<version implementation="java.lang.String">${version}</version>
<goal implementation="java.lang.String">${goal}</goal>
+ <includeReportConfig>false</includeReportConfig>
</configuration>
<requirements>
<requirement>
Modified:
maven/components/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/binding/DefaultMojoBindingFactoryTest.java
URL:
http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/binding/DefaultMojoBindingFactoryTest.java?view=diff&rev=543308&r1=543307&r2=543308
==============================================================================
---
maven/components/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/binding/DefaultMojoBindingFactoryTest.java
(original)
+++
maven/components/trunk/maven-core/src/test/java/org/apache/maven/lifecycle/binding/DefaultMojoBindingFactoryTest.java
Thu May 31 16:11:47 2007
@@ -12,11 +12,11 @@
{
private MojoBindingFactory factory;
-
+
public void setUp() throws Exception
{
super.setUp();
-
+
factory = (MojoBindingFactory) lookup( MojoBindingFactory.ROLE,
"default" );
}
@@ -27,7 +27,7 @@
try
{
- factory.parseMojoBinding( spec, new MavenProject( new Model() ),
false );
+ factory.parseMojoBinding( spec, new MavenProject( new Model() ),
false, false );
fail( "Should fail when prefix references are not allowed." );
}
@@ -42,7 +42,7 @@
{
String spec = "group:artifact:goal";
- MojoBinding binding = factory.parseMojoBinding( spec, new
MavenProject( new Model() ), false );
+ MojoBinding binding = factory.parseMojoBinding( spec, new
MavenProject( new Model() ), false, false );
assertEquals( "group", binding.getGroupId() );
assertEquals( "artifact", binding.getArtifactId() );
@@ -55,7 +55,7 @@
{
String spec = "group:artifact:version:goal";
- MojoBinding binding = factory.parseMojoBinding( spec, new
MavenProject( new Model() ), false );
+ MojoBinding binding = factory.parseMojoBinding( spec, new
MavenProject( new Model() ), false, false );
assertEquals( "group", binding.getGroupId() );
assertEquals( "artifact", binding.getArtifactId() );
@@ -70,7 +70,7 @@
try
{
- factory.parseMojoBinding( spec, new MavenProject( new Model() ),
false );
+ factory.parseMojoBinding( spec, new MavenProject( new Model() ),
false, false );
fail( "Should fail because spec has too many parts (type part is
not allowed)." );
}