gnodet opened a new pull request, #397: URL: https://github.com/apache/maven-filtering/pull/397
## Summary Port of the `ChangeDetection` strategy from the `maven-filtering-3.x` branch (commit [d9bc10a](https://github.com/apache/maven-filtering/commit/d9bc10a)) to the `master` branch (Maven 4 / Path-based API). Instead of jumping between ways to perform change detection — deciding whether an existing target file needs to be overwritten — make it a **configurable strategy**. Before 3.4.0 it was timestamp-based, post 3.4.0 it switched to content-based via `CachingOutputStream`, but in any case users were left with no control. ## Changes ### New `ChangeDetection` enum Five strategies: | Strategy | Behaviour | |---|---| | `TIMESTAMP` | Overwrite only when source is newer (pre-3.4.0 default) | | `CONTENT` | Overwrite only when content differs — via `CachingOutputStream`/`CachingWriter` (**current default**) | | `TIMESTAMP_AND_CONTENT` | Check timestamp first, then content if needed | | `ALWAYS` | Always overwrite (replaces `overwrite=true`) | | `NEVER` | Never overwrite an existing file | ### API changes - **`AbstractMavenFilteringRequest`** — new `changeDetection` field (default `CONTENT`) with getter/setter - **`FilteringUtils`** — new `copyFile(Path, Path, String, FilterWrapper[], ChangeDetection)` overload returning `boolean`; old `boolean overwrite` signature deprecated - **`MavenFileFilter`** — new `copyFile(…, ChangeDetection)` method; old signature deprecated - **`DefaultMavenFileFilter`** — implements new interface method, delegates through `ChangeDetection` - **`DefaultMavenResourcesFiltering`** — uses `getChangeDetection()` from the request instead of `isOverwrite()` - **`MavenResourcesExecution`** — `isOverwrite()` / `setOverwrite()` deprecated, now delegate through `ChangeDetection` ### Implementation details - `CONTENT` / `TIMESTAMP_AND_CONTENT` use `CachingOutputStream` / `CachingWriter` (existing behaviour) - `ALWAYS` / `TIMESTAMP` / `NEVER` bypass caching and write unconditionally via `Files.newOutputStream` / `Files.newBufferedWriter` - TIMESTAMP uses `Files.getLastModifiedTime(path).toMillis()` for Path-based comparison ## Fixes - https://github.com/apache/maven-resources-plugin/issues/453 ## Origin Ported from [maven-filtering-3.x commit d9bc10a](https://github.com/apache/maven-filtering/commit/d9bc10a) by Tamas Cservenak. -- 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]
