You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "gnodet (via GitHub)" <gi...@apache.org> on 2026/03/31 09:42:21 UTC

[PR] fix: propagate addResource() to model Build for Maven 3 compat [maven]

gnodet opened a new pull request, #11868:
URL: https://github.com/apache/maven/pull/11868

   ## Summary
   
   - When a Maven 3 plugin dynamically adds a resource via `project.addResource()` or `project.getResources().add()`, propagate the change to the model's `Build.resources` so that `project.getBuild().getResources()` stays in sync with `project.getResources()`
   - This fixes resource ordering issues when running Maven 3 plugins (e.g. maven-source-plugin 3.x) on Maven 4
   
   ### Root cause
   
   In Maven 3, `project.getResources()` and `project.getBuild().getResources()` return the **same** mutable list. In Maven 4's compatibility layer, they are disconnected: `getResources()` returns a virtual list backed by the internal `sources` set, while `getBuild().getResources()` returns a WrapperList backed by the model.
   
   When `maven-remote-resources-plugin` adds a resource directory, only the `sources` set was updated. The `maven-source-plugin`'s `createArchiver()` method uses `project.getBuild().getResources()` to find the `maven-shared-archive-resources` directory and add META-INF files first in the JAR — but in Maven 4 it couldn't find it, causing the META-INF entries to appear at the end instead of the beginning.
   
   See: https://github.com/apache/maven-source-plugin/pull/281
   
   ## Test plan
   
   - [x] Existing `ResourceIncludeTest` passes (10 tests)
   - [x] Full `maven-core` test suite passes (545 tests)
   - [ ] Verify with maven-source-plugin 3.x reproducible IT on Maven 4
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: propagate addResource() to model Build for Maven 3 compat [maven]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet merged PR #11868:
URL: https://github.com/apache/maven/pull/11868


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: propagate addResource() to model Build for Maven 3 compat [maven]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #11868:
URL: https://github.com/apache/maven/pull/11868#issuecomment-4489025386

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


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: propagate addResource() to model Build for Maven 3 compat [maven]

Posted by "hboutemy (via GitHub)" <gi...@apache.org>.
hboutemy commented on PR #11868:
URL: https://github.com/apache/maven/pull/11868#issuecomment-4274563384

   @gnodet I tested the change on maven-source-plugin 3.x ITs, bot on this master branch and on 4.0.x one: I confirm this fixes the issue
   
   anything else to check before merging?


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org