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


##########
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()) {

Review Comment:
   🐛 **Duplicate `if` guard — still not addressed**: The outer `if 
(!duplicateLifecyclePhases.isEmpty())` on this line is still a copy-paste 
artifact from a previous iteration. The inner block already has the same guard, 
so the outer one is completely redundant. Remove it:
   
   ```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);
           }
           return mojoExecutions;
   ```



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