From bd55363af49e889d1208475cee78c1e1a2c66478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Sat, 20 Jun 2026 18:36:12 +0200 Subject: [PATCH 1/2] increase lifecycle bindings priority against pom ones --- .../src/main/java/org/apache/maven/internal/impl/Lifecycles.java | 1 + 1 file changed, 1 insertion(+) diff --git a/impl/maven-core/src/main/java/org/apache/maven/internal/impl/Lifecycles.java b/impl/maven-core/src/main/java/org/apache/maven/internal/impl/Lifecycles.java index d7ddeeba3d3f..4d20267fc121 100644 --- a/impl/maven-core/src/main/java/org/apache/maven/internal/impl/Lifecycles.java +++ b/impl/maven-core/src/main/java/org/apache/maven/internal/impl/Lifecycles.java @@ -74,6 +74,7 @@ static Plugin plugin(String coords, String phase) { .version(c[2]) .executions(Collections.singletonList(PluginExecution.newBuilder() .id("default-" + c[3]) + .priority(-1) .phase(phase) .goals(Collections.singletonList(c[3])) .location("", DefaultLifecycleRegistry.DEFAULT_LIFECYCLE_INPUT_LOCATION) From a105a0b11a02c033b6611cae5f0150cb1524c986 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 22 Jun 2026 23:40:26 +0200 Subject: [PATCH 2/2] Add test for clean lifecycle binding ordering (MNG-12331) Verify that lifecycle-default bindings (default-clean) run before pom.xml-defined executions bound to the same phase, matching Maven 3 behavior. Co-Authored-By: Claude Opus 4.6 --- .../lifecycle/LifecycleExecutorTest.java | 18 ++++ .../pom.xml | 92 +++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 impl/maven-core/src/test/projects/lifecycle-executor/project-with-clean-phase-execution/pom.xml diff --git a/impl/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java b/impl/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java index 09f1027e993e..a338aa820757 100644 --- a/impl/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java +++ b/impl/maven-core/src/test/java/org/apache/maven/lifecycle/LifecycleExecutorTest.java @@ -313,6 +313,24 @@ MavenExecutionPlan calculateExecutionPlan(MavenSession session, String... tasks) session, session.getCurrentProject(), mergedSegment.getTasks()); } + @Test + void testCleanLifecycleBindingRunsBeforePomExecution() throws Exception { + File pom = getProject("project-with-clean-phase-execution"); + MavenSession session = createMavenSession(pom); + assertEquals( + "project-with-clean-phase-execution", + session.getCurrentProject().getArtifactId()); + List executionPlan = getExecutions(calculateExecutionPlan(session, "clean")); + assertEquals(2, executionPlan.size()); + assertListEquals( + List.of("clean:clean", "it:it"), + executionPlan.stream() + .map(e -> e.getMojoDescriptor().getFullGoalName()) + .toList()); + assertEquals("default-clean", executionPlan.get(0).getExecutionId()); + assertEquals("user-clean-execution", executionPlan.get(1).getExecutionId()); + } + @Test void testInvalidGoalName() throws Exception { File pom = getProject("project-basic"); diff --git a/impl/maven-core/src/test/projects/lifecycle-executor/project-with-clean-phase-execution/pom.xml b/impl/maven-core/src/test/projects/lifecycle-executor/project-with-clean-phase-execution/pom.xml new file mode 100644 index 000000000000..4ee3ccd5ab21 --- /dev/null +++ b/impl/maven-core/src/test/projects/lifecycle-executor/project-with-clean-phase-execution/pom.xml @@ -0,0 +1,92 @@ + + + + + + 4.0.0 + + org.apache.maven.lifecycle.test + project-with-clean-phase-execution + 1.0 + jar + + + + + + org.apache.maven.plugins + maven-clean-plugin + 0.1 + + + org.apache.maven.plugins + maven-compiler-plugin + 0.1 + + + org.apache.maven.plugins + maven-deploy-plugin + 0.1 + + + org.apache.maven.plugins + maven-install-plugin + 0.1 + + + org.apache.maven.plugins + maven-jar-plugin + 0.1 + + + org.apache.maven.plugins + maven-plugin-plugin + 0.1 + + + org.apache.maven.plugins + maven-resources-plugin + 0.1 + + + org.apache.maven.plugins + maven-surefire-plugin + 0.1 + + + + + + org.apache.maven.its.plugins + maven-it-plugin + 0.1 + + + user-clean-execution + clean + + it + + + + + + +