Repository: maven Updated Branches: refs/heads/master a035d9026 -> 02795b21e
[MNG-5359] Declared execution in PluginMgmt gets bound to lifecycle (regression) o Re-opening issue and reverting commits 901b1e8e4c9df50ccc12bf8759589c7c82400aae d5ba185c1ab926b53acb0947c8a13ad74eac55e6 029af3a394b37610ecfb97c07b4f62895f7d2eb7 cc006b544f0e21683d955e2175b06e864e64329f e84405162b8a228aaced264f48ec6a3e8ed261e8 Project: http://git-wip-us.apache.org/repos/asf/maven/repo Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/02795b21 Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/02795b21 Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/02795b21 Branch: refs/heads/master Commit: 02795b21e753bdd4eddd7e9ebee9f50315bc0e24 Parents: a035d90 Author: Christian Schulte <schu...@apache.org> Authored: Thu Jan 14 14:59:15 2016 +0100 Committer: Christian Schulte <schu...@apache.org> Committed: Thu Jan 14 15:17:39 2016 +0100 ---------------------------------------------------------------------- .../project/DefaultMavenProjectBuilder.java | 1 - .../project/EmptyLifecyclePluginAnalyzer.java | 8 - .../execution/DefaultMavenExecutionRequest.java | 1 - .../lifecycle/DefaultLifecycleExecutor.java | 3 - .../maven/lifecycle/DefaultLifecycles.java | 4 +- .../lifecycle/LifeCyclePluginAnalyzer.java | 22 +- .../maven/lifecycle/LifecycleExecutor.java | 18 +- .../lifecycle/LifecycleMappingDelegate.java | 11 - .../LifecycleMappingNotFoundException.java | 45 ---- .../DefaultLifecycleMappingDelegate.java | 9 - .../DefaultLifecyclePluginAnalyzer.java | 228 ++----------------- .../DefaultLifecycleBindingsInjector.java | 42 ++-- .../maven/project/DefaultProjectBuilder.java | 1 - .../project/DefaultProjectBuildingRequest.java | 17 -- .../maven/project/ProjectBuildingRequest.java | 20 -- .../lifecycle/EmptyLifecyclePluginAnalyzer.java | 8 - .../stub/LifeCyclePluginAnalyzerStub.java | 16 +- .../building/DefaultModelBuildingRequest.java | 17 -- .../building/FilterModelBuildingRequest.java | 15 +- .../model/building/ModelBuildingRequest.java | 19 -- .../model/plugin/DefaultReportingConverter.java | 6 - 21 files changed, 59 insertions(+), 452 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven/blob/02795b21/maven-compat/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java b/maven-compat/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java index 6834a17..7bc5a5c 100644 --- a/maven-compat/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java +++ b/maven-compat/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java @@ -101,7 +101,6 @@ public class DefaultMavenProjectBuilder { request.setActiveProfileIds( req.getActiveProfiles() ); request.setInactiveProfileIds( req.getInactiveProfiles() ); - request.setGoals( request.getGoals() ); } } } http://git-wip-us.apache.org/repos/asf/maven/blob/02795b21/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecyclePluginAnalyzer.java ---------------------------------------------------------------------- diff --git a/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecyclePluginAnalyzer.java b/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecyclePluginAnalyzer.java index ead0157..672e07b 100644 --- a/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecyclePluginAnalyzer.java +++ b/maven-compat/src/test/java/org/apache/maven/project/EmptyLifecyclePluginAnalyzer.java @@ -24,7 +24,6 @@ import java.util.LinkedHashSet; import java.util.Set; import org.apache.maven.lifecycle.LifeCyclePluginAnalyzer; -import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; @@ -34,7 +33,6 @@ import org.apache.maven.model.PluginExecution; public class EmptyLifecyclePluginAnalyzer implements LifeCyclePluginAnalyzer { - public Set<Plugin> getPluginsBoundByDefaultToAllLifecycles( String packaging ) { Set<Plugin> plugins; @@ -59,12 +57,6 @@ public class EmptyLifecyclePluginAnalyzer return plugins; } - @Override - public Set<Plugin> getDefaultBuildPlugins( final Model model, final Set<String> goals ) - { - return Collections.emptySet(); - } - private Plugin newPlugin( String artifactId, String... goals ) { Plugin plugin = new Plugin(); http://git-wip-us.apache.org/repos/asf/maven/blob/02795b21/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java index 218b4ec..71a6894 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java +++ b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java @@ -1105,7 +1105,6 @@ public class DefaultMavenExecutionRequest projectBuildingRequest.setProfiles( getProfiles() ); projectBuildingRequest.setProcessPlugins( true ); projectBuildingRequest.setBuildStartTime( getStartTime() ); - projectBuildingRequest.setGoals( getGoals() ); } return projectBuildingRequest; http://git-wip-us.apache.org/repos/asf/maven/blob/02795b21/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java ---------------------------------------------------------------------- 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 8d0405c..6f994b3 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 @@ -100,10 +100,7 @@ public class DefaultLifecycleExecutor // TODO: This whole method could probably removed by injecting lifeCyclePluginAnalyzer straight into client site. // TODO: But for some reason the whole plexus appcontext refuses to start when I try this. - @Override - @Deprecated public Set<Plugin> getPluginsBoundByDefaultToAllLifecycles( String packaging ) - throws LifecycleMappingNotFoundException { return lifeCyclePluginAnalyzer.getPluginsBoundByDefaultToAllLifecycles( packaging ); } http://git-wip-us.apache.org/repos/asf/maven/blob/02795b21/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java index 788c2fe..48cd0c5 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycles.java @@ -66,9 +66,9 @@ public class DefaultLifecycles this.lifecycles = lifecycles; } - public Lifecycle get( String phase ) + public Lifecycle get( String key ) { - return getPhaseToLifecycleMap().get( phase ); + return getPhaseToLifecycleMap().get( key ); } /** http://git-wip-us.apache.org/repos/asf/maven/blob/02795b21/maven-core/src/main/java/org/apache/maven/lifecycle/LifeCyclePluginAnalyzer.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/LifeCyclePluginAnalyzer.java b/maven-core/src/main/java/org/apache/maven/lifecycle/LifeCyclePluginAnalyzer.java index 536e167..ed07c1d 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/LifeCyclePluginAnalyzer.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/LifeCyclePluginAnalyzer.java @@ -20,8 +20,6 @@ package org.apache.maven.lifecycle; */ import java.util.Set; - -import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; /** @@ -30,23 +28,5 @@ import org.apache.maven.model.Plugin; */ public interface LifeCyclePluginAnalyzer { - - @Deprecated - Set<Plugin> getPluginsBoundByDefaultToAllLifecycles( String packaging ) - throws LifecycleMappingNotFoundException; - - /** - * Gets a set of default build {@code Plugin}s for a given {@code Model} and a Maven execution with the given goals. - * - * @param model The model to get the default build {@code Plugin}s for. - * @param goals A set of goals of the current Maven invokation. - * - * @return A set of default build {@code Plugin}s for {@code Model}. - * - * @throws LifecycleMappingNotFoundException if {@code model} does not declare a supported packaging. - * @since 3.4 - */ - Set<Plugin> getDefaultBuildPlugins( Model model, Set<String> goals ) - throws LifecycleMappingNotFoundException; - + Set<Plugin> getPluginsBoundByDefaultToAllLifecycles( String packaging ); } http://git-wip-us.apache.org/repos/asf/maven/blob/02795b21/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleExecutor.java ---------------------------------------------------------------------- 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 9e74ba2..04c602c 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 @@ -47,15 +47,21 @@ public interface LifecycleExecutor @Deprecated String ROLE = LifecycleExecutor.class.getName(); + // For a given project packaging find all the plugins that are bound to any registered + // lifecycles. The project builder needs to now what default plugin information needs to be + // merged into POM being built. Once the POM builder has this plugin information, versions can be assigned + // by the POM builder because they will have to be defined in plugin management. Once this is setComplete then it + // can be passed back so that the default configuration information can be populated. + // + // We need to know the specific version so that we can lookup the right version of the plugin descriptor + // which tells us what the default configuration is. + // + /** * @return The plugins bound to the lifecycles of the specified packaging or {@code null} if the packaging is - * unknown. - * - * @deprecated Please use {@link LifeCyclePluginAnalyzer}. + * unknown. */ - @Deprecated - Set<Plugin> getPluginsBoundByDefaultToAllLifecycles( String packaging ) - throws LifecycleMappingNotFoundException; + Set<Plugin> getPluginsBoundByDefaultToAllLifecycles( String packaging ); MavenExecutionPlan calculateExecutionPlan( MavenSession session, String... tasks ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, http://git-wip-us.apache.org/repos/asf/maven/blob/02795b21/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleMappingDelegate.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleMappingDelegate.java b/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleMappingDelegate.java index 0b4465f..f070198 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleMappingDelegate.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleMappingDelegate.java @@ -21,7 +21,6 @@ package org.apache.maven.lifecycle; import java.util.List; import java.util.Map; -import java.util.Set; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.InvalidPluginDescriptorException; @@ -46,16 +45,6 @@ import org.apache.maven.project.MavenProject; */ public interface LifecycleMappingDelegate { - - /** - * Gets a set of lifecycle identifiers of lifecycles this delegate is requiring to operate. - * - * @return An unmodifiable set of lifecycle identifiers of lifecycles this delegate is requiring to operate. - * - * @since 3.4 - */ - Set<String> getRequiredLifecycles(); - Map<String, List<MojoExecution>> calculateLifecycleMappings( MavenSession session, MavenProject project, Lifecycle lifecycle, String lifecyclePhase ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, http://git-wip-us.apache.org/repos/asf/maven/blob/02795b21/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleMappingNotFoundException.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleMappingNotFoundException.java b/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleMappingNotFoundException.java deleted file mode 100644 index 983f052..0000000 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/LifecycleMappingNotFoundException.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.apache.maven.lifecycle; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * Signals a failure to locate a lifecycle mapping. - * - * @author Christian Schulte - * - * @since 3.4 - */ -public final class LifecycleMappingNotFoundException extends Exception -{ - - private String packaging; - - public LifecycleMappingNotFoundException( final String packaging ) - { - super( String.format( "No lifecycle mapping found for packaging '%s'.", packaging ) ); - this.packaging = packaging; - } - - public String getPackaging() - { - return this.packaging; - } - -} http://git-wip-us.apache.org/repos/asf/maven/blob/02795b21/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleMappingDelegate.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleMappingDelegate.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleMappingDelegate.java index 305fa4e..8348530 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleMappingDelegate.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleMappingDelegate.java @@ -20,11 +20,9 @@ package org.apache.maven.lifecycle.internal; */ import java.util.ArrayList; -import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.TreeMap; import org.apache.maven.execution.MavenSession; @@ -53,13 +51,6 @@ public class DefaultLifecycleMappingDelegate @Requirement private BuildPluginManager pluginManager; - @Override - public Set<String> getRequiredLifecycles() - { - // The default delegate requires no lifecycles to operate. - return Collections.emptySet(); - } - public Map<String, List<MojoExecution>> calculateLifecycleMappings( MavenSession session, MavenProject project, Lifecycle lifecycle, String lifecyclePhase ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, http://git-wip-us.apache.org/repos/asf/maven/blob/02795b21/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecyclePluginAnalyzer.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecyclePluginAnalyzer.java b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecyclePluginAnalyzer.java index b98b5f1..a72ce8e 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecyclePluginAnalyzer.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecyclePluginAnalyzer.java @@ -19,25 +19,12 @@ package org.apache.maven.lifecycle.internal; * under the License. */ -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - import org.apache.maven.lifecycle.DefaultLifecycles; import org.apache.maven.lifecycle.LifeCyclePluginAnalyzer; import org.apache.maven.lifecycle.Lifecycle; -import org.apache.maven.lifecycle.LifecycleMappingDelegate; -import org.apache.maven.lifecycle.LifecycleMappingNotFoundException; import org.apache.maven.lifecycle.mapping.LifecycleMapping; import org.apache.maven.lifecycle.mapping.LifecycleMojo; import org.apache.maven.lifecycle.mapping.LifecyclePhase; -import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; import org.codehaus.plexus.component.annotations.Component; @@ -45,14 +32,23 @@ import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.StringUtils; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + /** * @since 3.0 * @author Benjamin Bentmann * @author Jason van Zyl * @author jdcasey * @author Kristian Rosenvold (extracted class only) - * <p/> - * NOTE: This class is not part of any public api and can be changed or deleted without prior notice. + * <p/> + * NOTE: This class is not part of any public api and can be changed or deleted without prior notice. */ @Component( role = LifeCyclePluginAnalyzer.class ) public class DefaultLifecyclePluginAnalyzer @@ -65,12 +61,6 @@ public class DefaultLifecyclePluginAnalyzer @Requirement private DefaultLifecycles defaultLifeCycles; - @Requirement( hint = DefaultLifecycleMappingDelegate.HINT ) - private LifecycleMappingDelegate defaultLifecycleMappingDelegate; - - @Requirement - private Map<String, LifecycleMappingDelegate> lifecycleMappingDelegates; - @Requirement private Logger logger; @@ -82,23 +72,25 @@ public class DefaultLifecyclePluginAnalyzer // <plugin/> block in a Maven POM. We have to do some wiggling to pull the sources of information // together and this really shows the problem of constructing a sensible default configuration but // it's all encapsulated here so it appears normalized to the POM builder. + // We are going to take the project packaging and find all plugin in the default lifecycle and create // fully populated Plugin objects, including executions with goals and default configuration taken // from the plugin.xml inside a plugin. + // + public Set<Plugin> getPluginsBoundByDefaultToAllLifecycles( String packaging ) - throws LifecycleMappingNotFoundException { if ( logger.isDebugEnabled() ) { logger.debug( "Looking up lifecyle mappings for packaging " + packaging + " from " - + Thread.currentThread().getContextClassLoader() ); + + Thread.currentThread().getContextClassLoader() ); } LifecycleMapping lifecycleMappingForPackaging = lifecycleMappings.get( packaging ); if ( lifecycleMappingForPackaging == null ) { - throw new LifecycleMappingNotFoundException( packaging ); + return null; } Map<Plugin, Plugin> plugins = new LinkedHashMap<>(); @@ -136,178 +128,6 @@ public class DefaultLifecyclePluginAnalyzer return plugins.keySet(); } - @Override - public Set<Plugin> getDefaultBuildPlugins( final Model model, final Set<String> goals ) - throws LifecycleMappingNotFoundException - { - final Map<Plugin, Plugin> defaultBuildPlugins = new LinkedHashMap<>(); - final Set<String> executedLifecycles = new HashSet<>(); - - // Plugins of lifecycles of the 'MavenExecutionRequest' goals or the project default goals. - if ( goals != null ) - { - if ( !goals.isEmpty() ) - { - // Command line goals. - for ( final String goal : goals ) - { - if ( !isGoalSpecification( goal ) ) - { - final Lifecycle lifecycle = this.defaultLifeCycles.get( goal ); - - if ( lifecycle != null ) - { - executedLifecycles.add( lifecycle.getId() ); - } - } - } - } - else if ( model.getBuild() != null && model.getBuild().getDefaultGoal() != null ) - { - // No command line goals -> default goal(s). - // Copied from 'DefaultLifecycleTaskSegmentCalculator'. - if ( !StringUtils.isEmpty( model.getBuild().getDefaultGoal() ) ) - { - for ( final String goal - : Arrays.asList( StringUtils.split( model.getBuild().getDefaultGoal() ) ) ) - { - if ( !isGoalSpecification( goal ) ) - { - final Lifecycle lifecycle = this.defaultLifeCycles.get( goal ); - - if ( lifecycle != null ) - { - executedLifecycles.add( lifecycle.getId() ); - } - } - } - } - } - } - - // If nothing is to be executed via MavenExecutionRequest or default goals from the model, no need to provide - // anything as nothing will ever get executed. - if ( !executedLifecycles.isEmpty() ) - { - // Plugins of lifecycles plugin executions are bound to manually. - if ( model.getBuild() != null && model.getBuild().getPlugins() != null ) - { - for ( final Plugin plugin : model.getBuild().getPlugins() ) - { - executedLifecycles.addAll( this.getLifecycleRequirements( plugin ) ); - } - } - - // Plugins of lifecycles required by lifecycle mapping delegates. - for ( final Lifecycle lifecycle : this.defaultLifeCycles.getLifeCycles() ) - { - // Keep in sync with - // DefaultLifecycleExecutionPlanCalculator#calculateLifecycleMappings( MavenSession session, - // MavenProject project, - // String lifecyclePhase ) - final LifecycleMappingDelegate lifecycleMappingDelegate = - Arrays.binarySearch( DefaultLifecycles.STANDARD_LIFECYCLES, lifecycle.getId() ) >= 0 - ? defaultLifecycleMappingDelegate - : lifecycleMappingDelegates.containsKey( lifecycle.getId() ) - ? lifecycleMappingDelegates.get( lifecycle.getId() ) - : defaultLifecycleMappingDelegate; - - for ( final String id : lifecycleMappingDelegate.getRequiredLifecycles() ) - { - executedLifecycles.add( id ); - } - } - } - - for ( final Lifecycle lifecycle : this.getOrderedLifecycles() ) - { - if ( executedLifecycles.contains( lifecycle.getId() ) ) - { - org.apache.maven.lifecycle.mapping.Lifecycle lifecycleConfiguration = null; - - if ( lifecycle.getId().equals( "default" ) ) - { - if ( logger.isDebugEnabled() ) - { - logger.debug( String.format( "Looking up lifecyle mappings for packaging '%s' from '%s'", - model.getPackaging(), - Thread.currentThread().getContextClassLoader() ) ); - - } - - final LifecycleMapping lifecycleMappingForPackaging = - this.lifecycleMappings.get( model.getPackaging() ); - - if ( lifecycleMappingForPackaging == null ) - { - throw new LifecycleMappingNotFoundException( model.getPackaging() ); - } - - lifecycleConfiguration = lifecycleMappingForPackaging.getLifecycles().get( lifecycle.getId() ); - } - - Map<String, LifecyclePhase> phaseToGoalMapping = null; - - if ( lifecycleConfiguration != null ) - { - phaseToGoalMapping = lifecycleConfiguration.getLifecyclePhases(); - } - else if ( lifecycle.getDefaultLifecyclePhases() != null ) - { - phaseToGoalMapping = lifecycle.getDefaultLifecyclePhases(); - } - - if ( phaseToGoalMapping != null ) - { - for ( final Map.Entry<String, LifecyclePhase> goalsForLifecyclePhase - : phaseToGoalMapping.entrySet() ) - { - final String phase = goalsForLifecyclePhase.getKey(); - final LifecyclePhase lifecyclePhase = goalsForLifecyclePhase.getValue(); - - if ( goals != null ) - { - parseLifecyclePhaseDefinitions( defaultBuildPlugins, phase, lifecyclePhase ); - } - } - } - } - } - - return defaultBuildPlugins.keySet(); - } - - private Set<String> getLifecycleRequirements( final Plugin plugin ) - { - final Set<String> executedLifecycles = new HashSet<>(); - - for ( final PluginExecution pluginExecution : plugin.getExecutions() ) - { - if ( pluginExecution.getPhase() != null ) - { - final Lifecycle lifecycle = this.defaultLifeCycles.get( pluginExecution.getPhase() ); - - if ( lifecycle != null ) - { - executedLifecycles.add( lifecycle.getId() ); - } - } - else - { - // TODO: If omitted, the goals will be bound to the default phase specified by the plugin. - // TODO: Forked executions. - } - } - - return executedLifecycles; - } - - // Copied from 'DefaultLifecycleTaskSegmentCalculator'. - private static boolean isGoalSpecification( String task ) - { - return task.indexOf( ':' ) >= 0; - } - private List<Lifecycle> getOrderedLifecycles() { // NOTE: The lifecycle order can affect implied execution ids so we better be deterministic. @@ -332,25 +152,25 @@ public class DefaultLifecyclePluginAnalyzer List<LifecycleMojo> mojos = goals.getMojos(); if ( mojos != null ) { - + for ( int i = 0; i < mojos.size(); i++ ) { LifecycleMojo mojo = mojos.get( i ); - + GoalSpec gs = parseGoalSpec( mojo.getGoal() ); - + if ( gs == null ) { logger.warn( "Ignored invalid goal specification '" + mojo.getGoal() - + "' from lifecycle mapping for phase " + phase ); + + "' from lifecycle mapping for phase " + phase ); continue; } - + Plugin plugin = new Plugin(); plugin.setGroupId( gs.groupId ); plugin.setArtifactId( gs.artifactId ); plugin.setVersion( gs.version ); - + Plugin existing = plugins.get( plugin ); if ( existing != null ) { @@ -364,14 +184,14 @@ public class DefaultLifecyclePluginAnalyzer { plugins.put( plugin, plugin ); } - + PluginExecution execution = new PluginExecution(); execution.setId( getExecutionId( plugin, gs.goal ) ); execution.setPhase( phase ); execution.setPriority( i - mojos.size() ); execution.getGoals().add( gs.goal ); execution.setConfiguration( mojo.getConfiguration() ); - + plugin.setDependencies( mojo.getDependencies() ); plugin.getExecutions().add( execution ); } http://git-wip-us.apache.org/repos/asf/maven/blob/02795b21/maven-core/src/main/java/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.java b/maven-core/src/main/java/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.java index b77bf0a..1401e30 100644 --- a/maven-core/src/main/java/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.java +++ b/maven-core/src/main/java/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.java @@ -22,13 +22,11 @@ package org.apache.maven.model.plugin; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import org.apache.maven.lifecycle.LifeCyclePluginAnalyzer; -import org.apache.maven.lifecycle.LifecycleMappingNotFoundException; import org.apache.maven.model.Build; import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; @@ -36,12 +34,11 @@ import org.apache.maven.model.PluginContainer; import org.apache.maven.model.PluginExecution; import org.apache.maven.model.PluginManagement; import org.apache.maven.model.building.ModelBuildingRequest; +import org.apache.maven.model.building.ModelProblemCollector; import org.apache.maven.model.building.ModelProblem.Severity; import org.apache.maven.model.building.ModelProblem.Version; -import org.apache.maven.model.building.ModelProblemCollector; import org.apache.maven.model.building.ModelProblemCollectorRequest; import org.apache.maven.model.merge.MavenModelMerger; - import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; @@ -58,36 +55,27 @@ public class DefaultLifecycleBindingsInjector private LifecycleBindingsMerger merger = new LifecycleBindingsMerger(); @Requirement - private LifeCyclePluginAnalyzer lifecyclePluginAnalyzer; + private LifeCyclePluginAnalyzer lifecycle; public void injectLifecycleBindings( Model model, ModelBuildingRequest request, ModelProblemCollector problems ) { - try - { - // MNG-5359: request.setGoals() may not have been called since the goals got added for MNG-5359 in 3.4. In - // this case fall back to the pre 3.4 behaviour. Usages of ProjectBuildingRequest and - // ModelBuildingRequest without setting the goals should behave the same way as before. - final Collection<Plugin> defaultPlugins = - request.getGoals() == null - ? lifecyclePluginAnalyzer.getPluginsBoundByDefaultToAllLifecycles( model.getPackaging() ) - : lifecyclePluginAnalyzer.getDefaultBuildPlugins( model, new HashSet<>( request.getGoals() ) ); - - if ( !defaultPlugins.isEmpty() ) - { - Model lifecycleModel = new Model(); - lifecycleModel.setBuild( new Build() ); - lifecycleModel.getBuild().getPlugins().addAll( defaultPlugins ); + String packaging = model.getPackaging(); - merger.merge( model, lifecycleModel ); - } + Collection<Plugin> defaultPlugins = lifecycle.getPluginsBoundByDefaultToAllLifecycles( packaging ); + + if ( defaultPlugins == null ) + { + problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) + .setMessage( "Unknown packaging: " + packaging ) + .setLocation( model.getLocation( "packaging" ) ) ); } - catch ( final LifecycleMappingNotFoundException e ) + else if ( !defaultPlugins.isEmpty() ) { - problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ). - setException( e ). - setMessage( "Unknown packaging: " + model.getPackaging() ). - setLocation( model.getLocation( "packaging" ) ) ); + Model lifecycleModel = new Model(); + lifecycleModel.setBuild( new Build() ); + lifecycleModel.getBuild().getPlugins().addAll( defaultPlugins ); + merger.merge( model, lifecycleModel ); } } http://git-wip-us.apache.org/repos/asf/maven/blob/02795b21/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java index 3b3fe74..fb15c87 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java @@ -272,7 +272,6 @@ public class DefaultProjectBuilder request.setBuildStartTime( configuration.getBuildStartTime() ); request.setModelResolver( resolver ); request.setModelCache( new ReactorModelCache() ); - request.setGoals( configuration.getGoals() ); return request; } http://git-wip-us.apache.org/repos/asf/maven/blob/02795b21/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java index ab5de1c..97eb276 100644 --- a/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java +++ b/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingRequest.java @@ -20,7 +20,6 @@ package org.apache.maven.project; */ import java.util.ArrayList; -import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Properties; @@ -68,8 +67,6 @@ public class DefaultProjectBuildingRequest private RepositoryMerging repositoryMerging = RepositoryMerging.POM_DOMINANT; - private List<String> goals; - public DefaultProjectBuildingRequest() { processPlugins = true; @@ -99,7 +96,6 @@ public class DefaultProjectBuildingRequest setProject( request.getProject() ); setResolveDependencies( request.isResolveDependencies() ); setValidationLevel( request.getValidationLevel() ); - setGoals( request.getGoals() ); } public MavenProject getProject() @@ -343,19 +339,6 @@ public class DefaultProjectBuildingRequest return this; } - @Override - public List<String> getGoals() - { - return this.goals; - } - - @Override - public DefaultProjectBuildingRequest setGoals( final List<String> value ) - { - this.goals = value != null ? Collections.unmodifiableList( value ) : null; - return this; - } - public RepositoryMerging getRepositoryMerging() { return repositoryMerging; http://git-wip-us.apache.org/repos/asf/maven/blob/02795b21/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java ---------------------------------------------------------------------- diff --git a/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java b/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java index c87c8d9..17a53b1 100644 --- a/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java +++ b/maven-core/src/main/java/org/apache/maven/project/ProjectBuildingRequest.java @@ -185,26 +185,6 @@ public interface ProjectBuildingRequest ProjectBuildingRequest setResolveVersionRanges( boolean value ); /** - * Gets the goals the user requested to execute. - * - * @return An unmodifiable set of goals to execute or {@code null}. - * - * @since 3.4 - */ - List<String> getGoals(); - - /** - * Sets the goals the user requested to execute. - * - * @param value Set of goals the user requested to execute or {@code null}. - * - * @return This request, newver {@code null}. - * - * @since 3.4 - */ - ProjectBuildingRequest setGoals( List<String> value ); - - /** * The possible merge modes for combining remote repositories. */ enum RepositoryMerging http://git-wip-us.apache.org/repos/asf/maven/blob/02795b21/maven-core/src/test/java/org/apache/maven/lifecycle/EmptyLifecyclePluginAnalyzer.java ---------------------------------------------------------------------- diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/EmptyLifecyclePluginAnalyzer.java b/maven-core/src/test/java/org/apache/maven/lifecycle/EmptyLifecyclePluginAnalyzer.java index 5106fd9..a812c26 100644 --- a/maven-core/src/test/java/org/apache/maven/lifecycle/EmptyLifecyclePluginAnalyzer.java +++ b/maven-core/src/test/java/org/apache/maven/lifecycle/EmptyLifecyclePluginAnalyzer.java @@ -23,7 +23,6 @@ import java.util.Collections; import java.util.LinkedHashSet; import java.util.Set; -import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; @@ -33,7 +32,6 @@ import org.apache.maven.model.PluginExecution; public class EmptyLifecyclePluginAnalyzer implements LifeCyclePluginAnalyzer { - public Set<Plugin> getPluginsBoundByDefaultToAllLifecycles( String packaging ) { Set<Plugin> plugins; @@ -58,12 +56,6 @@ public class EmptyLifecyclePluginAnalyzer return plugins; } - @Override - public Set<Plugin> getDefaultBuildPlugins( final Model model, final Set<String> goals ) - { - return Collections.emptySet(); - } - private Plugin newPlugin( String artifactId, String... goals ) { Plugin plugin = new Plugin(); http://git-wip-us.apache.org/repos/asf/maven/blob/02795b21/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/LifeCyclePluginAnalyzerStub.java ---------------------------------------------------------------------- diff --git a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/LifeCyclePluginAnalyzerStub.java b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/LifeCyclePluginAnalyzerStub.java index 75d7923..b067e24 100644 --- a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/LifeCyclePluginAnalyzerStub.java +++ b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/stub/LifeCyclePluginAnalyzerStub.java @@ -15,22 +15,20 @@ package org.apache.maven.lifecycle.internal.stub; -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.Set; - import org.apache.maven.lifecycle.LifeCyclePluginAnalyzer; -import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.Set; + /** * @author Kristian Rosenvold */ public class LifeCyclePluginAnalyzerStub implements LifeCyclePluginAnalyzer { - public Set<Plugin> getPluginsBoundByDefaultToAllLifecycles( String packaging ) { Set<Plugin> plugins; @@ -55,12 +53,6 @@ public class LifeCyclePluginAnalyzerStub return plugins; } - @Override - public Set<Plugin> getDefaultBuildPlugins( final Model model, final Set<String> goals ) - { - return Collections.emptySet(); - } - private Plugin newPlugin( String artifactId, String... goals ) { Plugin plugin = new Plugin(); http://git-wip-us.apache.org/repos/asf/maven/blob/02795b21/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java ---------------------------------------------------------------------- diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java index f5e1c83..a3505c9 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java @@ -21,7 +21,6 @@ package org.apache.maven.model.building; import java.io.File; import java.util.ArrayList; -import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Properties; @@ -74,8 +73,6 @@ public class DefaultModelBuildingRequest private WorkspaceModelResolver workspaceResolver; - private List<String> goals; - /** * Creates an empty request. */ @@ -104,7 +101,6 @@ public class DefaultModelBuildingRequest setModelResolver( request.getModelResolver() ); setModelBuildingListener( request.getModelBuildingListener() ); setModelCache( request.getModelCache() ); - setGoals( request.getGoals() ); } @Override @@ -409,17 +405,4 @@ public class DefaultModelBuildingRequest return this; } - @Override - public List<String> getGoals() - { - return this.goals; - } - - @Override - public ModelBuildingRequest setGoals( final List<String> value ) - { - this.goals = value != null ? Collections.unmodifiableList( value ) : null; - return this; - } - } http://git-wip-us.apache.org/repos/asf/maven/blob/02795b21/maven-model-builder/src/main/java/org/apache/maven/model/building/FilterModelBuildingRequest.java ---------------------------------------------------------------------- diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/FilterModelBuildingRequest.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/FilterModelBuildingRequest.java index 480668c..c5c2cbf 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/FilterModelBuildingRequest.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/FilterModelBuildingRequest.java @@ -282,17 +282,4 @@ class FilterModelBuildingRequest return this; } - @Override - public List<String> getGoals() - { - return request.getGoals(); - } - - @Override - public ModelBuildingRequest setGoals( final List<String> value ) - { - request.setGoals( value ); - return this; - } - -} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven/blob/02795b21/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingRequest.java ---------------------------------------------------------------------- diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingRequest.java b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingRequest.java index e1cad14..c10274d 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingRequest.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingRequest.java @@ -335,23 +335,4 @@ public interface ModelBuildingRequest ModelBuildingRequest setWorkspaceModelResolver( WorkspaceModelResolver workspaceResolver ); - /** - * Gets the goals the user requested to execute. - * - * @return An unmodifiable set of goals to execute or {@code null}. - * - * @since 3.4 - */ - List<String> getGoals(); - - /** - * Sets the goals the user requested to execute. - * - * @param value Set of goals the user requested to execute or {@code null}. - * - * @return This request, newver {@code null}. - * - * @since 3.4 - */ - ModelBuildingRequest setGoals( List<String> value ); } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven/blob/02795b21/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java ---------------------------------------------------------------------- diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java b/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java index 4d2bef1..d918d9e 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/plugin/DefaultReportingConverter.java @@ -66,12 +66,6 @@ public class DefaultReportingConverter { sitePlugin = new Plugin(); sitePlugin.setArtifactId( "maven-site-plugin" ); - - // MNG-5359: Since the site plugin is no longer added if not requested by the user, a version needs to be - // provided here. This version should be kept in sync with the version declared for the 'site' - // lifecycle. Prior to MNG-5359, findSitePlugin( build ) never returned 'null'. - sitePlugin.setVersion( "3.3" ); - PluginManagement pluginManagement = build.getPluginManagement(); if ( pluginManagement == null ) {