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/10/19 21:21:27 UTC
(maven) branch maven-4.0.x updated: [4.0.x] fix #13521: restore phase config merging for null input (#13630)
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 7b069de92a [4.0.x] fix #13521: restore phase config merging for null input (#13630)
7b069de92a is described below
commit 7b069de92ae99467d2c337aa742327cf7371af6c
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Mon Oct 19 23:21:15 2026 +0200
[4.0.x] fix #13521: restore phase config merging for null input (#13630)
- Remove the null guard introduced in DefaultLifecycleExecutionPlanCalculator that broke merging of phase plugin configurations when the input is null; the merge method is null-safe and the guard caused regressions in Surefire ITs
- Add integration test covering the null-configuration merge path to prevent regression
Co-authored-by: Sebastian Tiemann <se...@mailbox.org>
---
.../DefaultLifecycleExecutionPlanCalculator.java | 12 ++----
.../it/MavenITgh13521PhaseConfigurationTest.java | 49 ++++++++++++++++++++++
.../resources/gh-13521-phase-configuration/pom.xml | 48 +++++++++++++++++++++
.../maven/plugin/coreit/ForkPhaseConfigMojo.java | 33 +++++++++++++++
.../main/resources/META-INF/maven/lifecycle.xml | 11 +++++
5 files changed, 145 insertions(+), 8 deletions(-)
diff --git a/impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleExecutionPlanCalculator.java b/impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleExecutionPlanCalculator.java
index efbcc2e7ae..f0f8528768 100644
--- a/impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleExecutionPlanCalculator.java
+++ b/impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleExecutionPlanCalculator.java
@@ -514,14 +514,10 @@ private void injectLifecycleOverlay(
if (phaseConfiguration != null) {
for (MojoExecution forkedExecution : forkedExecutions) {
org.codehaus.plexus.util.xml.Xpp3Dom config = forkedExecution.getConfiguration();
-
- if (config != null) {
- XmlNode forkedConfiguration = config.getDom();
-
- forkedConfiguration = XmlService.merge(phaseConfiguration, forkedConfiguration);
-
- forkedExecution.setConfiguration(forkedConfiguration);
- }
+ XmlNode forkedConfiguration = config != null
+ ? XmlService.merge(phaseConfiguration, config.getDom())
+ : phaseConfiguration;
+ forkedExecution.setConfiguration(forkedConfiguration);
}
}
}
diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh13521PhaseConfigurationTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh13521PhaseConfigurationTest.java
new file mode 100644
index 0000000000..e4204e7203
--- /dev/null
+++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITgh13521PhaseConfigurationTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.io.File;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * This is a test set for <a href="https://github.com/apache/maven/issues/13521">GH-13521</a>.
+ * Tests that phase configuration is applied to forked executions with no prior configuration.
+ */
+public class MavenITgh13521PhaseConfigurationTest extends AbstractMavenIntegrationTestCase {
+
+ public MavenITgh13521PhaseConfigurationTest() {
+ super("(4.0.0,)");
+ }
+
+ @Test
+ public void testPhaseConfigurationAppliedToUnconfiguredExecution() throws Exception {
+ File testDir = extractResources("/gh-13521-phase-configuration");
+
+ Verifier verifier = newVerifier(testDir.getAbsolutePath());
+ verifier.setAutoclean(false);
+ verifier.deleteDirectory("target");
+ verifier.addCliArgument("org.apache.maven.its.plugins:maven-it-plugin-fork:fork-phase-config");
+ verifier.execute();
+ verifier.verifyErrorFreeLog();
+
+ verifier.verifyFilePresent("target/phase-config/touch.txt");
+ verifier.verifyFileNotPresent("target/touch.txt");
+ }
+}
diff --git a/its/core-it-suite/src/test/resources/gh-13521-phase-configuration/pom.xml b/its/core-it-suite/src/test/resources/gh-13521-phase-configuration/pom.xml
new file mode 100644
index 0000000000..549aafdbe5
--- /dev/null
+++ b/its/core-it-suite/src/test/resources/gh-13521-phase-configuration/pom.xml
@@ -0,0 +1,48 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>gh-13521-phase-config</groupId>
+ <artifactId>base-project</artifactId>
+ <version>${revision}</version>
+ <packaging>pom</packaging>
+
+ <properties>
+ <revision>1.0.0</revision>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.its.plugins</groupId>
+ <artifactId>maven-it-plugin-fork</artifactId>
+ <version>2.1-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <phase>generate-resources</phase>
+ <goals><goal>touch</goal></goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkPhaseConfigMojo.java b/its/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkPhaseConfigMojo.java
new file mode 100644
index 0000000000..01d3fd8c03
--- /dev/null
+++ b/its/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/java/org/apache/maven/plugin/coreit/ForkPhaseConfigMojo.java
@@ -0,0 +1,33 @@
+/*
+ * 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.plugin.coreit;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugins.annotations.Execute;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+
+@Mojo(name = "fork-phase-config")
+@Execute(phase = LifecyclePhase.GENERATE_RESOURCES, lifecycle = "phase-config")
+public class ForkPhaseConfigMojo extends AbstractMojo {
+
+ @Override
+ public void execute() {}
+}
diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/resources/META-INF/maven/lifecycle.xml b/its/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/resources/META-INF/maven/lifecycle.xml
index 9504c71e0c..6146119edb 100644
--- a/its/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/resources/META-INF/maven/lifecycle.xml
+++ b/its/core-it-support/core-it-plugins/maven-it-plugin-fork/src/main/resources/META-INF/maven/lifecycle.xml
@@ -25,4 +25,15 @@
</phase>
</phases>
</lifecycle>
+ <lifecycle>
+ <id>phase-config</id>
+ <phases>
+ <phase>
+ <id>generate-resources</id>
+ <configuration>
+ <outputDirectory>${project.build.directory}/phase-config</outputDirectory>
+ </configuration>
+ </phase>
+ </phases>
+ </lifecycle>
</lifecycles>