Adding the build-plan instance for each project to the session and MavenExecutionResponse.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@616824 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2008-01-30 18:11:50 +00:00
parent 30342818f0
commit 6c103fff87
12 changed files with 328 additions and 111 deletions

View File

@ -16,12 +16,15 @@ import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.InvalidPluginException;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.lifecycle.plan.BuildPlanner;
import org.apache.maven.lifecycle.plan.BuildPlan;
import org.apache.maven.lifecycle.model.MojoBinding;
import org.apache.maven.lifecycle.statemgmt.StateManagementUtils;
import org.apache.maven.lifecycle.DefaultLifecycleExecutor;
import org.apache.maven.lifecycle.LifecycleExecutor;
import org.apache.maven.lifecycle.LifecycleException;
import org.apache.maven.lifecycle.LifecycleExecutionException;
import org.apache.maven.lifecycle.LifecycleLoaderException;
import org.apache.maven.lifecycle.LifecycleSpecificationException;
import org.apache.maven.lifecycle.plan.LifecyclePlannerException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.plugin.DefaultPluginManager;
import org.apache.maven.plugin.PluginManager;
@ -32,7 +35,6 @@ import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluatio
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.configuration.PlexusConfiguration;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
import java.util.List;
@ -44,7 +46,8 @@ public privileged aspect LifecycleErrorReporterAspect
execution( void DefaultLifecycleExecutor.executeGoalAndHandleFailures( MojoBinding, .. ) )
&& args( binding, .. );
private pointcut le_executeGoalAndHandleFailures_withSession( MojoBinding binding, MavenSession session ):
private pointcut le_executeGoalAndHandleFailures_withSession( MojoBinding binding,
MavenSession session ):
execution( void DefaultLifecycleExecutor.executeGoalAndHandleFailures( MojoBinding, MavenSession, .. ) )
&& args( binding, session, .. );
@ -56,7 +59,8 @@ public privileged aspect LifecycleErrorReporterAspect
withincode( void PluginManager+.executeMojo( MavenProject, .. ) )
&& args( project, .. );
after( MojoBinding binding, MavenProject project ) throwing ( PluginLoaderException cause ):
after( MojoBinding binding,
MavenProject project) throwing ( PluginLoaderException cause ):
( cflow( le_executeGoalAndHandleFailures( MojoBinding ) )
|| cflow( execution( * LifecycleExecutor+.isTaskValid( .. ) ) ) )
&& execution( * PluginLoader+.loadPlugin( MojoBinding, MavenProject, .. ) )
@ -65,14 +69,17 @@ public privileged aspect LifecycleErrorReporterAspect
getReporter().reportErrorLoadingPlugin( binding, project, cause );
}
after( String task, MavenSession session, MavenProject project ) throwing ( InvalidPluginException cause ):
after( String task,
MavenSession session,
MavenProject project) throwing ( InvalidPluginException cause ):
execution( private * DefaultLifecycleExecutor.getMojoDescriptorForDirectInvocation( String, MavenSession, MavenProject ) )
&& args( task, session, project )
{
getReporter().reportInvalidPluginForDirectInvocation( task, session, project, cause );
}
after( MojoBinding binding, MavenProject project ) throwing ( MojoExecutionException cause ):
after( MojoBinding binding,
MavenProject project) throwing ( MojoExecutionException cause ):
cflow( le_executeGoalAndHandleFailures( binding ) )
&& cflow( pm_executeMojo( project ) )
&& call( void Mojo+.execute() )
@ -84,7 +91,8 @@ public privileged aspect LifecycleErrorReporterAspect
}
}
PluginExecutionException around( MojoBinding binding, MavenProject project ):
PluginExecutionException around( MojoBinding binding,
MavenProject project ):
cflow( le_executeGoalAndHandleFailures( binding ) )
&& cflow( pm_executeMojo( project ) )
&& call( PluginExecutionException.new( .., String ) )
@ -95,7 +103,8 @@ public privileged aspect LifecycleErrorReporterAspect
return cause;
}
after( MojoBinding binding, MavenProject project ) throwing ( ComponentLookupException cause ):
after( MojoBinding binding,
MavenProject project) throwing ( ComponentLookupException cause ):
cflow( le_executeGoalAndHandleFailures( binding ) )
&& cflow( pm_executeMojo( project ) )
&& withincode( Mojo DefaultPluginManager.getConfiguredMojo( .. ) )
@ -137,22 +146,38 @@ public privileged aspect LifecycleErrorReporterAspect
currentParameter = null;
}
private pointcut pm_executeMojoWithSessionAndExec( MavenProject project, MojoExecution exec, MavenSession session, DefaultPluginManager manager ):
private pointcut pm_executeMojoWithSessionAndExec( MavenProject project,
MojoExecution exec,
MavenSession session,
DefaultPluginManager manager ):
execution( void DefaultPluginManager.executeMojo( MavenProject, MojoExecution, MavenSession ) )
&& args( project, exec, session )
&& this( manager );
after( MojoBinding binding, MavenProject project, MojoExecution exec, MavenSession session, DefaultPluginManager manager ) throwing( PluginConfigurationException cause ):
after( MojoBinding binding,
MavenProject project,
MojoExecution exec,
MavenSession session,
DefaultPluginManager manager) throwing( PluginConfigurationException cause ):
cflow( le_executeGoalAndHandleFailures( binding ) )
&& cflow( pm_executeMojoWithSessionAndExec( project, exec, session, manager ) )
&& pm_validatePomConfig()
{
PathTranslator translator = manager.pathTranslator;
Logger logger = new ConsoleLogger( Logger.LEVEL_INFO, "error reporting" );
getReporter().reportAttemptToOverrideUneditableMojoParameter( currentParameter, binding, project, session, exec, translator, logger, cause );
getReporter().reportAttemptToOverrideUneditableMojoParameter( currentParameter,
binding,
project,
session,
exec,
translator,
logger,
cause );
}
PluginParameterException around( MojoBinding binding, MavenProject project, List invalidParameters ):
PluginParameterException around( MojoBinding binding,
MavenProject project,
List invalidParameters ):
cflow( le_executeGoalAndHandleFailures( binding ) )
&& cflow( pm_executeMojo( project ) )
&& cflow( pm_checkRequiredParameters() )
@ -174,7 +199,10 @@ public privileged aspect LifecycleErrorReporterAspect
withincode( Object PluginParameterExpressionEvaluator.evaluate( String ) )
&& args( expression );
before( MojoBinding binding, MavenProject project, String expression, ExpressionEvaluationException err ):
before( MojoBinding binding,
MavenProject project,
String expression,
ExpressionEvaluationException err ):
cflow( le_executeGoalAndHandleFailures( binding ) )
&& cflow( pm_executeMojo( project ) )
&& cflow( pm_checkRequiredParameters() )
@ -190,7 +218,9 @@ public privileged aspect LifecycleErrorReporterAspect
err );
}
after( MojoBinding binding, MavenProject project, String expression ) throwing ( Exception cause ):
after( MojoBinding binding,
MavenProject project,
String expression) throwing ( Exception cause ):
cflow( le_executeGoalAndHandleFailures( binding ) )
&& cflow( pm_executeMojo( project ) )
&& cflow( pm_checkRequiredParameters() )
@ -199,13 +229,15 @@ public privileged aspect LifecycleErrorReporterAspect
&& call( Object ReflectionValueExtractor.evaluate( String, Object ) )
{
getReporter().reportReflectionErrorWhileEvaluatingMojoParameter( currentParameter,
binding,
project,
expression,
cause );
binding,
project,
expression,
cause );
}
after( MojoBinding binding, MavenProject project, PlexusConfiguration config ) throwing( PluginConfigurationException cause ):
after( MojoBinding binding,
MavenProject project,
PlexusConfiguration config) throwing( PluginConfigurationException cause ):
cflow( le_executeGoalAndHandleFailures( binding ) )
&& cflow( pm_executeMojo( project ) )
&& execution( void DefaultPluginManager.populatePluginFields( *, *, PlexusConfiguration, .. ) )
@ -214,22 +246,27 @@ public privileged aspect LifecycleErrorReporterAspect
getReporter().reportErrorApplyingMojoConfiguration( binding, project, config, cause );
}
private pointcut pm_resolveTransitiveDependencies( MavenProject project, String scope ):
private pointcut pm_resolveTransitiveDependencies( MavenProject project,
String scope ):
execution( void DefaultPluginManager.resolveTransitiveDependencies( *, *, String, *, MavenProject ) )
&& args( *, *, scope, *, project );
after( MavenProject project, String scope ) throwing( ArtifactNotFoundException cause ):
after( MavenProject project,
String scope) throwing( ArtifactNotFoundException cause ):
pm_resolveTransitiveDependencies( project, scope )
{
getReporter().reportProjectDependenciesNotFound( project, scope, cause );
}
after( MavenProject project, String scope ) throwing( ArtifactResolutionException cause ):
after( MavenProject project,
String scope) throwing( ArtifactResolutionException cause ):
pm_resolveTransitiveDependencies( project, scope )
{
if ( cause instanceof MultipleArtifactsNotFoundException )
{
getReporter().reportProjectDependenciesNotFound( project, scope, (MultipleArtifactsNotFoundException) cause );
getReporter().reportProjectDependenciesNotFound( project,
scope,
(MultipleArtifactsNotFoundException) cause );
}
else
{
@ -237,16 +274,39 @@ public privileged aspect LifecycleErrorReporterAspect
}
}
private pointcut le_getLifecycleBindings( List tasks, MavenProject configuringProject, String targetDescription ):
private pointcut le_getLifecycleBindings( List tasks,
MavenProject configuringProject,
String targetDescription ):
execution( List DefaultLifecycleExecutor.getLifecycleBindings( List, MavenProject, *, String ) )
&& args( tasks, configuringProject, *, targetDescription );
before( List tasks, MavenProject configuringProject, String targetDescription, LifecycleException cause ):
cflow( le_getLifecycleBindings( tasks, configuringProject, targetDescription ) )
&& call( LifecycleExecutionException.new( .., LifecycleException ) )
&& args( .., cause )
BuildPlan around( List tasks,
MavenProject project,
MavenSession session )
throws LifecycleLoaderException, LifecycleSpecificationException, LifecyclePlannerException:
cflow( execution( * DefaultLifecycleExecutor.*( .. ) ) )
&& execution( BuildPlan BuildPlanner+.constructBuildPlan( List, MavenProject, MavenSession ) )
&& args( tasks, project, session )
{
getReporter().reportErrorFormulatingBuildPlan( tasks, configuringProject, targetDescription, cause );
try
{
return proceed( tasks, project, session );
}
catch ( LifecycleLoaderException cause )
{
getReporter().reportErrorFormulatingBuildPlan( tasks, project, session, cause );
throw cause;
}
catch ( LifecyclePlannerException cause )
{
getReporter().reportErrorFormulatingBuildPlan( tasks, project, session, cause );
throw cause;
}
catch ( LifecycleSpecificationException cause )
{
getReporter().reportErrorFormulatingBuildPlan( tasks, project, session, cause );
throw cause;
}
}
}

