gnodet-bot commented on code in PR #14025:
URL: https://github.com/apache/maven/pull/14025#discussion_r4643375445
##########
impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleExecutionPlanCalculator.java:
##########
@@ -233,13 +241,26 @@ 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()) {
+ LOG.warn("The given lifecycle phases overlap. If this is not
intended, you should check your Maven Build.");
Review Comment:
⚠️ **Still open** — the warning message is still a static string that tells
the user phases overlap but not *which* ones. `duplicateLifecyclePhases` is
collected correctly as a `LinkedHashSet` but then discarded.
Note also that the IT test's `OVERLAP_WARNING` constant (line 103 of the
test file) matches the current static message — once the message is updated to
include phase names, `verifyTextInLog(OVERLAP_WARNING)` will need to be updated
to match only the **static prefix** of the message, or use a prefix-match
approach.
Suggested fix:
```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]