You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2026/06/23 05:39:43 UTC
(maven) branch maven-4.0.x updated: [#12331] Fix clean/site lifecycle bindings executing after pom.xml goals
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch maven-4.0.x
in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/maven-4.0.x by this push:
new 408bc65624 [#12331] Fix clean/site lifecycle bindings executing after pom.xml goals
408bc65624 is described below
commit 408bc65624c3291543dfd6ecd298fb958b20be02
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Tue Jun 23 07:36:59 2026 +0200
[#12331] Fix clean/site lifecycle bindings executing after pom.xml goals
Fix goal bindings in pom.xml being executed before lifecycle bindings
for the clean and site lifecycles (regression vs Maven 3).
Lifecycles.plugin() creates executions for built-in clean and site
lifecycle bindings (e.g. default-clean) without setting a priority,
so they defaulted to 0 — the same as user-defined executions from
pom.xml. Add .priority(-1) to make them consistent with how default
lifecycle packaging bindings work in DefaultPackagingRegistry.
---
.../org/apache/maven/internal/impl/Lifecycles.java | 1 +
.../maven/lifecycle/LifecycleExecutorTest.java | 18 +++++
.../project-with-clean-phase-execution/pom.xml | 92 ++++++++++++++++++++++
3 files changed, 111 insertions(+)
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 d7ddeeba3d..4d20267fc1 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)
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 ca45e941b4..a2941050f7 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
@@ -315,6 +315,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<MojoExecution> 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 0000000000..4ee3ccd5ab
--- /dev/null
+++ b/impl/maven-core/src/test/projects/lifecycle-executor/project-with-clean-phase-execution/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.lifecycle.test</groupId>
+ <artifactId>project-with-clean-phase-execution</artifactId>
+ <version>1.0</version>
+ <packaging>jar</packaging>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-clean-plugin</artifactId>
+ <version>0.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>0.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <version>0.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-install-plugin</artifactId>
+ <version>0.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>0.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>0.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>0.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>0.1</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.its.plugins</groupId>
+ <artifactId>maven-it-plugin</artifactId>
+ <version>0.1</version>
+ <executions>
+ <execution>
+ <id>user-clean-execution</id>
+ <phase>clean</phase>
+ <goals>
+ <goal>it</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>