View File

@ -240,6 +240,8 @@ public class DefaultMaven
result.setProject( reactorManager.getTopLevelProject() );
result.setBuildPlans( session.getBuildPlans() );
return result;
}

View File

@ -66,7 +66,7 @@ public interface CoreErrorReporter
void reportErrorConfiguringExtensionPluginRealm( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, RealmManagementException cause );
void reportErrorFormulatingBuildPlan( List tasks, MavenProject configuringProject, String targetDescription, LifecycleException cause );
void reportErrorFormulatingBuildPlan( List tasks, MavenProject project, MavenSession session, LifecycleException cause );
void reportErrorInterpolatingModel( Model model, Map inheritedValues, File pomFile, MavenExecutionRequest request, ModelInterpolationException cause );

View File

@ -747,8 +747,8 @@ public class DefaultCoreErrorReporter
}
public void reportErrorFormulatingBuildPlan( List tasks,
MavenProject configuringProject,
String targetDescription,
MavenProject project,
MavenSession session,
LifecycleException cause )
{
StringWriter writer = new StringWriter();
@ -769,12 +769,8 @@ public class DefaultCoreErrorReporter
writer.write( NEWLINE );
writer.write( NEWLINE );
writer.write( "Current project:" );
writeProjectCoordinate( configuringProject, writer );
writeProjectCoordinate( project, writer );
writer.write( NEWLINE );
writer.write( NEWLINE );
writer.write( "Build execution sub-segment:" );
writer.write( targetDescription );
writer.write( NEWLINE );
writer.write( NEWLINE );
writer.write( "Error message: " );
@ -783,7 +779,7 @@ public class DefaultCoreErrorReporter
writer.write( "Root error message: " );
writer.write( getRootCause( cause ).getMessage() );
addTips( CoreErrorTips.getBuildPlanningErrorTips( tasks, configuringProject, cause ), writer );
addTips( CoreErrorTips.getBuildPlanningErrorTips( tasks, project, cause ), writer );
registerBuildError( cause, writer.toString(), cause.getCause() );
}

