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

hboutemy pushed a commit to branch maven-resources-plugin-3.x
in repository https://gitbox.apache.org/repos/asf/maven-resources-plugin.git


The following commit(s) were added to refs/heads/maven-resources-plugin-3.x by 
this push:
     new f514841  Fix user-filters IT fixture for Maven 4 compatibility
f514841 is described below

commit f514841b527a6f74ef4f1693b76f6ee6d5a11757
Author: Gerd Aschemann <[email protected]>
AuthorDate: Sun Jun 7 22:39:55 2026 +0200

    Fix user-filters IT fixture for Maven 4 compatibility
    
    Maven 4 splits CLI -D values strictly into 
MavenSession.getUserProperties(); they no longer leak into 
getSystemProperties() as they did on Maven 3. The user-filters IT's ItFilter 
test fixture read getSystemProperties() only, so under Maven 4 it wrote 
'toto=null' and the post-build groovy assertion 'content.contains("toto=titi")' 
failed.
    
    Consult getUserProperties() first and fall back to getSystemProperties() so 
the fixture works on both Maven 3.9.x and Maven 4.0.0-rc-5+.
    
    Production plugin code is unchanged; the bug is only in the IT fixture.
    
    This unblocks PR #466 (enable Maven 4 CI matrix).
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
---
 .../apache/maven/plugins/resources/filters/ItFilter.java   | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git 
a/src/test/java/org/apache/maven/plugins/resources/filters/ItFilter.java 
b/src/test/java/org/apache/maven/plugins/resources/filters/ItFilter.java
index 22c4ccc..eca5818 100644
--- a/src/test/java/org/apache/maven/plugins/resources/filters/ItFilter.java
+++ b/src/test/java/org/apache/maven/plugins/resources/filters/ItFilter.java
@@ -29,6 +29,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
+import org.apache.maven.execution.MavenSession;
 import org.apache.maven.shared.filtering.MavenFilteringException;
 import org.apache.maven.shared.filtering.MavenResourcesExecution;
 import org.apache.maven.shared.filtering.MavenResourcesFiltering;
@@ -68,11 +69,14 @@ public class ItFilter implements MavenResourcesFiltering {
 
             lines.add("foo");
             lines.add("version=" + 
mavenResourcesExecution.getMavenProject().getVersion());
-            lines.add("toto="
-                    + mavenResourcesExecution
-                            .getMavenSession()
-                            .getSystemProperties()
-                            .getProperty("toto"));
+            MavenSession session = mavenResourcesExecution.getMavenSession();
+            // Maven 4 splits CLI -D into user properties strictly; Maven 3 
merged them into
+            // system properties as well. Consult user properties first, then 
fall back.
+            String toto = session.getUserProperties().getProperty("toto");
+            if (toto == null) {
+                toto = session.getSystemProperties().getProperty("toto");
+            }
+            lines.add("toto=" + toto);
             Path target = f.toPath();
             Files.createDirectories(target.getParent());
             Files.write(target, lines);

Reply via email to