gnodet-bot commented on code in PR #14025:
URL: https://github.com/apache/maven/pull/14025#discussion_r4643695815


##########
impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleExecutionPlanCalculator.java:
##########
@@ -233,13 +241,31 @@ public List<MojoExecution> 
calculateMojoExecutions(MavenSession session, MavenPr
                 Map<String, List<MojoExecution>> phaseToMojoMapping =
                         calculateLifecycleMappings(session, project, 
lifecyclePhase);
 
+                Set<String> alreadyPlannedPhases = mojoExecutions.stream()
+                        .map(MojoExecution::getLifecyclePhase)
+                        .filter(Objects::nonNull)
+                        .collect(Collectors.toSet());
+
                 for (List<MojoExecution> mojoExecutionsFromLifecycle : 
phaseToMojoMapping.values()) {
+                    mojoExecutionsFromLifecycle.stream()
+                            .map(MojoExecution::getLifecyclePhase)
+                            .filter(alreadyPlannedPhases::contains)
+                            .forEach(duplicateLifecyclePhases::add);
                     mojoExecutions.addAll(mojoExecutionsFromLifecycle);
                 }
+
             } else {
                 throw new IllegalStateException("unexpected task " + task);
             }
         }
+        if (!duplicateLifecyclePhases.isEmpty()) {
+        if (!duplicateLifecyclePhases.isEmpty()) {
+            LOG.warn(
+                    "The following lifecycle phases overlap and will cause 
some plugins to execute multiple times: {}."
+                            + " If this is not intended, review the phases 
passed on the command line.",
+                    duplicateLifecyclePhases);
+        }
+        }

Review Comment:
   🐛 **Duplicate `if` guard — still present**: The outer `if 
(!duplicateLifecyclePhases.isEmpty())` on this line is a copy-paste artifact 
from a previous iteration. The same condition gates the inner block 
redundantly. Remove the outer guard:
   
   ```suggestion
           if (!duplicateLifecyclePhases.isEmpty()) {
               LOG.warn(
                       "The following lifecycle phases overlap and will cause 
some plugins to execute multiple times: {}."
                               + " If this is not intended, review the phases 
passed on the command line.",
                       duplicateLifecyclePhases);
           }
   ```



-- 
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]

Reply via email to