View File

@ -20,11 +20,13 @@ package org.apache.maven.execution;
*/
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.lifecycle.plan.BuildPlan;
import org.apache.maven.project.MavenProject;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/** @author Jason van Zyl */
public class DefaultMavenExecutionResult
@ -40,6 +42,8 @@ public class DefaultMavenExecutionResult
private ReactorManager reactorManager;
private Map buildPlans;
public MavenExecutionResult setProject( MavenProject project )
{
this.project = project;
@ -109,4 +113,19 @@ public class DefaultMavenExecutionResult
return this;
}
public BuildPlan getBuildPlan( String projectId )
{
return (BuildPlan) buildPlans.get( projectId );
}
public BuildPlan getBuildPlan( MavenProject project )
{
return (BuildPlan) buildPlans.get( project.getId() );
}
public void setBuildPlans( Map buildPlans )
{
this.buildPlans = buildPlans;
}
}

View File

@ -20,9 +20,11 @@ package org.apache.maven.execution;
*/
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.lifecycle.plan.BuildPlan;
import org.apache.maven.project.MavenProject;
import java.util.List;
import java.util.Map;
/**
* @author Jason van Zyl
@ -51,4 +53,10 @@ public interface MavenExecutionResult
MavenExecutionResult addException( Throwable e );
boolean hasExceptions();
BuildPlan getBuildPlan( String projectId );
BuildPlan getBuildPlan( MavenProject project );
void setBuildPlans( Map buildPlan );
}

View File

@ -20,6 +20,7 @@ package org.apache.maven.execution;
*/
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.lifecycle.plan.BuildPlan;
import org.apache.maven.monitor.event.EventDispatcher;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
@ -33,6 +34,7 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@ -57,10 +59,13 @@ public class MavenSession
private MavenExecutionRequest request;
private MavenProject currentProject;
private Stack forkedProjectStack = new Stack();
private Map reports = new LinkedHashMap();
private Map buildPlans = new HashMap();
public MavenSession( PlexusContainer container,
MavenExecutionRequest request,
EventDispatcher eventDispatcher,
@ -251,4 +256,24 @@ public class MavenSession
return reports.keySet();
}
public BuildPlan getBuildPlan( String projectId )
{
return (BuildPlan) buildPlans.get( projectId );
}
public BuildPlan getBuildPlan( MavenProject project )
{
return (BuildPlan) buildPlans.get( project.getId() );
}
public void setBuildPlan( MavenProject project, BuildPlan buildPlan )
{
buildPlans.put( project.getId(), buildPlan );
}
public Map getBuildPlans()
{
return buildPlans;
}
}

