gnodet opened a new pull request, #398: URL: https://github.com/apache/maven-filtering/pull/398
## Summary Restore "first `<resource>` entry wins" semantics for overlapping resource declarations. Port of [maven-filtering-3.x commits `306db11`](https://github.com/apache/maven-filtering/commit/306db11) and [`6d84663`](https://github.com/apache/maven-filtering/commit/6d84663) by Richard Zowalla. ## Problem When two `<resource>` entries cover the same source directory — one with `filtering=true` and a narrow `<include>`, the other with `filtering=false` and `<include>**</include>` — the placeholder in the file selected by the first entry is no longer replaced. This regression was introduced in `maven-filtering 3.3.2` when MSHARED-1216 switched to `CachingOutputStream`/`CachingWriter`: every write now goes through unconditionally if the bytes differ, so the unfiltered second entry silently clobbers the filtered first entry. ```xml <!-- This configuration stopped working correctly --> <resource> <filtering>true</filtering> <directory>src/main/resources</directory> <includes><include>config/filtered.xml</include></includes> </resource> <resource> <filtering>false</filtering> <directory>src/main/resources</directory> <includes><include>**</include></includes> </resource> ``` ## Fix `DefaultMavenResourcesFiltering.filterResources()` now tracks destination paths already written within a single call (`Set<Path> alreadyCopied`) and skips subsequent writes that would land on the same path. Explicit opt-in via `MavenResourcesExecution.setOverwrite(true)` preserves the previous "second entry clobbers" behaviour for callers that relied on it. The existing flatten-collision policy (warn-or-throw) is left untouched since that is a conceptually distinct case. ## Tests - **`OverlappingResourcesFilteringTest`** — new test reproducing the MRP-471 regression: asserts that `config/filtered.xml` has its placeholder replaced while `static/keep-as-is.txt` retains its literal placeholder - **`DefaultMavenResourcesFilteringTest.overlappingEntriesWithExplicitOverwriteStillReplace()`** — verifies that `setOverwrite(true)` still allows the second entry to clobber the first ## Fixes - https://github.com/apache/maven-resources-plugin/issues/471 -- 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]
