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/05/18 21:51:48 UTC

(maven) branch maven-4.0.x-test-fixes updated (633b8ff862 -> b40490f4f4)

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

gnodet pushed a change to branch maven-4.0.x-test-fixes
in repository https://gitbox.apache.org/repos/asf/maven.git


    from 633b8ff862 Filter transitive dependencies with uninterpolated expressions
     new b59c22a1af Fix #12086: filter transitive repos with uninterpolated expressions
     new b40490f4f4 Fix #12087: add surefire and failsafe plugins to PluginUpgradeStrategy

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../invoker/mvnup/goals/PluginUpgradeStrategy.java | 12 +++-
 .../mvnup/goals/PluginUpgradeStrategyTest.java     | 84 ++++++++++++++++++++++
 .../resolver/DefaultArtifactDescriptorReader.java  |  7 ++
 3 files changed, 102 insertions(+), 1 deletion(-)


(maven) 02/02: Fix #12087: add surefire and failsafe plugins to PluginUpgradeStrategy

Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch maven-4.0.x-test-fixes
in repository https://gitbox.apache.org/repos/asf/maven.git

commit b40490f4f41047ca6e285f890b41d8916ed42a19
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Mon May 18 23:46:41 2026 +0200

    Fix #12087: add surefire and failsafe plugins to PluginUpgradeStrategy
    
    Older versions of maven-surefire-plugin and maven-failsafe-plugin
    (e.g. 3.1.2) are incompatible with Maven 4, failing with
    IllegalStateException in MojoExecutionScopeModule. Add both plugins
    with minimum version 3.5.2 so mvnup upgrades them automatically.
    
    Co-Authored-By: Claude Opus 4.6 <no...@anthropic.com>
---
 .../invoker/mvnup/goals/PluginUpgradeStrategy.java | 12 +++-
 .../mvnup/goals/PluginUpgradeStrategyTest.java     | 84 ++++++++++++++++++++++
 2 files changed, 95 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 411db349ef..37b0247464 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
@@ -101,7 +101,11 @@ public class PluginUpgradeStrategy extends AbstractUpgradeStrategy {
                     DEFAULT_MAVEN_PLUGIN_GROUP_ID,
                     "maven-remote-resources-plugin",
                     "3.0.0",
-                    MAVEN_4_COMPATIBILITY_REASON));
+                    MAVEN_4_COMPATIBILITY_REASON),
+            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));
 
     private static final List<PluginUpgrade> PLUGIN_DEPENDENCY_UPGRADES = List.of(new PluginUpgrade(
             "org.codehaus.mojo",
@@ -255,6 +259,12 @@ private Map<String, PluginUpgradeInfo> getPluginUpgradesMap() {
         upgrades.put(
                 DEFAULT_MAVEN_PLUGIN_GROUP_ID + ":maven-remote-resources-plugin",
                 new PluginUpgradeInfo(DEFAULT_MAVEN_PLUGIN_GROUP_ID, "maven-remote-resources-plugin", "3.0.0"));
+        upgrades.put(
+                DEFAULT_MAVEN_PLUGIN_GROUP_ID + ":maven-surefire-plugin",
+                new PluginUpgradeInfo(DEFAULT_MAVEN_PLUGIN_GROUP_ID, "maven-surefire-plugin", "3.5.2"));
+        upgrades.put(
+                DEFAULT_MAVEN_PLUGIN_GROUP_ID + ":maven-failsafe-plugin",
+                new PluginUpgradeInfo(DEFAULT_MAVEN_PLUGIN_GROUP_ID, "maven-failsafe-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 9a5b5598b3..9f38a93afc 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
@@ -272,6 +272,84 @@ void shouldUpgradePluginWithPropertyVersion() throws Exception {
             assertEquals("3.5.0", version);
         }
 
+        @Test
+        @DisplayName("should upgrade surefire plugin when below minimum")
+        void shouldUpgradeSurefirePluginWhenBelowMinimum() 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-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-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 upgrade failsafe plugin when below minimum")
+        void shouldUpgradeFailsafePluginWhenBelowMinimum() 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-failsafe-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-failsafe-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 {
@@ -495,9 +573,15 @@ void shouldHavePredefinedPluginUpgrades() throws Exception {
                     upgrades.stream().anyMatch(upgrade -> "maven-compiler-plugin".equals(upgrade.artifactId()));
             boolean hasExecPlugin =
                     upgrades.stream().anyMatch(upgrade -> "maven-exec-plugin".equals(upgrade.artifactId()));
+            boolean hasSurefirePlugin =
+                    upgrades.stream().anyMatch(upgrade -> "maven-surefire-plugin".equals(upgrade.artifactId()));
+            boolean hasFailsafePlugin =
+                    upgrades.stream().anyMatch(upgrade -> "maven-failsafe-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");
         }
 
         @Test


(maven) 01/02: Fix #12086: filter transitive repos with uninterpolated expressions

Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch maven-4.0.x-test-fixes
in repository https://gitbox.apache.org/repos/asf/maven.git

commit b59c22a1af31d607a1377611dccca75f5dd45cfe
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Mon May 18 23:51:28 2026 +0200

    Fix #12086: filter transitive repos with uninterpolated expressions
    
    Extend the uninterpolated expression filtering to also cover
    repositories from transitive dependency POMs. This prevents
    build failures when a transitive dependency defines a repository
    with a property expression (e.g., ${eclipseP2RepoId}) as its ID
    that is only available in the original project context.
    
    Cherry-picked and adapted from PR #12088 for the 4.0.x branch.
    
    Co-Authored-By: Claude Opus 4.6 <no...@anthropic.com>
---
 .../maven/impl/resolver/DefaultArtifactDescriptorReader.java       | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/impl/maven-impl/src/main/java/org/apache/maven/impl/resolver/DefaultArtifactDescriptorReader.java b/impl/maven-impl/src/main/java/org/apache/maven/impl/resolver/DefaultArtifactDescriptorReader.java
index fece86dc64..88d168cccf 100644
--- a/impl/maven-impl/src/main/java/org/apache/maven/impl/resolver/DefaultArtifactDescriptorReader.java
+++ b/impl/maven-impl/src/main/java/org/apache/maven/impl/resolver/DefaultArtifactDescriptorReader.java
@@ -334,6 +334,13 @@ private int getPolicy(RepositorySystemSession session, Artifact a, ArtifactDescr
     }
 
     private void filterUninterpolatedDependencies(ArtifactDescriptorResult result) {
+        result.getRepositories().removeIf(repo -> {
+            if (containsPlaceholder(repo.getId()) || containsPlaceholder(repo.getUrl())) {
+                logger.debug("Filtered repository with uninterpolated expression: {}", repo);
+                return true;
+            }
+            return false;
+        });
         result.getDependencies().removeIf(dep -> {
             if (hasUninterpolatedExpression(dep.getArtifact())) {
                 logger.debug("Filtered dependency with uninterpolated expression: {}", dep);