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 — Add module-aware resource handling for modular sources by desruisseaux · Pull Request #11700 · apache/maven

Conversation

@desruisseaux

@desruisseaux desruisseaux commented Feb 5, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

This is a combination of pull requests #11505, #11632 and #11702 on master branch.

Summary: Maven 4.x introduces a unified <sources> element that supports modular project layouts (src/<module>/<scope>/<lang>). However, resource handling did not follow the modular layout - resources were always loaded from the legacy <resources> element which defaults to src/main/resources. This change implements automatic module-aware resource injection.

  • For modular projects without resource configuration in <sources>, automatically inject resource roots following the modular layout: src/<module>/main/resources and src/<module>/test/resources.
  • Resources configured via <sources> take priority over legacy <resources>.
  • Fail the build (as ModelProblem) when explicit legacy resources are ignored.

Sorry, something went wrong.

Uh oh!

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

All reactions
@desruisseaux desruisseaux added backport-to-4.0.x backport and removed backport-to-4.0.x labels Feb 5, 2026
elharo
elharo reviewed Feb 5, 2026
View reviewed changes

@elharo elharo left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little uncomfortable that large fixes like this are getting submitted without corresponding issues.

Sorry, something went wrong.

Uh oh!

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

All reactions
elharo
elharo requested changes Feb 5, 2026
View reviewed changes
Comment thread impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
.map(pomFile -> build(pomFile, recursive))
.flatMap(List::stream)
.collect(Collectors.toList());
.toList();

@elharo elharo Feb 5, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be a separate small change

Sorry, something went wrong.

Uh oh!

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

All reactions

@desruisseaux desruisseaux Feb 20, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, but this pull request is a verbatim backport of commits done in the master branch. By keeping the changes identical, we reduce the risk of conflicts in future merges.

Sorry, something went wrong.

Uh oh!

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

All reactions

@elharo elharo Feb 20, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you want to do verbatim pulls from master, then it should probably be from one PR in master. Description says "This is a combination of pull requests #11505, #11632 and #11702 on master branch."

Sorry, something went wrong.

Uh oh!

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

All reactions

@desruisseaux desruisseaux Feb 20, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 separated pull requests would be clearer if they were 3 independent tasks. But in this case, each new pull request is amending the previous one, for example adding warnings, then changing warnings into build failures. In this case, I think that squashing the 3 pull requests make them easier to analyse, because reviewers can analyse directly the final result instead of spending times on changes that are made obsolete in the next commit.

Sorry, something went wrong.

Uh oh!

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

ascheman reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@elharo elharo Feb 20, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and my point is that when you're merging all these things together you're not doing a straight backport so it's not necessary to mirror exactly what never really existed on master

Sorry, something went wrong.

Uh oh!

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

All reactions

@desruisseaux desruisseaux Feb 20, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The work is ported in one piece instead of 3 pieces, but the result is identical to that we would have if we squashed the 3 commits on master before to port. The important thing (regarding merge conflicts) is that DefaultProjectBuilder.java (for example) is almost identical on the maven-4.0.x and master branches — the differences between the two branches do not come from this pull requests.

If we do not include the change of .collect(Collectors.toList()) to .toList() in this pull request, it will create a difference between the maven-4.0.x and master branches. In such case, if a change is made on master around those lines, back-porting this change to maven-4.0.x will create a merge conflict.

While separating the tasks is good in principle, in this case it increases the effort both in splitting this pull request and in resolving merge conflicts later (unless this pull request is followed by another pull request doing the changes that we skipped).

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
.filter(cr -> cr != r && cr.getEffectiveModel() != null)
.map(cr -> projectIndex.get(cr.getEffectiveModel().getId()))
.collect(Collectors.toList()));
.toList());

@elharo elharo Feb 5, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto; good but not needed in this PR

Sorry, something went wrong.

Uh oh!

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

