mirror of https://github.com/apache/maven.git
o remove the build planner from visibility
o fix a method in the project builder to protect against an error coming from the remote resources plugin, it's asking to resolve a POM from a JAR artifact and the old project building code was doing that for whatever not-right reason git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@751021 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c0a920cf80
commit
c586c81065
|
@ -171,8 +171,6 @@ public class DefaultMaven
|
|||
|
||||
result.setProject( reactorManager.getTopLevelProject() );
|
||||
|
||||
result.setBuildPlans( session.getBuildPlans() );
|
||||
|
||||
dispatcher.dispatchEnd( event, request.getBaseDirectory() );
|
||||
|
||||
return result;
|
||||
|
|
|
@ -42,8 +42,6 @@ public class DefaultMavenExecutionResult
|
|||
|
||||
private ReactorManager reactorManager;
|
||||
|
||||
private Map buildPlans;
|
||||
|
||||
public MavenExecutionResult setProject( MavenProject project )
|
||||
{
|
||||
this.project = project;
|
||||
|
@ -113,19 +111,4 @@ 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,10 +53,4 @@ public interface MavenExecutionResult
|
|||
MavenExecutionResult addException( Throwable e );
|
||||
|
||||
boolean hasExceptions();
|
||||
|
||||
BuildPlan getBuildPlan( String projectId );
|
||||
|
||||
BuildPlan getBuildPlan( MavenProject project );
|
||||
|
||||
void setBuildPlans( Map buildPlan );
|
||||
}
|
||||
|
|
|
@ -19,8 +19,17 @@ package org.apache.maven.execution;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
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;
|
||||
|
@ -32,17 +41,6 @@ import org.apache.maven.settings.Settings;
|
|||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
|
||||
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;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
/**
|
||||
* @author Jason van Zyl
|
||||
* @version $Id$
|
||||
|
@ -65,12 +63,7 @@ public class MavenSession
|
|||
|
||||
private Map reports = new LinkedHashMap();
|
||||
|
||||
private Map buildPlans = new HashMap();
|
||||
|
||||
public MavenSession( PlexusContainer container,
|
||||
MavenExecutionRequest request,
|
||||
EventDispatcher eventDispatcher,
|
||||
ReactorManager reactorManager )
|
||||
public MavenSession( PlexusContainer container, MavenExecutionRequest request, EventDispatcher eventDispatcher, ReactorManager reactorManager )
|
||||
{
|
||||
this.container = container;
|
||||
|
||||
|
@ -269,26 +262,6 @@ 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;
|
||||
}
|
||||
|
||||
public ProjectBuilderConfiguration getProjectBuilderConfiguration()
|
||||
{
|
||||
return request.getProjectBuildingConfiguration();
|
||||
|
|
|
@ -147,15 +147,6 @@ public class DefaultLifecycleExecutor
|
|||
|
||||
List taskSegments = segmentTaskListByAggregationNeeds( goals, session, rootProject );
|
||||
|
||||
try
|
||||
{
|
||||
buildPlanner.constructInitialProjectBuildPlans( session );
|
||||
}
|
||||
catch ( LifecycleException e )
|
||||
{
|
||||
throw new LifecycleExecutionException( "Failed to construct one or more initial build plans." + " Reason: " + e.getMessage(), e );
|
||||
}
|
||||
|
||||
executeTaskSegments( taskSegments, reactorManager, session, rootProject, dispatcher );
|
||||
}
|
||||
|
||||
|
@ -169,11 +160,7 @@ public class DefaultLifecycleExecutor
|
|||
* method will iterate through each project, and execute all the goals implied
|
||||
* by the current task segment.
|
||||
*/
|
||||
private void executeTaskSegments( final List taskSegments,
|
||||
final ReactorManager reactorManager,
|
||||
final MavenSession session,
|
||||
final MavenProject rootProject,
|
||||
final EventDispatcher dispatcher )
|
||||
private void executeTaskSegments( List taskSegments, ReactorManager reactorManager, MavenSession session, MavenProject rootProject, EventDispatcher dispatcher )
|
||||
throws LifecycleExecutionException, BuildFailureException
|
||||
{
|
||||
for ( Iterator it = taskSegments.iterator(); it.hasNext(); )
|
||||
|
@ -377,10 +364,7 @@ public class DefaultLifecycleExecutor
|
|||
* of MojoBindings, each fully configured to execute, which enables us to enumerate the full build plan to the debug
|
||||
* log-level, complete with the configuration each mojo will use.
|
||||
*/
|
||||
private List getLifecycleBindings( final List tasks,
|
||||
final MavenProject project,
|
||||
final MavenSession session,
|
||||
final String targetDescription )
|
||||
private List getLifecycleBindings( List tasks, MavenProject project, MavenSession session, String targetDescription )
|
||||
throws LifecycleExecutionException
|
||||
{
|
||||
List mojoBindings;
|
||||
|
@ -421,13 +405,9 @@ public class DefaultLifecycleExecutor
|
|||
* is not the root project of the reactor (using {@link ReactorManager#getTopLevelProject()},
|
||||
* then print a DEBUG message and skip that execution.
|
||||
*/
|
||||
private void executeGoalAndHandleFailures( final MojoBinding mojoBinding,
|
||||
final MavenSession session,
|
||||
final EventDispatcher dispatcher,
|
||||
final String event,
|
||||
final ReactorManager rm,
|
||||
final long buildStartTime,
|
||||
final String target,
|
||||
private void executeGoalAndHandleFailures( MojoBinding mojoBinding, MavenSession session, EventDispatcher dispatcher, String event, ReactorManager rm,
|
||||
long buildStartTime,
|
||||
String target,
|
||||
boolean allowAggregators )
|
||||
throws LifecycleExecutionException, MojoFailureException
|
||||
{
|
||||
|
|
|
@ -40,8 +40,6 @@ import org.apache.maven.project.MavenProject;
|
|||
*/
|
||||
public interface LifecycleExecutor
|
||||
{
|
||||
String ROLE = LifecycleExecutor.class.getName();
|
||||
|
||||
/**
|
||||
* Provides a fail-fast way to check that all goals specified in {@link MavenExecutionRequest#getGoals()}
|
||||
* or {@link MavenSession#getGoals()} is valid.
|
||||
|
|
|
@ -22,16 +22,6 @@ 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,
|
||||
boolean allowUnbindableMojos )
|
||||
throws LifecycleLoaderException, LifecycleSpecificationException, LifecyclePlannerException;
|
||||
|
||||
void constructInitialProjectBuildPlans( MavenSession session )
|
||||
throws LifecycleLoaderException, LifecycleSpecificationException, LifecyclePlannerException;
|
||||
|
||||
BuildPlan constructInitialProjectBuildPlan( MavenProject project,
|
||||
MavenSession session )
|
||||
BuildPlan constructBuildPlan( List tasks, MavenProject project, MavenSession session, boolean allowUnbindableMojos )
|
||||
throws LifecycleLoaderException, LifecycleSpecificationException, LifecyclePlannerException;
|
||||
}
|
||||
|
|
|
@ -24,21 +24,21 @@ import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
|||
import org.apache.maven.project.MavenProject;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.codehaus.plexus.logging.LogEnabled;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
|
||||
/**
|
||||
* Responsible for creating a plan of execution for a given project and list of tasks. This build plan consists of
|
||||
* 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.
|
||||
*
|
||||
* Responsible for creating a plan of execution for a given project and list of tasks. This build
|
||||
* plan consists of 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
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Component(role = BuildPlanner.class)
|
||||
public class DefaultBuildPlanner
|
||||
implements BuildPlanner, LogEnabled
|
||||
implements BuildPlanner
|
||||
{
|
||||
@Requirement
|
||||
private PluginManager pluginLoader;
|
||||
|
@ -49,9 +49,10 @@ public class DefaultBuildPlanner
|
|||
@Requirement
|
||||
private MojoBindingFactory mojoBindingFactory;
|
||||
|
||||
@Requirement
|
||||
private Logger logger;
|
||||
|
||||
public void constructInitialProjectBuildPlans( final MavenSession session )
|
||||
public void constructInitialProjectBuildPlans( MavenSession session )
|
||||
throws LifecycleLoaderException, LifecycleSpecificationException, LifecyclePlannerException
|
||||
{
|
||||
for ( Iterator it = session.getSortedProjects().iterator(); it.hasNext(); )
|
||||
|
@ -62,52 +63,33 @@ public class DefaultBuildPlanner
|
|||
}
|
||||
}
|
||||
|
||||
public BuildPlan constructInitialProjectBuildPlan( final MavenProject project,
|
||||
final MavenSession session )
|
||||
public BuildPlan constructInitialProjectBuildPlan( MavenProject project, MavenSession session )
|
||||
throws LifecycleLoaderException, LifecycleSpecificationException, LifecyclePlannerException
|
||||
{
|
||||
BuildPlan plan = session.getBuildPlan( project );
|
||||
if ( plan == null )
|
||||
{
|
||||
plan = constructBuildPlan( Collections.EMPTY_LIST, project, session, true );
|
||||
|
||||
session.setBuildPlan( project, plan );
|
||||
}
|
||||
BuildPlan plan = constructBuildPlan( Collections.EMPTY_LIST, project, session, true );
|
||||
|
||||
return plan;
|
||||
}
|
||||
|
||||
/**
|
||||
* Orchestrates construction of the build plan which will be used by the user of LifecycleExecutor.
|
||||
* Orchestrates construction of the build plan which will be used by the user of
|
||||
* LifecycleExecutor.
|
||||
*/
|
||||
public BuildPlan constructBuildPlan( List tasks,
|
||||
MavenProject project,
|
||||
MavenSession session,
|
||||
boolean allowUnbindableMojos )
|
||||
public BuildPlan constructBuildPlan( List tasks, MavenProject project, MavenSession session, boolean allowUnbindableMojos )
|
||||
throws LifecycleLoaderException, LifecycleSpecificationException, LifecyclePlannerException
|
||||
{
|
||||
BuildPlan plan = session.getBuildPlan( project );
|
||||
|
||||
boolean pluginResolutionAttempted = false;
|
||||
if ( plan != null )
|
||||
{
|
||||
plan = plan.copy( tasks );
|
||||
}
|
||||
else
|
||||
{
|
||||
LifecycleBindings defaultBindings = lifecycleBindingManager.getDefaultBindings( project );
|
||||
|
||||
LifecycleBindings packagingBindings = lifecycleBindingManager.getBindingsForPackaging( project,
|
||||
session );
|
||||
LifecycleBindings defaultBindings = lifecycleBindingManager.getDefaultBindings( project );
|
||||
|
||||
Set unbindableMojos = new HashSet();
|
||||
LifecycleBindings projectBindings = lifecycleBindingManager.getProjectCustomBindings( project,
|
||||
session,
|
||||
unbindableMojos );
|
||||
LifecycleBindings packagingBindings = lifecycleBindingManager.getBindingsForPackaging( project, session );
|
||||
|
||||
plan = new BuildPlan( packagingBindings, projectBindings, defaultBindings, unbindableMojos, tasks );
|
||||
pluginResolutionAttempted = true;
|
||||
}
|
||||
Set unbindableMojos = new HashSet();
|
||||
LifecycleBindings projectBindings = lifecycleBindingManager.getProjectCustomBindings( project, session, unbindableMojos );
|
||||
|
||||
BuildPlan plan = new BuildPlan( packagingBindings, projectBindings, defaultBindings, unbindableMojos, tasks );
|
||||
|
||||
pluginResolutionAttempted = true;
|
||||
|
||||
if ( ( !pluginResolutionAttempted || !allowUnbindableMojos ) && plan.hasUnbindableMojos() )
|
||||
{
|
||||
|
@ -129,11 +111,10 @@ 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();
|
||||
|
||||
for ( Iterator it = tasks.iterator(); it.hasNext(); )
|
||||
|
@ -142,10 +123,7 @@ public class DefaultBuildPlanner
|
|||
|
||||
if ( !LifecycleUtils.isValidPhaseName( task ) )
|
||||
{
|
||||
MojoBinding binding = mojoBindingFactory.parseMojoBinding( task,
|
||||
project,
|
||||
session,
|
||||
true );
|
||||
MojoBinding binding = mojoBindingFactory.parseMojoBinding( task, project, session, true );
|
||||
|
||||
binding.setOrigin( MojoBinding.DIRECT_INVOCATION_ORIGIN );
|
||||
binding.setOriginDescription( "Original reference from user: " + task );
|
||||
|
@ -155,21 +133,14 @@ public class DefaultBuildPlanner
|
|||
}
|
||||
}
|
||||
|
||||
public void enableLogging( final Logger logger )
|
||||
{
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Traverses all MojoBinding instances discovered from the POM and its packaging-mappings, and orchestrates the
|
||||
* process of injecting any modifiers that are necessary to accommodate forked execution.
|
||||
* Traverses all MojoBinding instances discovered from the POM and its packaging-mappings, and
|
||||
* orchestrates the process of injecting any modifiers that are necessary to accommodate forked
|
||||
* execution.
|
||||
*
|
||||
* @param callStack
|
||||
*/
|
||||
private void addForkedLifecycleModifiers( final BuildPlan plan,
|
||||
final MavenProject project,
|
||||
final MavenSession session,
|
||||
LinkedList callStack,
|
||||
final boolean allowUnbindableMojos )
|
||||
private void addForkedLifecycleModifiers( final BuildPlan plan, final MavenProject project, final MavenSession session, LinkedList callStack, final boolean allowUnbindableMojos )
|
||||
throws LifecyclePlannerException, LifecycleSpecificationException, LifecycleLoaderException
|
||||
{
|
||||
List planBindings = plan.renderExecutionPlan( new Stack() );
|
||||
|
@ -186,12 +157,7 @@ public class DefaultBuildPlanner
|
|||
}
|
||||
}
|
||||
|
||||
private void findForkModifiers( final MojoBinding mojoBinding,
|
||||
final BuildPlan plan,
|
||||
final MavenProject project,
|
||||
MavenSession session,
|
||||
LinkedList callStack,
|
||||
final boolean allowUnbindableMojos )
|
||||
private void findForkModifiers( final MojoBinding mojoBinding, final BuildPlan plan, final MavenProject project, MavenSession session, LinkedList callStack, final boolean allowUnbindableMojos )
|
||||
throws LifecyclePlannerException, LifecycleSpecificationException, LifecycleLoaderException
|
||||
{
|
||||
PluginDescriptor pluginDescriptor = loadPluginDescriptor( mojoBinding, plan, project, session, allowUnbindableMojos );
|
||||
|
@ -204,24 +170,18 @@ public class DefaultBuildPlanner
|
|||
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( mojoBinding.getGoal() );
|
||||
if ( mojoDescriptor == null )
|
||||
{
|
||||
throw new LifecyclePlannerException( "Mojo: " + mojoBinding.getGoal()
|
||||
+ " does not exist in plugin: "
|
||||
+ pluginDescriptor.getId() + "." );
|
||||
throw new LifecyclePlannerException( "Mojo: " + mojoBinding.getGoal() + " does not exist in plugin: " + pluginDescriptor.getId() + "." );
|
||||
}
|
||||
|
||||
findForkModifiers( mojoBinding, pluginDescriptor, plan, project, session, callStack, false, allowUnbindableMojos );
|
||||
}
|
||||
|
||||
/**
|
||||
* Traverses all MojoBinding instances discovered from the POM and its packaging-mappings, and orchestrates the
|
||||
* process of injecting any modifiers that are necessary to accommodate mojos that require access to the project's
|
||||
* configured reports.
|
||||
* Traverses all MojoBinding instances discovered from the POM and its packaging-mappings, and
|
||||
* orchestrates the process of injecting any modifiers that are necessary to accommodate mojos
|
||||
* that require access to the project's configured reports.
|
||||
*/
|
||||
private void addReportingLifecycleModifiers( final BuildPlan plan,
|
||||
final MavenProject project,
|
||||
final MavenSession session,
|
||||
LinkedList callStack,
|
||||
final boolean allowUnbindableMojos )
|
||||
private void addReportingLifecycleModifiers( final BuildPlan plan, final MavenProject project, final MavenSession session, LinkedList callStack, final boolean allowUnbindableMojos )
|
||||
throws LifecyclePlannerException, LifecycleSpecificationException, LifecycleLoaderException
|
||||
{
|
||||
if ( plan.isIncludingReports() )
|
||||
|
@ -243,11 +203,7 @@ public class DefaultBuildPlanner
|
|||
continue;
|
||||
}
|
||||
|
||||
PluginDescriptor pluginDescriptor = loadPluginDescriptor( mojoBinding,
|
||||
plan,
|
||||
project,
|
||||
session,
|
||||
allowUnbindableMojos );
|
||||
PluginDescriptor pluginDescriptor = loadPluginDescriptor( mojoBinding, plan, project, session, allowUnbindableMojos );
|
||||
|
||||
if ( pluginDescriptor == null )
|
||||
{
|
||||
|
@ -258,9 +214,7 @@ public class DefaultBuildPlanner
|
|||
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( mojoBinding.getGoal() );
|
||||
if ( mojoDescriptor == null )
|
||||
{
|
||||
throw new LifecyclePlannerException( "Mojo: " + mojoBinding.getGoal()
|
||||
+ " does not exist in plugin: "
|
||||
+ pluginDescriptor.getId() + "." );
|
||||
throw new LifecyclePlannerException( "Mojo: " + mojoBinding.getGoal() + " does not exist in plugin: " + pluginDescriptor.getId() + "." );
|
||||
}
|
||||
|
||||
if ( mojoDescriptor.isRequiresReports() )
|
||||
|
@ -281,22 +235,11 @@ public class DefaultBuildPlanner
|
|||
continue;
|
||||
}
|
||||
|
||||
PluginDescriptor pd = loadPluginDescriptor( reportBinding,
|
||||
plan,
|
||||
project,
|
||||
session,
|
||||
allowUnbindableMojos );
|
||||
PluginDescriptor pd = loadPluginDescriptor( reportBinding, plan, project, session, allowUnbindableMojos );
|
||||
|
||||
if ( pd != null )
|
||||
{
|
||||
findForkModifiers( reportBinding,
|
||||
pd,
|
||||
plan,
|
||||
project,
|
||||
session,
|
||||
callStack,
|
||||
true,
|
||||
allowUnbindableMojos );
|
||||
findForkModifiers( reportBinding, pd, plan, project, session, callStack, true, allowUnbindableMojos );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -314,7 +257,7 @@ public class DefaultBuildPlanner
|
|||
throws LifecyclePlannerException
|
||||
{
|
||||
PluginDescriptor pluginDescriptor = null;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
pluginDescriptor = pluginLoader.loadPlugin( mojoBinding, project, session );
|
||||
|
@ -346,18 +289,13 @@ public class DefaultBuildPlanner
|
|||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* 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.
|
||||
*
|
||||
* @param callStack
|
||||
*/
|
||||
private void findForkModifiers( final MojoBinding mojoBinding,
|
||||
final PluginDescriptor pluginDescriptor,
|
||||
final BuildPlan plan,
|
||||
final MavenProject project,
|
||||
final MavenSession session,
|
||||
LinkedList callStack,
|
||||
final boolean includeReportConfig,
|
||||
final boolean allowUnbindableMojos )
|
||||
private void findForkModifiers( final MojoBinding mojoBinding, final PluginDescriptor pluginDescriptor, final BuildPlan plan, final MavenProject project, final MavenSession session,
|
||||
LinkedList callStack, final boolean includeReportConfig, final boolean allowUnbindableMojos )
|
||||
throws LifecyclePlannerException, LifecycleSpecificationException, LifecycleLoaderException
|
||||
{
|
||||
String referencingGoal = mojoBinding.getGoal();
|
||||
|
@ -366,50 +304,33 @@ public class DefaultBuildPlanner
|
|||
|
||||
if ( mojoDescriptor == null )
|
||||
{
|
||||
throw new LifecyclePlannerException( "Cannot find mojo descriptor for: "
|
||||
+ referencingGoal + " in plugin: "
|
||||
+ pluginDescriptor.getId() );
|
||||
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,
|
||||
callStack,
|
||||
includeReportConfig,
|
||||
allowUnbindableMojos );
|
||||
recursePhaseMojoFork( mojoBinding, pluginDescriptor, plan, project, session, callStack, includeReportConfig, allowUnbindableMojos );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* 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
|
||||
* {@link DefaultBuildPlanner#modifyBuildPlanForForkedLifecycle(MojoBinding, PluginDescriptor, ModifiablePlanElement, LifecycleBindings, MavenProject, LinkedList, List)}
|
||||
* 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,
|
||||
LinkedList callStack,
|
||||
final boolean includeReportConfig,
|
||||
final boolean allowUnbindableMojos )
|
||||
private void recursePhaseMojoFork( final MojoBinding mojoBinding, final PluginDescriptor pluginDescriptor, final BuildPlan plan, final MavenProject project, final MavenSession session,
|
||||
LinkedList callStack, final boolean includeReportConfig, final boolean allowUnbindableMojos )
|
||||
throws LifecyclePlannerException, LifecycleSpecificationException, LifecycleLoaderException
|
||||
{
|
||||
callStack.addFirst( mojoBinding );
|
||||
|
@ -441,15 +362,11 @@ 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 );
|
||||
|
@ -467,17 +384,14 @@ public class DefaultBuildPlanner
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieves the information necessary to create a new MojoBinding for a single-mojo forked execution, then hands
|
||||
* off to the
|
||||
* Retrieves the information necessary to create a new MojoBinding for a single-mojo forked
|
||||
* execution, then hands off to the
|
||||
* {@link DefaultBuildPlanner#modifyBuildPlanForForkedDirectInvocation(MojoBinding, MojoBinding, PluginDescriptor, ModifiablePlanElement, LifecycleBindings, MavenProject, LinkedList, List)}
|
||||
* 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();
|
||||
|
@ -494,16 +408,10 @@ 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( MojoBinding.FORKED_DIRECT_REFERENCE_ORIGIN );
|
||||
binding.setOriginDescription( "Forked from: " + MojoBindingUtils.toString( mojoBinding ) );
|
||||
|
|
|
@ -123,6 +123,9 @@ public class DefaultPluginManager
|
|||
RESERVED_GROUP_IDS = rgids;
|
||||
}
|
||||
|
||||
@Requirement
|
||||
private Logger logger;
|
||||
|
||||
@Requirement
|
||||
protected PlexusContainer container;
|
||||
|
||||
|
@ -149,9 +152,6 @@ public class DefaultPluginManager
|
|||
@Requirement
|
||||
protected MavenProjectBuilder mavenProjectBuilder;
|
||||
|
||||
@Requirement
|
||||
private Logger logger;
|
||||
|
||||
@Requirement
|
||||
protected RepositoryMetadataManager repositoryMetadataManager;
|
||||
|
||||
|
|
|
@ -162,7 +162,14 @@ public class DefaultMavenProjectBuilder
|
|||
public MavenProject buildFromRepository( Artifact artifact, List<ArtifactRepository> remoteArtifactRepositories, ArtifactRepository localRepository, boolean allowStubs )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
return buildFromRepository( artifact, remoteArtifactRepositories, localRepository );
|
||||
Artifact pomArtifact = artifact;
|
||||
|
||||
if ( !artifact.getType().equals( "pom" ) )
|
||||
{
|
||||
pomArtifact = repositorySystem.createProjectArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() );
|
||||
}
|
||||
|
||||
return buildFromRepository( pomArtifact, remoteArtifactRepositories, localRepository );
|
||||
}
|
||||
|
||||
public MavenProject buildFromRepository( Artifact artifact, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository )
|
||||
|
|
Loading…
Reference in New Issue