GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Restore "first <resource> entry wins" for overlapping resource declarations by rzo1 · Pull Request #334 · apache/maven-filtering

Conversation

@rzo1

@rzo1 rzo1 commented May 5, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Fixes #333. Downstream report: apache/maven-resources-plugin#471.

Problem

When two <resource> entries cover the same source directory — one with
filtering=true plus a narrow <include>, the other with filtering=false
plus <include>**</include>, the placeholder in the file selected by the
filtered entry is no longer replaced. The literal ${...} text remains.

Bisect lands the regression on 1371dcf (MSHARED-1216, "Use a caching output stream when filtering resources"). That commit removed the boolean overwrite parameter from
FilteringUtils.copyFile and the timestamp-based "don't clobber a fresher
destination" gate that came with it. Every write now goes through
CachingOutputStream / CachingWriter unconditionally if the bytes
differ, so an unfiltered second <resource> entry overwrites the
filtered first entry's output.

3.3.1 produced the "first entry wins" semantic as a side effect of that
gate; 3.3.2+ silently lost it. Pinning maven-resources-plugin to 3.3.1
is the current downstream workaround.

Change

DefaultMavenResourcesFiltering now tracks destination paths already
written within a single filterResources(...) call and skips subsequent
writes that would land on the same path. Explicit opt-in
(MavenResourcesExecution.setOverwrite(true), i.e.
ChangeDetection.ALWAYS) keeps the previous "second entry clobbers"
behaviour for callers that relied on it. The existing flatten-collision
policy is intentionally left untouched, a duplicate flattened name still
hits the warn-or-throw path, since that case is conceptually different.

No public API surface changes.


Following this checklist to help us incorporate your contribution
quickly and easily:

  • Your pull request should address just one issue, without pulling in other changes.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body. Note that commits might be squashed by a maintainer on merge.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible but is a best-practice.
  • Run mvn verify to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
  • You have run the integration tests successfully (mvn -Prun-its verify). N/A - this repo defines no run-its profile.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mawiesne reacted with thumbs up emoji mawiesne and peter-c-larsson reacted with heart emoji cstamas reacted with eyes emoji
All reactions
  • 👍 1 reaction
  • ❤️ 2 reactions
  • 👀 1 reaction
rzo1 added 2 commits May 5, 2026 11:17
@rzo1
Add regression test for filtering with overlapping <resource> entries
8055b3d
When a directory is covered by two <resource> entries — 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 was introduced between maven-filtering
3.3.1 and 3.3.2 and surfaced downstream as
apache/maven-resources-plugin#471.

The new test calls MavenResourcesFiltering directly (no plugin invoker), so
the failure can be reproduced and bisected within this repository. It also
asserts that files matched only by the unfiltered <resource> entry still
keep their literal placeholders, so a fix cannot trivially "filter
everything".
@rzo1
Restore "first <resource> entry wins" for overlapping declarations
499f880
When two <resource> entries cover the same source directory, the file
written by the first entry must not be silently replaced by the second.
3.3.1 produced this behaviour as a side effect of the timestamp-based
overwrite gate in FilteringUtils.copyFile, which MSHARED-1216 (commit
1371dcf, "Use a caching output stream when filtering resources") removed
when it switched to CachingOutputStream / CachingWriter — every write
now goes through unconditionally if the bytes differ, so an unfiltered
second entry clobbers the filtered first entry.

DefaultMavenResourcesFiltering now tracks destination paths already
written within a single filterResources(...) call and skips subsequent
writes that would land on the same path. Explicit opt-in
(MavenResourcesExecution.setOverwrite(true), i.e. ChangeDetection.ALWAYS)
keeps the previous "second entry clobbers" behaviour for callers that
relied on it. The existing flatten-collision policy is left untouched —
a duplicate flattened name still triggers the warn-or-throw path, since
that case is conceptually distinct.

Adds a unit test in DefaultMavenResourcesFilteringTest covering the
explicit-overwrite escape hatch. The OverlappingResourcesFilteringTest
introduced in the previous commit now passes against this code.
@cstamas cstamas added the bug Something isn't working label May 7, 2026
@cstamas cstamas added this to the 3.5.1 milestone May 7, 2026
cstamas
cstamas approved these changes May 7, 2026
View reviewed changes
@cstamas
cstamas requested a review from slawekjaranowski May 7, 2026 15:37
slawekjaranowski
slawekjaranowski approved these changes May 7, 2026
View reviewed changes
slachiewicz
slachiewicz approved these changes May 10, 2026
View reviewed changes
@slachiewicz
slachiewicz merged commit 6d84663 into apache:maven-filtering-3.x May 10, 2026
17 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot assigned slachiewicz May 10, 2026
@gnodet gnodet mentioned this pull request Sep 23, 2026
Filtering changed behaviour from 3.3.1 apache/maven-resources-plugin#471
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@cstamas cstamas cstamas approved these changes
@slawekjaranowski slawekjaranowski slawekjaranowski approved these changes
@slachiewicz slachiewicz slachiewicz approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@slachiewicz slachiewicz

Labels

bug Something isn't working

Projects

None yet

Milestone

3.5.1

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@rzo1 @cstamas @slawekjaranowski @slachiewicz
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.