diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java index 9270b053dd..4150c170e3 100644 --- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java +++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java @@ -171,8 +171,6 @@ public class DefaultMaven result.setProject( reactorManager.getTopLevelProject() ); - result.setBuildPlans( session.getBuildPlans() ); - dispatcher.dispatchEnd( event, request.getBaseDirectory() ); return result; diff --git a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionResult.java b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionResult.java index 4a3d08a5ee..8083f03d4f 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionResult.java +++ b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionResult.java @@ -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; - } } diff --git a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionResult.java b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionResult.java index d73be93750..ad3c8b241d 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionResult.java +++ b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionResult.java @@ -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 ); } diff --git a/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java b/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java index 03104c6d31..f5b2cbc359 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java +++ b/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java @@ -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(); diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java index 00dbbc11f4..1d822e6a15 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java @@ -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 { diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java b/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java index 4fadaf5404..cd4d8e48ef 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java @@ -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. diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlanner.java b/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlanner.java index 3eb666ed70..49039a70e7 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlanner.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/plan/BuildPlanner.java @@ -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; } diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DefaultBuildPlanner.java b/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DefaultBuildPlanner.java index 03a81fd024..ff60352f21 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DefaultBuildPlanner.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/plan/DefaultBuildPlanner.java @@ -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 ) ); diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java index 4a229349f6..7149461e8e 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java @@ -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; diff --git a/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java index 5a5ba02bfa..6fdd164768 100644 --- a/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java +++ b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java @@ -162,7 +162,14 @@ public class DefaultMavenProjectBuilder public MavenProject buildFromRepository( Artifact artifact, List 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 remoteRepositories, ArtifactRepository localRepository )