Make reporting plugin configuration always used (even if mojo in question is not a report), as in 2.0.x

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@592949 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2007-11-07 23:28:45 +00:00
parent febce07c90
commit ed568e725f
11 changed files with 36 additions and 59 deletions

View File

@ -23,7 +23,6 @@ import org.apache.maven.AggregatedBuildFailureException;
import org.apache.maven.BuildFailureException;
import org.apache.maven.NoGoalsSpecifiedException;
import org.apache.maven.ProjectBuildFailureException;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.context.BuildContextManager;
@ -84,8 +83,6 @@ public class DefaultLifecycleExecutor
private BuildPlanner buildPlanner;
private ArtifactHandlerManager artifactHandlerManager;
private MojoBindingFactory mojoBindingFactory;
private BuildContextManager buildContextManager;
@ -768,8 +765,7 @@ public class DefaultLifecycleExecutor
MojoBinding binding = mojoBindingFactory.parseMojoBinding(
task,
project,
true,
false );
true );
PluginDescriptor descriptor = pluginLoader.loadPlugin(
binding,

View File

@ -199,7 +199,7 @@ final class BindingUtils
* 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, boolean includeReportConfig )
static void injectProjectConfiguration( MojoBinding binding, MavenProject project )
{
Map pluginMap = buildPluginMap( project );
@ -219,26 +219,23 @@ final class BindingUtils
Object configuration = mergeConfigurations( plugin, exec );
if ( includeReportConfig )
ReportPlugin reportPlugin = (ReportPlugin) BindingUtils.buildReportPluginMap( project ).get( key );
if ( reportPlugin != null )
{
ReportPlugin reportPlugin = (ReportPlugin) BindingUtils.buildReportPluginMap( project ).get( key );
if ( reportPlugin != null )
Map reportSets = reportPlugin.getReportSetsAsMap();
ReportSet reportSet = null;
if ( ( reportSets != null ) && ( exec != 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 );
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 );

View File

@ -276,8 +276,7 @@ public class DefaultLifecycleBindingManager
* 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 boolean includeReportConfig )
final String lifecycleId, final MavenProject project )
throws LifecycleLoaderException, LifecycleSpecificationException
{
Lifecycle lifecycleOverlay = null;
@ -344,7 +343,7 @@ public class DefaultLifecycleBindingManager
MojoBinding binding;
if ( goal.indexOf( ":" ) > 0 )
{
binding = mojoBindingFactory.parseMojoBinding( goal, project, false, includeReportConfig );
binding = mojoBindingFactory.parseMojoBinding( goal, project, false );
}
else
{
@ -553,7 +552,7 @@ public class DefaultLifecycleBindingManager
binding.setExecutionId( id );
binding.setOrigin( "POM" );
BindingUtils.injectProjectConfiguration( binding, project, true );
BindingUtils.injectProjectConfiguration( binding, project );
reports.add( binding );
}

View File

@ -28,7 +28,7 @@ public class DefaultMojoBindingFactory
* 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, boolean includeReportConfig )
public MojoBinding parseMojoBinding( String bindingSpec, MavenProject project, boolean allowPrefixReference )
throws LifecycleSpecificationException, LifecycleLoaderException
{
StringTokenizer tok = new StringTokenizer( bindingSpec, ":" );
@ -61,7 +61,7 @@ public class DefaultMojoBindingFactory
}
binding = createMojoBinding( pluginDescriptor.getGroupId(), pluginDescriptor.getArtifactId(),
pluginDescriptor.getVersion(), tok.nextToken(), project, includeReportConfig );
pluginDescriptor.getVersion(), tok.nextToken(), project );
}
else if ( ( numTokens == 3 ) || ( numTokens == 4 ) )
{
@ -78,7 +78,7 @@ public class DefaultMojoBindingFactory
String goal = tok.nextToken();
binding = createMojoBinding( groupId, artifactId, version, goal, project, includeReportConfig );
binding = createMojoBinding( groupId, artifactId, version, goal, project );
}
else
{
@ -95,7 +95,7 @@ public class DefaultMojoBindingFactory
* 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, boolean includeReportConfig )
public MojoBinding createMojoBinding( String groupId, String artifactId, String version, String goal, MavenProject project )
{
MojoBinding binding = new MojoBinding();
@ -104,7 +104,7 @@ public class DefaultMojoBindingFactory
binding.setVersion( version );
binding.setGoal( goal );
BindingUtils.injectProjectConfiguration( binding, project, includeReportConfig );
BindingUtils.injectProjectConfiguration( binding, project );
return binding;
}
@ -119,7 +119,7 @@ public class DefaultMojoBindingFactory
{
try
{
return parseMojoBinding( bindingSpec, null, false, false );
return parseMojoBinding( bindingSpec, null, false );
}
catch ( LifecycleLoaderException e )
{

View File

@ -45,7 +45,7 @@ public interface LifecycleBindingManager
* plugin. Inject mojo configuration from the POM into all appropriate MojoBinding instances.
*/
LifecycleBindings getPluginLifecycleOverlay( PluginDescriptor pluginDescriptor, String lifecycleId,
MavenProject project, boolean includeReportConfig )
MavenProject project )
throws LifecycleLoaderException, LifecycleSpecificationException;
/**

View File

@ -23,14 +23,14 @@ public interface MojoBindingFactory
* 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, boolean includeReportConfig )
MojoBinding parseMojoBinding( String bindingSpec, MavenProject project, boolean allowPrefixReference )
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, boolean includeReportConfig );
MojoBinding createMojoBinding( String groupId, String artifactId, String version, String goal, MavenProject project );
/**
* Simplified version of {@link MojoBindingFactory#parseMojoBinding(String, MavenProject, boolean)}

View File

@ -78,9 +78,7 @@ public class DefaultBuildPlanner
if ( !LifecycleUtils.isValidPhaseName( task ) )
{
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 );
MojoBinding binding = mojoBindingFactory.parseMojoBinding( task, project, true );
plan.addDirectInvocationBinding( task, binding );
}
}
@ -290,7 +288,7 @@ public class DefaultBuildPlanner
try
{
overlayBindings =
lifecycleBindingManager.getPluginLifecycleOverlay( pluginDescriptor, executeLifecycle, project, includeReportConfig );
lifecycleBindingManager.getPluginLifecycleOverlay( pluginDescriptor, executeLifecycle, project );
}
catch ( LifecycleLoaderException e )
{
@ -343,7 +341,7 @@ public class DefaultBuildPlanner
MojoBinding binding =
mojoBindingFactory.createMojoBinding( pluginDescriptor.getGroupId(), pluginDescriptor.getArtifactId(),
pluginDescriptor.getVersion(), executeGoal, project, includeReportConfig );
pluginDescriptor.getVersion(), executeGoal, project );
binding.setOrigin( "Forked from " + referencingGoal );

View File

@ -28,15 +28,13 @@ public class ResolveLateBoundPluginMojo extends AbstractMojo
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, includeReportConfig );
MojoBinding binding = bindingFactory.createMojoBinding( groupId, artifactId, version, artifactId, project );
try
{
PluginDescriptor descriptor = pluginLoader.loadPlugin( binding, project );

View File

@ -162,13 +162,6 @@
<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}"/>
@ -176,7 +169,6 @@
<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>

View File

@ -263,9 +263,6 @@ under the License.
<requirement>
<role>org.apache.maven.plugin.PluginManager</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement>
<requirement>
<role>org.apache.maven.lifecycle.plan.BuildPlanner</role>
</requirement>

View File

@ -27,7 +27,7 @@ public class DefaultMojoBindingFactoryTest
try
{
factory.parseMojoBinding( spec, new MavenProject( new Model() ), false, false );
factory.parseMojoBinding( spec, new MavenProject( new Model() ), false );
fail( "Should fail when prefix references are not allowed." );
}
@ -42,7 +42,7 @@ public class DefaultMojoBindingFactoryTest
{
String spec = "group:artifact:goal";
MojoBinding binding = factory.parseMojoBinding( spec, new MavenProject( new Model() ), false, false );
MojoBinding binding = factory.parseMojoBinding( spec, new MavenProject( new Model() ), false );
assertEquals( "group", binding.getGroupId() );
assertEquals( "artifact", binding.getArtifactId() );
@ -55,7 +55,7 @@ public class DefaultMojoBindingFactoryTest
{
String spec = "group:artifact:version:goal";
MojoBinding binding = factory.parseMojoBinding( spec, new MavenProject( new Model() ), false, false );
MojoBinding binding = factory.parseMojoBinding( spec, new MavenProject( new Model() ), false );
assertEquals( "group", binding.getGroupId() );
assertEquals( "artifact", binding.getArtifactId() );
@ -70,7 +70,7 @@ public class DefaultMojoBindingFactoryTest
try
{
factory.parseMojoBinding( spec, new MavenProject( new Model() ), false, false );
factory.parseMojoBinding( spec, new MavenProject( new Model() ), false );
fail( "Should fail because spec has too many parts (type part is not allowed)." );
}