Fixed forking from reports.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@541950 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2007-05-26 23:37:35 +00:00
parent a55e9c24fe
commit 008d6943bc
1 changed files with 43 additions and 56 deletions

View File

@ -55,6 +55,7 @@ public class DefaultBuildPlanner
BuildPlan plan = new BuildPlan( packagingBindings, projectBindings, defaultBindings, tasks );
// initialize/resolve any direct-invocation tasks, if possible.
initializeDirectInvocations( plan, project );
// Inject forked lifecycles as plan modifiers for each mojo that has @execute in it.
@ -108,28 +109,7 @@ public class DefaultBuildPlanner
private void findForkModifiers( final MojoBinding mojoBinding, final BuildPlan plan, final MavenProject project )
throws LifecyclePlannerException, LifecycleSpecificationException, LifecycleLoaderException
{
PluginDescriptor pluginDescriptor = null;
try
{
pluginDescriptor = pluginLoader.loadPlugin( mojoBinding, project );
}
catch ( PluginLoaderException e )
{
String message =
"Failed to load plugin: " + MojoBindingUtils.createPluginKey( mojoBinding )
+ ". Adding to late-bound plugins list.\nReason: " + e.getMessage();
if ( logger.isDebugEnabled() )
{
logger.debug( message, e );
}
else
{
logger.warn( message );
}
plan.addLateBoundMojo( mojoBinding );
}
PluginDescriptor pluginDescriptor = loadPluginDescriptor( mojoBinding, plan, project );
if ( pluginDescriptor == null )
{
@ -161,28 +141,7 @@ public class DefaultBuildPlanner
{
MojoBinding mojoBinding = (MojoBinding) it.next();
PluginDescriptor pluginDescriptor = null;
try
{
pluginDescriptor = pluginLoader.loadPlugin( mojoBinding, project );
}
catch ( PluginLoaderException e )
{
String message =
"Failed to load plugin: " + MojoBindingUtils.createPluginKey( mojoBinding )
+ ". Adding to late-bound plugins list.\nReason: " + e.getMessage();
if ( logger.isDebugEnabled() )
{
logger.debug( message, e );
}
else
{
logger.warn( message );
}
plan.addLateBoundMojo( mojoBinding );
}
PluginDescriptor pluginDescriptor = loadPluginDescriptor( mojoBinding, plan, project );
if ( pluginDescriptor == null )
{
@ -200,24 +159,23 @@ public class DefaultBuildPlanner
{
List reportBindings = lifecycleBindingManager.getReportBindings( project );
for ( Iterator reportBindingIt = reportBindings.iterator(); reportBindingIt.hasNext(); )
if ( reportBindings != null )
{
MojoBinding reportBinding = (MojoBinding) reportBindingIt.next();
plan.addForkedExecution( mojoBinding, reportBindings );
try
for ( Iterator reportBindingIt = reportBindings.iterator(); reportBindingIt.hasNext(); )
{
pluginLoader.loadReportPlugin( mojoBinding, project );
}
catch ( PluginLoaderException e )
{
throw new LifecyclePlannerException( "Failed to load report-plugin descriptor for: "
+ MojoBindingUtils.toString( reportBinding )
+ ". Reason: " + e.getMessage(), e );
MojoBinding reportBinding = (MojoBinding) reportBindingIt.next();
PluginDescriptor pd = loadPluginDescriptor( reportBinding, plan, project );
if ( pd != null )
{
findForkModifiers( reportBinding, pluginDescriptor, plan, project );
}
}
}
plan.addForkedExecution( mojoBinding, reportBindings );
// NOTE: the first sighting of a mojo requiring reports should satisfy this condition.
// therefore, we can break out as soon as we find one.
break;
@ -225,6 +183,35 @@ public class DefaultBuildPlanner
}
}
private PluginDescriptor loadPluginDescriptor( final MojoBinding mojoBinding, final BuildPlan plan,
final MavenProject project )
{
PluginDescriptor pluginDescriptor = null;
try
{
pluginDescriptor = pluginLoader.loadPlugin( mojoBinding, project );
}
catch ( PluginLoaderException e )
{
String message =
"Failed to load plugin: " + MojoBindingUtils.createPluginKey( mojoBinding )
+ ". Adding to late-bound plugins list.\nReason: " + e.getMessage();
if ( logger.isDebugEnabled() )
{
logger.debug( message, e );
}
else
{
logger.warn( message );
}
plan.addLateBoundMojo( mojoBinding );
}
return pluginDescriptor;
}
/**
* Explores a single MojoBinding, and injects any necessary plan modifiers to accommodate any of the three types of
* forked execution, along with any new mojos/lifecycles that entails.