View File

@ -130,20 +130,18 @@ public class DefaultLifecycleExecutor
session,
rootProject );
// FIXME: This should be handled by the extension scanner.
// try
// {
// Map handlers = findArtifactTypeHandlers( session );
//
// artifactHandlerManager.addHandlers( handlers );
// }
// catch ( PluginNotFoundException e )
// {
// throw new LifecycleExecutionException(
// "Plugin could not be not found while searching for artifact-type handlers.",
// rootProject,
// e );
// }
try
{
buildPlanner.constructInitialProjectBuildPlans( session );
}
catch ( LifecycleException e )
{
e.printStackTrace();
throw new LifecycleExecutionException(
"Failed to construct one or more initial build plans."
+ " Reason: " + e.getMessage(),
e );
}
executeTaskSegments(
taskSegments,
@ -430,7 +428,7 @@ public class DefaultLifecycleExecutor
getLogger().debug(
"\n\nOur build plan is:\n" + BuildPlanUtils.listBuildPlan(
plan,
false ) + "\n\n" );
false ) + "\n\nfor task-segment: " + targetDescription );
}
mojoBindings = plan.renderExecutionPlan( new Stack() );

View File

@ -91,6 +91,13 @@ public class LifecycleExecutionException
this.project = project;
}
public LifecycleExecutionException( String message,
Throwable cause )
{
super( message, cause );
project = null;
}
public MavenProject getProject()
{
return project;

View File

@ -267,22 +267,15 @@ public class DefaultLifecycleBindingManager
}
else
{
StringBuffer message = new StringBuffer();
logger.debug( "Skipping addition to build-plan for goal: "
+ goal
+ " in execution: "
+ execution.getId()
+ " of plugin: "
+ plugin.getKey()
+ " because no phase information was available (either through the mojo descriptor, which is currently missing, or in the POM itself)." );
message.append( "\n\nNo lifecycle phase binding can be found for goal: " + goal );
message.append( ",\nspecified as a part of the execution: " + execution.getId() );
message.append( "\nin plugin: " );
message.append( plugin.getKey() );
message.append( "\n\nThis plugin could not be resolved, so use of the default lifecycle phase binding " )
.append( "\n(if there is one) is impossible." );
message.append( "\n\nPlease ensure that the plugin: " )
.append( plugin.getKey() )
.append( " can be resolved by Maven," )
.append( "\nthen try re-running this build with the -U option " )
.append( "\n(to ensure that all plugin metadata is refreshed)." );
message.append( "\n\n" );
throw new LifecycleSpecificationException( message.toString() );
continue;
}
}
}

