goutamadwant commented on code in PR #13041:
URL: https://github.com/apache/maven/pull/13041#discussion_r3946792928
##########
impl/maven-core/src/main/java/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.java:
##########
@@ -146,6 +160,26 @@ protected void mergePluginContainer_Plugins(
}
}
+ private Plugin mergePluginManagement(Plugin lifecyclePlugin, Plugin
managedPlugin, boolean sourceDominant) {
+ Plugin plugin = managedPlugin.clone();
+ plugin.getExecutions().removeIf(execution ->
!isFromSameLifecycle(lifecyclePlugin, execution));
+ mergePlugin(plugin, lifecyclePlugin, sourceDominant,
Collections.emptyMap());
+ return plugin;
+ }
+
+ private boolean isFromSameLifecycle(Plugin lifecyclePlugin,
PluginExecution managedExecution) {
+ String managedPhase = managedExecution.getPhase();
+ if (managedPhase == null) {
+ return true;
+ }
+
+ String managedLifecycle = phaseToLifecycle.get(managedPhase);
+ return lifecyclePlugin.getExecutions().stream()
+ .anyMatch(execution ->
managedPhase.equals(execution.getPhase())
+ || managedLifecycle != null
+ &&
managedLifecycle.equals(phaseToLifecycle.get(execution.getPhase())));
+ }
Review Comment:
Yes, exact-phase matching is intentional for unregistered phases. Added a
comment and tests for matching and nonmatching unknown phases, plus different
phases belonging to the same registered lifecycle.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]