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


##########
impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleExecutionPlanCalculator.java:
##########
@@ -211,6 +211,9 @@ public List<MojoExecution> 
calculateMojoExecutions(MavenSession session, MavenPr
                     MojoNotFoundException, NoPluginFoundForPrefixException, 
InvalidPluginDescriptorException,
                     PluginVersionResolutionException, 
LifecyclePhaseNotFoundException {
         final List<MojoExecution> mojoExecutions = new ArrayList<>();
+        final Set<String> skippedPhases = session.getRequest() != null
+                ? new HashSet<>(session.getRequest().getSkippedPhases())
+                : Set.of();

Review Comment:
   **Sub-phase expansion is asymmetric — sequential path still does exact-match 
only.**
   
   Commit `8c5cf895` added `expandSkippedPhases()` to 
`BuildPlanExecutor.plan()`, so the concurrent path now correctly propagates 
`--skip-phases=verify` to sub-phases (`test`, `integration-test`, etc.).
   
   But the sequential path here (`DefaultLifecycleExecutionPlanCalculator`) 
still builds `skippedPhases` as a bare `HashSet` with no expansion. The default 
Maven 4 build uses the `singlethreaded` builder (set in `MavenInvoker` line 
113: `mavenExecutionRequest.setBuilderId("singlethreaded")`), which flows 
through `SingleThreadedBuilder` → `BuilderCommon` → this class. With no `-T` 
flag, `--skip-phases=verify` will filter only mojos whose execution phase is 
literally `"verify"` — it will NOT skip mojos bound to `test` (a child of 
`verify` in the Maven 4 DAG), even though the user reasonably expects it to.
   
   With `-T2` (multithreaded → `BuildPlanExecutor`), expansion happens and 
`test` is skipped. The behavior is inconsistent across builders for the same 
option.
   
   Fix: extract `expandSkippedPhases()` to a shared location (e.g. a static 
helper in a new utility class or in `MavenExecutionRequest` itself) and call it 
from both sites:
   
   ```suggestion
           final Set<String> skippedPhases = session.getRequest() != null
                   ? expandSkippedPhases(new 
HashSet<>(session.getRequest().getSkippedPhases()))
                   : Set.of();
   ```
   
   where `expandSkippedPhases` must also be added to this class (inject 
`LifecycleRegistry` or pass the lifecycle context needed to walk the DAG). 
Alternatively, expand once in `MavenInvoker.populateRequest()` before the 
phases are stored in the request, so both paths see the already-expanded set — 
that would be simpler and avoids duplicating the expansion logic.



##########
its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng13230SkipPhasesTest.java:
##########
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.it;
+
+import java.nio.file.Path;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Integration tests for the {@code --skip-phases} and {@code --skip-tests} 
CLI options
+ * introduced by <a 
href="https://github.com/apache/maven/issues/13230";>GH-13230</a>,
+ * and the lifecycle DAG change that makes {@code install} and {@code deploy} 
depend on
+ * {@code verify} (so that {@code mvn install} always runs {@code verify}).
+ *
+ * @since 4.1.0
+ */
+class MavenITmng13230SkipPhasesTest extends AbstractMavenIntegrationTestCase {
+
+    /**
+     * Verify that {@code --skip-phases=test} suppresses mojo executions bound 
to
+     * the {@code test} phase (e.g. maven-surefire-plugin) while still running
+     * the phases leading up to and after it.
+     */
+    @Test
+    void skipPhasesSupressesMojosForSkippedPhase() throws Exception {

Review Comment:
   **Typo in method name:** `Supresses` → `Suppresses` (missing second `p`).
   
   ```suggestion
       void skipPhasesSupressesMojosForSkippedPhase() throws Exception {
   ```
   
   Wait — the method name itself has the typo. The correct spelling:
   
   ```suggestion
       void skipPhasesSuppressesMojosForSkippedPhase() throws Exception {
   ```



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