This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git


The following commit(s) were added to refs/heads/master by this push:
     new febffbc63e fix: concurrent builder runs verify phase before package 
(#14151) (#14156)
febffbc63e is described below

commit febffbc63e9c2fd3bec67e8e78fc33fcb1fe4a90
Author: Guillaume Nodet <[email protected]>
AuthorDate: Fri Nov 27 22:40:44 2026 +0100

    fix: concurrent builder runs verify phase before package (#14151) (#14156)
    
    With -b concurrent, the VERIFY container phase only declared 
after(VALIDATE),
    making before:verify independent of after:build in the execution DAG. As a
    result, mojos bound to the 'verify' phase (failsafe:verify, jacoco:check,
    dependency:analyze-only, gpg:sign) could be scheduled before compilation,
    tests and packaging completed, causing BUILD SUCCESS on a failing build.
    
    Add after(BUILD) to the VERIFY phase definition so that before:verify
    executes after after:build, restoring Maven 3 sequential semantics for
    all mojos bound to 'verify' or any of its child phases.
    
    Fixes #14151
---
 .../internal/impl/DefaultLifecycleRegistry.java    |  1 +
 .../internal/concurrent/BuildPlanCreatorTest.java  | 41 ++++++++++++++++++++++
 2 files changed, 42 insertions(+)

diff --git 
a/impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultLifecycleRegistry.java
 
b/impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultLifecycleRegistry.java
index 1769176954..447520e6e0 100644
--- 
a/impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultLifecycleRegistry.java
+++ 
b/impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultLifecycleRegistry.java
@@ -476,6 +476,7 @@ public Collection<Phase> phases() {
                             phase(
                                     VERIFY,
                                     after(VALIDATE),
+                                    after(BUILD),
                                     phase(
                                             UNIT_TEST,
                                             phase(TEST_SOURCES),
diff --git 
a/impl/maven-core/src/test/java/org/apache/maven/lifecycle/internal/concurrent/BuildPlanCreatorTest.java
 
b/impl/maven-core/src/test/java/org/apache/maven/lifecycle/internal/concurrent/BuildPlanCreatorTest.java
index 72466dc904..e66c556ee4 100644
--- 
a/impl/maven-core/src/test/java/org/apache/maven/lifecycle/internal/concurrent/BuildPlanCreatorTest.java
+++ 
b/impl/maven-core/src/test/java/org/apache/maven/lifecycle/internal/concurrent/BuildPlanCreatorTest.java
@@ -625,4 +625,45 @@ void 
testReactorPluginWithLibraryDependencyPreCompilePhase() {
                 .forEach(s -> assertFalse(
                         s.skip.get(), "Predecessor step " + s.name + " of 
plugin project (p2) must not be skipped"));
     }
+
+    /**
+     * Regression test for <a 
href="https://github.com/apache/maven/issues/14151";>#14151</a>:
+     * with the concurrent builder, goals bound to the {@code verify} phase 
(e.g.
+     * {@code failsafe:verify}, {@code jacoco:check}) must not run before 
compilation,
+     * tests and packaging complete.
+     *
+     * <p>Root cause: the {@code VERIFY} container phase only declared {@code 
after(VALIDATE)},
+     * so its {@code before:verify} build step had no ordering edge to {@code 
after:build}.
+     * The fix adds {@code after(BUILD)} to the {@code VERIFY} phase 
definition, ensuring
+     * {@code before:verify executeAfter after:build} in the DAG.</p>
+     */
+    @Test
+    void testVerifyPhaseWaitsForBuild() {
+        MavenProject project = new MavenProject();
+        project.setCollectedProjects(List.of());
+        Map<MavenProject, List<MavenProject>> projects = 
Collections.singletonMap(project, Collections.emptyList());
+
+        BuildPlan plan = calculateLifecycleMappings(projects, "verify");
+
+        // before:verify must transitively depend on after:build (and 
therefore after:package).
+        // We verify this by checking that after:build is reachable in the 
predecessor graph
+        // of before:verify — i.e. before:verify cannot be scheduled before 
build completes.
+        BuildStep beforeVerify = plan.requiredStep(project, "before:verify");
+        boolean afterBuildIsPrerequisite = beforeVerify
+                .allPredecessors()
+                .anyMatch(step -> step.project == project && 
"after:build".equals(step.name));
+
+        assertTrue(
+                afterBuildIsPrerequisite,
+                "before:verify must transitively depend on after:build so that 
mojos bound to "
+                        + "'verify' (e.g. failsafe:verify, jacoco:check) 
cannot run before "
+                        + "compilation, test and packaging complete (#14151)");
+
+        // Symmetrically, after:package (a child of build) must also be a 
transitive prerequisite.
+        boolean afterPackageIsPrerequisite = beforeVerify
+                .allPredecessors()
+                .anyMatch(step -> step.project == project && 
"after:package".equals(step.name));
+
+        assertTrue(afterPackageIsPrerequisite, "before:verify must 
transitively depend on after:package (#14151)");
+    }
 }

Reply via email to