Skip to content

[maven-4.0.x] fix: propagate addResource() to model Build for Maven 3 compat#12093

Merged
gnodet merged 3 commits into
maven-4.0.xfrom
backport-11868-to-4.0.x
May 19, 2026
Merged

[maven-4.0.x] fix: propagate addResource() to model Build for Maven 3 compat#12093
gnodet merged 3 commits into
maven-4.0.xfrom
backport-11868-to-4.0.x

Conversation

@gnodet
Copy link
Copy Markdown
Contributor

@gnodet gnodet commented May 19, 2026

Backport of #11868 to maven-4.0.x.

Propagate addResource() / addTestResource() calls on the model Build object to the underlying Sources set for Maven 3 compatibility. Also ensures Build.resources is properly synced from the Sources set for <sources> projects.

Claude Code on behalf of Guillaume Nodet

gnodet and others added 3 commits May 19, 2026 12:01
When a Maven 3 plugin dynamically adds a resource via
project.addResource() or project.getResources().add(), the resource
was only added to the internal sources set but not to the model's
Build.resources. This caused project.getBuild().getResources() to be
out of sync with project.getResources(), breaking plugins like
maven-source-plugin that access resources through the Build model.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Also sync the model's Build.resources after project building so that
project.getBuild().getResources() is consistent with
project.getResources() even when resources are defined via <sources>
(Maven 4.1.0 model) rather than legacy <resources>.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Avoid syncing Build.resources for legacy projects to prevent
Path.toString() from converting forward slashes to backslashes
on Windows (fixes PomConstructionTest.testTargetPathResourceRegression).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet added this to the 4.0.0-rc-6 milestone May 19, 2026
@gnodet gnodet merged commit 904bb60 into maven-4.0.x May 19, 2026
24 checks passed
@gnodet gnodet deleted the backport-11868-to-4.0.x branch May 19, 2026 13:33
@github-actions
Copy link
Copy Markdown

@gnodet Please assign appropriate label to PR according to the type of change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants