Repository: maven
Updated Branches:
  refs/heads/master 61a92559a -> a4d6cf2a2


[MNG-5359] Declared execution in PluginMgmt gets bound to lifecycle (regression)

o Updated to preserve management of default phases (== null).


Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/a4d6cf2a
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/a4d6cf2a
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/a4d6cf2a

Branch: refs/heads/master
Commit: a4d6cf2a20b51a4829731bef6b042ac63cf6fa20
Parents: 61a9255
Author: Christian Schulte <schu...@apache.org>
Authored: Mon Jan 18 04:05:39 2016 +0100
Committer: Christian Schulte <schu...@apache.org>
Committed: Mon Jan 18 04:05:39 2016 +0100

----------------------------------------------------------------------
 .../DefaultLifecyclePluginAnalyzer.java         | 47 ++++++++------------
 1 file changed, 19 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/a4d6cf2a/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 b7c50c1..6d56978 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
@@ -22,7 +22,6 @@ package org.apache.maven.lifecycle.internal;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -169,7 +168,6 @@ public class DefaultLifecyclePluginAnalyzer
                 {
                     final String phase = goalsForLifecyclePhase.getKey();
                     final LifecyclePhase goals = 
goalsForLifecyclePhase.getValue();
-                    final Map<Plugin, Plugin> previousPlugins = new HashMap<>( 
plugins );
 
                     if ( goals != null )
                     {
@@ -180,40 +178,33 @@ public class DefaultLifecyclePluginAnalyzer
                     {
                         for ( final Plugin plugin : plugins.keySet() )
                         {
-                            if ( !previousPlugins.containsKey( plugin ) )
+                            final Plugin managedPlugin = 
this.getManagedPlugin( pluginManagement, plugin );
+
+                            if ( managedPlugin != null )
                             {
-                                // Creates management entry for plugin of 
current lifecycle.
-                                final Plugin managedPlugin = 
this.getManagedPlugin( pluginManagement, plugin );
+                                final List<PluginExecution> defaultExecutions =
+                                    new ArrayList<>( 
managedPlugin.getExecutions().size() );
 
-                                if ( managedPlugin != null )
+                                for ( final PluginExecution pluginExecution : 
managedPlugin.getExecutions() )
                                 {
-                                    // Retains only executions of current 
lifecyle.
-                                    final List<PluginExecution> 
defaultExecutions =
-                                        new ArrayList<>( 
managedPlugin.getExecutions().size() );
-
-                                    for ( final PluginExecution 
pluginExecution : managedPlugin.getExecutions() )
+                                    // What if the plugin's default phase (== 
null) is not from the current lifecyle?
+                                    if ( pluginExecution.getPhase() == null
+                                             || 
lifecycle.getPhases().contains( pluginExecution.getPhase() ) )
                                     {
-                                        if ( pluginExecution.getPhase() != null
-                                                 && 
lifecycle.getPhases().contains( pluginExecution.getPhase() ) )
-                                        {
-                                            defaultExecutions.add( 
pluginExecution );
-                                        }
+                                        defaultExecutions.add( pluginExecution 
);
                                     }
+                                }
 
-                                    if ( !defaultExecutions.isEmpty() )
-                                    {
-                                        final Plugin defaultManagedPlugin =
-                                            this.getManagedPlugin( 
lifecycleModel.getBuild().getPluginManagement(),
-                                                                   
managedPlugin );
-
-                                        for ( final PluginExecution 
pluginExecution : defaultExecutions )
-                                        {
-                                            defaultManagedPlugin.addExecution( 
pluginExecution );
-                                        }
+                                final Plugin defaultManagedPlugin =
+                                    this.getManagedPlugin( 
lifecycleModel.getBuild().getPluginManagement(),
+                                                           managedPlugin );
 
-                                        
managedPlugin.getExecutions().removeAll( defaultExecutions );
-                                    }
+                                for ( final PluginExecution pluginExecution : 
defaultExecutions )
+                                {
+                                    defaultManagedPlugin.addExecution( 
pluginExecution );
                                 }
+
+                                managedPlugin.getExecutions().removeAll( 
defaultExecutions );
                             }
                         }
                     }

Reply via email to