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 cf510b39e1 [maven-4.0.x] Add maven-surefire-report-plugin to
PluginUpgradeStrategy (#12114)
cf510b39e1 is described below
commit cf510b39e1ea1eb24fd9ce5066bf65242fcc160a
Author: Guillaume Nodet <[email protected]>
AuthorDate: Tue May 19 23:42:58 2026 +0200
[maven-4.0.x] Add maven-surefire-report-plugin to PluginUpgradeStrategy
(#12114)
The surefire-report plugin is released from the same Maven Surefire
project as surefire and failsafe plugins, sharing the same version
and Maven 4 compatibility constraints. Add it with the same 3.5.2
minimum version to keep all three in sync.
Backport of #12113.
Co-authored-by: Claude Opus 4.6 <[email protected]>
---
.../invoker/mvnup/goals/PluginUpgradeStrategy.java | 10 +++++-
.../mvnup/goals/PluginUpgradeStrategyTest.java | 42 ++++++++++++++++++++++
2 files changed, 51 insertions(+), 1 deletion(-)
diff --git
a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/PluginUpgradeStrategy.java
b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/PluginUpgradeStrategy.java
index 0f1a31406c..d6db2dd01f 100644
---
a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/PluginUpgradeStrategy.java
+++
b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/PluginUpgradeStrategy.java
@@ -104,7 +104,12 @@ public class PluginUpgradeStrategy extends
AbstractUpgradeStrategy {
new PluginUpgrade(
DEFAULT_MAVEN_PLUGIN_GROUP_ID, "maven-surefire-plugin",
"3.5.2", MAVEN_4_COMPATIBILITY_REASON),
new PluginUpgrade(
- DEFAULT_MAVEN_PLUGIN_GROUP_ID, "maven-failsafe-plugin",
"3.5.2", MAVEN_4_COMPATIBILITY_REASON));
+ DEFAULT_MAVEN_PLUGIN_GROUP_ID, "maven-failsafe-plugin",
"3.5.2", MAVEN_4_COMPATIBILITY_REASON),
+ new PluginUpgrade(
+ DEFAULT_MAVEN_PLUGIN_GROUP_ID,
+ "maven-surefire-report-plugin",
+ "3.5.2",
+ MAVEN_4_COMPATIBILITY_REASON));
private static final List<PluginUpgrade> PLUGIN_DEPENDENCY_UPGRADES =
List.of(new PluginUpgrade(
"org.codehaus.mojo",
@@ -264,6 +269,9 @@ private Map<String, PluginUpgradeInfo>
getPluginUpgradesMap() {
upgrades.put(
DEFAULT_MAVEN_PLUGIN_GROUP_ID + ":maven-failsafe-plugin",
new PluginUpgradeInfo(DEFAULT_MAVEN_PLUGIN_GROUP_ID,
"maven-failsafe-plugin", "3.5.2"));
+ upgrades.put(
+ DEFAULT_MAVEN_PLUGIN_GROUP_ID +
":maven-surefire-report-plugin",
+ new PluginUpgradeInfo(DEFAULT_MAVEN_PLUGIN_GROUP_ID,
"maven-surefire-report-plugin", "3.5.2"));
return upgrades;
}
diff --git
a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/PluginUpgradeStrategyTest.java
b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/PluginUpgradeStrategyTest.java
index 07347ca268..657994d9a1 100644
---
a/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/PluginUpgradeStrategyTest.java
+++
b/impl/maven-cli/src/test/java/org/apache/maven/cling/invoker/mvnup/goals/PluginUpgradeStrategyTest.java
@@ -389,6 +389,45 @@ void shouldUpgradeFailsafePluginWhenBelowMinimum() throws
Exception {
assertEquals("3.5.2", version);
}
+ @Test
+ @DisplayName("should upgrade surefire-report plugin when below
minimum")
+ void shouldUpgradeSurefireReportPluginWhenBelowMinimum() throws
Exception {
+ String pomXml = """
+ <?xml version="1.0" encoding="UTF-8"?>
+ <project xmlns="http://maven.apache.org/POM/4.0.0">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>test</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0.0</version>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+
<artifactId>maven-surefire-report-plugin</artifactId>
+ <version>3.1.2</version>
+ </plugin>
+ </plugins>
+ </build>
+ </project>
+ """;
+
+ Document document = Document.of(pomXml);
+ Map<Path, Document> pomMap = Map.of(Paths.get("pom.xml"),
document);
+
+ UpgradeContext context = createMockContext();
+ UpgradeResult result = strategy.doApply(context, pomMap);
+
+ assertTrue(result.success(), "Plugin upgrade should succeed");
+ assertTrue(result.modifiedCount() > 0, "Should have upgraded
maven-surefire-report-plugin");
+
+ Editor editor = new Editor(document);
+ Element root = editor.root();
+ String version = root.path("build", "plugins", "plugin", "version")
+ .map(Element::textContentTrimmed)
+ .orElse(null);
+ assertEquals("3.5.2", version);
+ }
+
@Test
@DisplayName("should not upgrade when version is already higher")
void shouldNotUpgradeWhenVersionAlreadyHigher() throws Exception {
@@ -703,11 +742,14 @@ void shouldHavePredefinedPluginUpgrades() throws
Exception {
upgrades.stream().anyMatch(upgrade ->
"maven-surefire-plugin".equals(upgrade.artifactId()));
boolean hasFailsafePlugin =
upgrades.stream().anyMatch(upgrade ->
"maven-failsafe-plugin".equals(upgrade.artifactId()));
+ boolean hasSurefireReportPlugin =
+ upgrades.stream().anyMatch(upgrade ->
"maven-surefire-report-plugin".equals(upgrade.artifactId()));
assertTrue(hasCompilerPlugin, "Should include
maven-compiler-plugin upgrade");
assertTrue(hasExecPlugin, "Should include maven-exec-plugin
upgrade");
assertTrue(hasSurefirePlugin, "Should include
maven-surefire-plugin upgrade");
assertTrue(hasFailsafePlugin, "Should include
maven-failsafe-plugin upgrade");
+ assertTrue(hasSurefireReportPlugin, "Should include
maven-surefire-report-plugin upgrade");
}
@Test