gnodet commented on code in PR #395:
URL: https://github.com/apache/maven-filtering/pull/395#discussion_r4094936071


##########
src/main/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java:
##########
@@ -363,6 +366,30 @@ static boolean isPropertiesFile(Path file) {
         return 
"properties".equals(getExtension(file.getFileName().toString()));
     }
 
+    /**
+     * Returns {@code true} if the given relative file path matches any of the 
provided
+     * Ant-style glob patterns, meaning the file should NOT be filtered.
+     *
+     * @param relativePath the file path relative to the resource directory 
(forward-slash separated)
+     * @param nonFilteredGlobs the list of glob patterns from {@link 
Resource#getNonFilteredFiles()},
+     *                         or {@code null} / empty if none
+     * @return {@code true} if the path matches at least one pattern
+     * @since 3.4.0
+     */
+    static boolean matchesNonFilteredGlob(String relativePath, List<String> 
nonFilteredGlobs) {
+        if (nonFilteredGlobs == null || nonFilteredGlobs.isEmpty()) {
+            return false;
+        }
+        // Normalize separators — plexus SelectorUtils expects forward slashes
+        String normalizedPath = relativePath.replace('\\', '/');
+        for (String glob : nonFilteredGlobs) {
+            if (SelectorUtils.matchPath(glob.replace('\\', '/'), 
normalizedPath, false)) {

Review Comment:
   Case-insensitive matching (`false`) is intentional here. The 
`nonFilteredFiles` glob list is user-defined in the POM and the same POM must 
work correctly on both Linux (case-sensitive FS) and Windows (case-insensitive 
FS). Using case-insensitive matching (`false`) means a pattern like `**/*.p12` 
also excludes `file.P12` on Linux, which is the behavior users expect when 
writing cross-platform builds. Ant's default case-sensitive behavior for 
includes/excludes (e.g., in `<resource>`) is correct for source matching, but 
for a binary-exclusion safety net the cross-platform interpretation is 
preferable.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to