gnodet opened a new pull request, #400:
URL: https://github.com/apache/maven-filtering/pull/400
## Summary
Maven's `<filters>` configuration only accepts literal file paths. When a
project has many environment-specific property files under a common directory
(e.g. `env/dev/`), users must enumerate each file individually — even when the
set is dynamic or grows over time.
This PR adds **glob pattern support** to filter file paths, allowing
configurations like:
```xml
<filters>
<filter>env/dev/*.properties</filter>
</filters>
```
## Root Cause
`BaseFilter.loadProperties()` passes each filter path directly to
`FilteringUtils.resolveFile()`, which treats it as a literal file system path.
No glob expansion is performed.
## Fix
Added glob detection (`*`, `?`, `{`, `[` characters) and expansion via
`java.nio.file.Files.walk()` + `PathMatcher` in `BaseFilter.loadProperties()`:
- Glob patterns are expanded to matching files, sorted for reproducibility
- Each matched file is loaded in turn (same property inheritance semantics
as explicit paths)
- A glob that matches **no files** emits a `WARN` rather than failing the
build, since the absence of environment-specific files can be intentional
- Literal paths (no glob characters) are unchanged — fully
backward-compatible
## Tests
Three new unit tests in `DefaultMavenFileFilterTest`:
- `globFilterFilesMatchMultipleFiles`: a `**/*.properties` glob loads all
matched files
- `globFilterFilesScopedToSubdirectory`: a directory-scoped glob does not
bleed into sibling directories
- `globFilterFilesNoMatchEmitsWarning`: a non-matching glob emits a warning
and loads nothing
Fixes #254
--
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]