ascheman reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java
}
} else {
hasScript |= Language.SCRIPT.equals(language);
var sourceRoot = DefaultSourceRoot.fromModel(session, baseDir, outputDirectory, source);

@elharo elharo Feb 5, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I dislike var. It prioritizes trivial typing speed over code readability

Sorry, something went wrong.

Uh oh!

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

All reactions

@ascheman ascheman Feb 5, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I agree with you, but perhaps its more a question of programming style. var is already used in other places of this codebase, e.g., DefaultModelBuilder.java:

  for (var problem : e.getResult().getProblemCollector()...
  for (var transformer : transformers) {

Sorry, something went wrong.

Uh oh!

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

All reactions

@desruisseaux desruisseaux Feb 7, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that there is a consensus. I tend to use var when it avoids a redundancy on the same line, especially when the redundancy is verbose. For example:

MyFooWithLongName foo = new MyFooWithLongName();

However, when we don't see the type on the same line (as in for (var transformer : transformers)), I agree that it is good to keep the type. I usually try to stick to the rule "use var only if we can see the type on the same line", but I may sometime use var by mistake.

Sorry, something went wrong.

Uh oh!

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

ascheman reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java Resolved

Uh oh!

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

@desruisseaux

desruisseaux commented Feb 5, 2026

Copy link
Copy Markdown
Contributor Author

This pull request is a squashed backport of two pull requests from the mater branch, one merged in December 30th and the second one today. The issue describing the second commit on the master branch is #11612, but a more complete description is on the wiki at the link below:

https://cwiki.apache.org/confluence/display/MAVEN/Build+Sources+Validation+-+Discussion+Notes

All reactions

Sorry, something went wrong.

Uh oh!

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

@elharo

elharo commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

https://cwiki.apache.org/confluence/display/MAVEN/Build+Sources+Validation+-+Discussion+Notes

Useful, but the wiki is not an issue tracker. We seem to be getting in the habit of submitting major PRs without issues. That's an unexpected and IMHO negative side effect of moving to GitHub issues from JIRA.

All reactions

Sorry, something went wrong.

Uh oh!

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

@elharo

elharo commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

#11701

All reactions

Sorry, something went wrong.

Uh oh!

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

@ascheman

ascheman commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

I'm a little uncomfortable that large fixes like this are getting submitted without corresponding issues.

As this is a backport (mostly) of #11612: Would it be OK for you if this were explicitly mentioned?

All reactions

Sorry, something went wrong.

Uh oh!

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

@elharo

elharo commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

I'm a little uncomfortable that large fixes like this are getting submitted without corresponding issues.

As this is a backport (mostly) of #11612: Would it be OK for you if this were explicitly mentioned?

Only if we don't close the bug until the backports are complete. And even then I'm not sure our release tools are set up to handle single issues that touch multiple versions.

ascheman reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

This was referenced Feb 5, 2026
Legacy resources in modular build should fail #11701
Closed
Unified source handling for all lang/scope combinations with modular sources (Phase 2) #11612
Closed
@desruisseaux

desruisseaux commented Feb 13, 2026

Copy link
Copy Markdown
Contributor Author

This pull request is pending completion and merge of #11702.

All reactions

Sorry, something went wrong.

Uh oh!

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

@ascheman @desruisseaux
Add module-aware resource handling for modular sources.
85da731
This is a combination of pull requests apache#11505, apache#11632 and apache#11702 on master branch.

Summary:
Maven 4.x introduces a unified <sources> element that supports modular
project layouts (src/<module>/<scope>/<lang>). However, resource handling
did not follow the modular layout - resources were always loaded from
the legacy <resources> element which defaults to src/main/resources.
This change implements automatic module-aware resource injection.

- For modular projects without resource configuration in <sources>,
  automatically inject resource roots following the modular layout:
  src/<module>/main/resources and src/<module>/test/resources.
- Resources configured via <sources> take priority over legacy <resources>.
- Fail the build (as ModelProblem) when explicit legacy resources are ignored.
@desruisseaux
desruisseaux force-pushed the sources-handling branch from 206a689 to 85da731 Compare February 20, 2026 13:22
@desruisseaux

desruisseaux commented Mar 3, 2026

Copy link
Copy Markdown
Contributor Author

Can we consider this pull request as ready for merge? There are open discussions above, but their resolution would require a deviation from a simple backport of specific commits from the master branch.

All reactions

Sorry, something went wrong.

Uh oh!

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

@ascheman

ascheman commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

Can we consider this pull request as ready for merge? There are open discussions above, but their resolution would require a deviation from a simple backport of specific commits from the master branch.

As a non-committer I seem not to be in a position to formally approve. But I consider this change ready!

All reactions

Sorry, something went wrong.

Uh oh!

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

@desruisseaux
desruisseaux merged commit 3003a40 into apache:maven-4.0.x Mar 8, 2026
60 of 62 checks passed

Uh oh!

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

@github-actions github-actions Bot assigned desruisseaux Mar 8, 2026
@github-actions github-actions Bot added this to the 4.0.0 milestone Mar 8, 2026
@desruisseaux
desruisseaux deleted the sources-handling branch March 8, 2026 21:49
@gnodet gnodet modified the milestones: 4.0.0, 4.0.0-rc-6 Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ascheman ascheman ascheman left review comments
@elharo elharo elharo requested changes

Uh oh!

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

Assignees

@desruisseaux desruisseaux

Labels

backport

Projects

None yet

Milestone

4.0.0-rc-6

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

4 participants

@desruisseaux @elharo @ascheman @gnodet
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.