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 0a5e08f4ce59161fe670920d5e9d9a56a677c8ec
Author: Guillaume Nodet <[email protected]>
AuthorDate: Wed Apr 1 11:09:40 2026 +0200

    fix: only sync Build.resources for <sources> projects
    
    Avoid syncing Build.resources for legacy projects to prevent
    Path.toString() from converting forward slashes to backslashes
    on Windows (fixes PomConstructionTest.testTargetPathResourceRegression).
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
---
 .../java/org/apache/maven/project/DefaultProjectBuilder.java | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git 
a/impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
 
b/impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
index efa4ce2efc..f9c645be33 100644
--- 
a/impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
+++ 
b/impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
@@ -772,11 +772,13 @@ implicit fallback (only if they match the default, e.g., 
inherited)
                     
sourceContext.handleResourceConfiguration(ProjectScope.TEST);
                 }
 
-                // Sync model Build resources from sources set so that
-                // project.getBuild().getResources() is consistent with 
project.getResources().
-                // This is needed for Maven 3 plugin compatibility, since some 
plugins
-                // (e.g. maven-source-plugin) access resources via 
project.getBuild().getResources().
-                project.syncBuildResources();
+                // When resources are defined via <sources> (4.1.0 model), 
sync them to
+                // the model's Build so project.getBuild().getResources() is 
consistent.
+                // For legacy <resources>, the model already has the correct 
resources.
+                if (sourceContext.hasSources(Language.RESOURCES, 
ProjectScope.MAIN)
+                        || sourceContext.hasSources(Language.RESOURCES, 
ProjectScope.TEST)) {
+                    project.syncBuildResources();
+                }
             }
 
             project.setActiveProfiles(

Reply via email to