gnodet opened a new pull request, #395:
URL: https://github.com/apache/maven-filtering/pull/395
## Summary
Adds two complementary mechanisms for handling binary files in filtered
resource directories, replacing the silent-fallback approach from #303.
## Changes
### 1. Per-resource `nonFilteredFiles` glob list (primary mechanism)
`Resource` now has a `nonFilteredFiles: List<String>` field accepting
Ant-style glob patterns. Files matching any pattern are copied as-is, bypassing
the filter chain — even within a `<resource>` block that has
`<filtering>true</filtering>`.
`DefaultMavenResourcesFiltering` evaluates these patterns (via
`SelectorUtils.matchPath()`, already on the classpath) alongside the existing
`filteredFileExtension()` check.
Advantages over extension-only matching:
- Handles **extension-less binaries** (test keystores, generated fixtures)
- Supports **path-scoped exclusions** (`**/certs/**`, `**/keys/**`)
- Is **per-resource**, so surgical — does not affect other resource blocks
Example (exposed by maven-resources-plugin in a companion PR):
```xml
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<nonFilteredFiles>
<nonFilteredFile>**/*.p12</nonFilteredFile>
<nonFilteredFile>**/*.jks</nonFilteredFile>
<nonFilteredFile>**/certs/**</nonFilteredFile>
<nonFilteredFile>binary-file</nonFilteredFile>
</nonFilteredFiles>
</resource>
```
### 2. Opt-in `gracefulBinaryHandling` flag (safety net)
`MavenResourcesExecution` now has a `gracefulBinaryHandling` boolean
(default `false`). When enabled, `MalformedInputException` during filtering
causes a `WARN` log and a direct `Files.copy()` fallback instead of a build
failure.
- **Opt-in** (default `false`) — encoding errors are not silently swallowed
by default
- **Always warns** — the user is told filtering was skipped and what to do
- Falls back to **direct `Files.copy()`**, not a recursive method call
This flag is propagated through `MavenResourcesExecution.copyOf()`.
## Tests
- `DefaultMavenResourcesFilteringTest`: 4 new unit tests for
`matchesNonFilteredGlob()` (null/empty, extension glob, directory glob, exact
name)
- `DefaultMavenResourcesFilteringTest`: 2 integration tests using a mixed
binary+properties resource directory — one for the glob mechanism, one for
graceful fallback
- Binary test fixtures added under `src/test/units-files/binary-file/`
## See also
- Fixes #394
- PR #303 (closed in favour of this approach)
- Companion PR in maven-resources-plugin to expose `<nonFilteredFiles>` and
`<gracefulBinaryHandling>` as plugin config
--
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]