View File

@ -22,6 +22,15 @@ public interface BuildPlanner
/**
* Orchestrates construction of the build plan which will be used by the user of LifecycleExecutor.
*/
BuildPlan constructBuildPlan( List tasks, MavenProject project, MavenSession session )
BuildPlan constructBuildPlan( List tasks,
MavenProject project,
MavenSession session )
throws LifecycleLoaderException, LifecycleSpecificationException, LifecyclePlannerException;
void constructInitialProjectBuildPlans( MavenSession session )
throws LifecycleLoaderException, LifecycleSpecificationException, LifecyclePlannerException;
BuildPlan constructInitialProjectBuildPlan( MavenProject project,
MavenSession session )
throws LifecycleLoaderException, LifecycleSpecificationException, LifecyclePlannerException;
}

View File

@ -44,17 +44,56 @@ public class DefaultBuildPlanner
private MojoBindingFactory mojoBindingFactory;
public void constructInitialProjectBuildPlans( final MavenSession session )
throws LifecycleLoaderException, LifecycleSpecificationException, LifecyclePlannerException
{
for ( Iterator it = session.getSortedProjects().iterator(); it.hasNext(); )
{
MavenProject project = (MavenProject) it.next();
constructInitialProjectBuildPlan( project, session );
}
}
public BuildPlan constructInitialProjectBuildPlan( final MavenProject project,
final MavenSession session )
throws LifecycleLoaderException, LifecycleSpecificationException, LifecyclePlannerException
{
BuildPlan plan = session.getBuildPlan( project );
if ( plan == null )
{
plan = constructBuildPlan( Collections.EMPTY_LIST, project, session );
session.setBuildPlan( project, plan );
}
return plan;
}
/**
* Orchestrates construction of the build plan which will be used by the user of LifecycleExecutor.
*/
public BuildPlan constructBuildPlan( final List tasks, final MavenProject project, final MavenSession session )
public BuildPlan constructBuildPlan( final List tasks,
final MavenProject project,
final MavenSession session )
throws LifecycleLoaderException, LifecycleSpecificationException, LifecyclePlannerException
{
LifecycleBindings defaultBindings = lifecycleBindingManager.getDefaultBindings( project );
LifecycleBindings packagingBindings = lifecycleBindingManager.getBindingsForPackaging( project, session );
LifecycleBindings projectBindings = lifecycleBindingManager.getProjectCustomBindings( project, session );
BuildPlan plan = session.getBuildPlan( project );
BuildPlan plan = new BuildPlan( packagingBindings, projectBindings, defaultBindings, tasks );
if ( plan != null )
{
plan = plan.copy( tasks );
}
else
{
LifecycleBindings defaultBindings = lifecycleBindingManager.getDefaultBindings( project );
LifecycleBindings packagingBindings = lifecycleBindingManager.getBindingsForPackaging( project,
session );
LifecycleBindings projectBindings = lifecycleBindingManager.getProjectCustomBindings( project,
session );
plan = new BuildPlan( packagingBindings, projectBindings, defaultBindings, tasks );
}
// initialize/resolve any direct-invocation tasks, if possible.
initializeDirectInvocations( plan, project, session );
@ -68,7 +107,9 @@ public class DefaultBuildPlanner
return plan;
}
private void initializeDirectInvocations( final BuildPlan plan, final MavenProject project, final MavenSession session )
private void initializeDirectInvocations( final BuildPlan plan,
final MavenProject project,
final MavenSession session )
throws LifecycleSpecificationException, LifecycleLoaderException
{
List tasks = plan.getTasks();
@ -79,7 +120,10 @@ public class DefaultBuildPlanner
if ( !LifecycleUtils.isValidPhaseName( task ) )
{
MojoBinding binding = mojoBindingFactory.parseMojoBinding( task, project, session, true );
MojoBinding binding = mojoBindingFactory.parseMojoBinding( task,
project,
session,
true );
plan.addDirectInvocationBinding( task, binding );
}
}
@ -95,7 +139,10 @@ public class DefaultBuildPlanner
* process of injecting any modifiers that are necessary to accommodate forked execution.
* @param callStack
*/
private void addForkedLifecycleModifiers( final BuildPlan plan, final MavenProject project, MavenSession session, LinkedList callStack )
private void addForkedLifecycleModifiers( final BuildPlan plan,
final MavenProject project,
MavenSession session,
LinkedList callStack )
throws LifecyclePlannerException, LifecycleSpecificationException, LifecycleLoaderException
{
List planBindings = plan.renderExecutionPlan( new Stack() );
@ -109,10 +156,17 @@ public class DefaultBuildPlanner
}
}
private void findForkModifiers( final MojoBinding mojoBinding, final BuildPlan plan, final MavenProject project, MavenSession session, LinkedList callStack )
private void findForkModifiers( final MojoBinding mojoBinding,
final BuildPlan plan,
final MavenProject project,
MavenSession session,
LinkedList callStack )
throws LifecyclePlannerException, LifecycleSpecificationException, LifecycleLoaderException
{
PluginDescriptor pluginDescriptor = loadPluginDescriptor( mojoBinding, plan, project, session );
PluginDescriptor pluginDescriptor = loadPluginDescriptor( mojoBinding,
plan,
project,
session );
if ( pluginDescriptor == null )
{
@ -122,7 +176,8 @@ public class DefaultBuildPlanner
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( mojoBinding.getGoal() );
if ( mojoDescriptor == null )
{
throw new LifecyclePlannerException( "Mojo: " + mojoBinding.getGoal() + " does not exist in plugin: "
throw new LifecyclePlannerException( "Mojo: " + mojoBinding.getGoal()
+ " does not exist in plugin: "
+ pluginDescriptor.getId() + "." );
}
@ -136,7 +191,10 @@ public class DefaultBuildPlanner
* @param callStack
* @param session
*/
private void addReportingLifecycleModifiers( final BuildPlan plan, final MavenProject project, MavenSession session, LinkedList callStack )
private void addReportingLifecycleModifiers( final BuildPlan plan,
final MavenProject project,
MavenSession session,
LinkedList callStack )
throws LifecyclePlannerException, LifecycleSpecificationException, LifecycleLoaderException
{
List planBindings = plan.renderExecutionPlan( new Stack() );
@ -146,7 +204,10 @@ public class DefaultBuildPlanner
{
MojoBinding mojoBinding = (MojoBinding) it.next();
PluginDescriptor pluginDescriptor = loadPluginDescriptor( mojoBinding, plan, project, session );
PluginDescriptor pluginDescriptor = loadPluginDescriptor( mojoBinding,
plan,
project,
session );
if ( pluginDescriptor == null )
{
@ -156,7 +217,8 @@ public class DefaultBuildPlanner
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( mojoBinding.getGoal() );
if ( mojoDescriptor == null )
{
throw new LifecyclePlannerException( "Mojo: " + mojoBinding.getGoal() + " does not exist in plugin: "
throw new LifecyclePlannerException( "Mojo: " + mojoBinding.getGoal()
+ " does not exist in plugin: "
+ pluginDescriptor.getId() + "." );
}
@ -172,11 +234,20 @@ public class DefaultBuildPlanner
{
MojoBinding reportBinding = (MojoBinding) reportBindingIt.next();
PluginDescriptor pd = loadPluginDescriptor( reportBinding, plan, project, session );
PluginDescriptor pd = loadPluginDescriptor( reportBinding,
plan,
project,
session );
if ( pd != null )
{
findForkModifiers( reportBinding, pd, plan, project, session, true, callStack );
findForkModifiers( reportBinding,
pd,
plan,
project,
session,
true,
callStack );
}
}
}
@ -188,8 +259,10 @@ public class DefaultBuildPlanner
}
}
private PluginDescriptor loadPluginDescriptor( final MojoBinding mojoBinding, final BuildPlan plan,
final MavenProject project, final MavenSession session )
private PluginDescriptor loadPluginDescriptor( final MojoBinding mojoBinding,
final BuildPlan plan,
final MavenProject project,
final MavenSession session )
{
PluginDescriptor pluginDescriptor = null;
try
@ -198,9 +271,9 @@ public class DefaultBuildPlanner
}
catch ( PluginLoaderException e )
{
String message =
"Failed to load plugin: " + MojoBindingUtils.createPluginKey( mojoBinding )
+ ". Adding to late-bound plugins list.\nReason: " + e.getMessage();
String message = "Failed to load plugin: "
+ MojoBindingUtils.createPluginKey( mojoBinding )
+ ". Adding to late-bound plugins list.\nReason: " + e.getMessage();
if ( logger.isDebugEnabled() )
{
@ -222,9 +295,13 @@ public class DefaultBuildPlanner
* forked execution, along with any new mojos/lifecycles that entails.
* @param callStack
*/
private void findForkModifiers( final MojoBinding mojoBinding, final PluginDescriptor pluginDescriptor,
final BuildPlan plan, final MavenProject project, final MavenSession session,
final boolean includeReportConfig, LinkedList callStack )
private void findForkModifiers( final MojoBinding mojoBinding,
final PluginDescriptor pluginDescriptor,
final BuildPlan plan,
final MavenProject project,
final MavenSession session,
final boolean includeReportConfig,
LinkedList callStack )
throws LifecyclePlannerException, LifecycleSpecificationException, LifecycleLoaderException
{
String referencingGoal = mojoBinding.getGoal();
@ -233,17 +310,28 @@ public class DefaultBuildPlanner
if ( mojoDescriptor == null )
{
throw new LifecyclePlannerException( "Cannot find mojo descriptor for: " + referencingGoal + " in plugin: "
throw new LifecyclePlannerException( "Cannot find mojo descriptor for: "
+ referencingGoal + " in plugin: "
+ pluginDescriptor.getId() );
}
if ( mojoDescriptor.getExecuteGoal() != null )
{
recurseSingleMojoFork( mojoBinding, pluginDescriptor, plan, project, includeReportConfig );
recurseSingleMojoFork( mojoBinding,
pluginDescriptor,
plan,
project,
includeReportConfig );
}
else if ( mojoDescriptor.getExecutePhase() != null )
{
recursePhaseMojoFork( mojoBinding, pluginDescriptor, plan, project, session, includeReportConfig, callStack );
recursePhaseMojoFork( mojoBinding,
pluginDescriptor,
plan,
project,
session,
includeReportConfig,
callStack );
}
}
@ -257,9 +345,13 @@ public class DefaultBuildPlanner
* method to handle the actual plan modification.
* @param session
*/
private void recursePhaseMojoFork( final MojoBinding mojoBinding, final PluginDescriptor pluginDescriptor,
final BuildPlan plan, final MavenProject project, final MavenSession session,
final boolean includeReportConfig, LinkedList callStack )
private void recursePhaseMojoFork( final MojoBinding mojoBinding,
final PluginDescriptor pluginDescriptor,
final BuildPlan plan,
final MavenProject project,
final MavenSession session,
final boolean includeReportConfig,
LinkedList callStack )
throws LifecyclePlannerException, LifecycleSpecificationException, LifecycleLoaderException
{
callStack.addFirst( mojoBinding );
@ -291,13 +383,15 @@ public class DefaultBuildPlanner
LifecycleBindings overlayBindings;
try
{
overlayBindings =
lifecycleBindingManager.getPluginLifecycleOverlay( pluginDescriptor, executeLifecycle, project );
overlayBindings = lifecycleBindingManager.getPluginLifecycleOverlay( pluginDescriptor,
executeLifecycle,
project );
}
catch ( LifecycleLoaderException e )
{
throw new LifecyclePlannerException( "Failed to load overlay lifecycle: " + executeLifecycle
+ ". Reason: " + e.getMessage(), e );
throw new LifecyclePlannerException( "Failed to load overlay lifecycle: "
+ executeLifecycle + ". Reason: "
+ e.getMessage(), e );
}
clonedPlan.addLifecycleOverlay( overlayBindings );
@ -321,8 +415,11 @@ public class DefaultBuildPlanner
* method to actually inject the modification.
* @param callStack
*/
private void recurseSingleMojoFork( final MojoBinding mojoBinding, final PluginDescriptor pluginDescriptor,
final BuildPlan plan, final MavenProject project, final boolean includeReportConfig )
private void recurseSingleMojoFork( final MojoBinding mojoBinding,
final PluginDescriptor pluginDescriptor,
final BuildPlan plan,
final MavenProject project,
final boolean includeReportConfig )
throws LifecyclePlannerException, LifecycleSpecificationException, LifecycleLoaderException
{
String referencingGoal = mojoBinding.getGoal();
@ -339,13 +436,16 @@ public class DefaultBuildPlanner
MojoDescriptor otherDescriptor = pluginDescriptor.getMojo( executeGoal );
if ( otherDescriptor == null )
{
throw new LifecyclePlannerException( "Mojo: " + executeGoal + " (referenced by: " + referencingGoal
+ ") does not exist in plugin: " + pluginDescriptor.getId() + "." );
throw new LifecyclePlannerException( "Mojo: " + executeGoal + " (referenced by: "
+ referencingGoal + ") does not exist in plugin: "
+ pluginDescriptor.getId() + "." );
}
MojoBinding binding =
mojoBindingFactory.createMojoBinding( pluginDescriptor.getGroupId(), pluginDescriptor.getArtifactId(),
pluginDescriptor.getVersion(), executeGoal, project );
MojoBinding binding = mojoBindingFactory.createMojoBinding( pluginDescriptor.getGroupId(),
pluginDescriptor.getArtifactId(),
pluginDescriptor.getVersion(),
executeGoal,
project );
binding.setOrigin( "Forked from " + referencingGoal );