GeezerVison is showing github.com — [MNG-6979] Initialize the current project from the execution root by goutamadwant · Pull Request #13103 · apache/maven
Conversation
Fixes #8057.
Initialize the current project from the selected execution root instead of the first reactor-sorted project. Retain the first-project fallback when the execution root is not selected. Reactor order, per-module current-project overrides, null clearing, and clone behavior are unchanged.
The original reproducer logs parent instead of child1 with this fix. Regression tests cover lifecycle-participant selection, filtered and empty reactors, thread-local state, and cloned sessions.
Validation with JDK 21: the regression tests failed before the fix and passed afterward; mvn -B -ntp verify and the full mvn -B -ntp -Prun-its -Dits.forkCount=2 verify passed.
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 Core IT successfully.
If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Use the selected execution root as the initial current project, retaining the first selected project as fallback when the root is absent. This keeps lifecycle participants independent of reactor dependency ordering.
Add regression coverage for lifecycle project selection, empty and filtered reactors, thread-local state, and cloned sessions.
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.
Clean, correct fix for MNG-6979. The root cause was that setProjects() initialized currentProject to projects.get(0) (first in reactor order) instead of the execution root. In a multi-module build where the root depends on a child, reactor sorting puts the dependency first — so getCurrentProject() returned the wrong project.
The fix correctly unifies currentProject initial value and topLevelProject to both point to the execution root (with fallback to projects.get(0) when the root is filtered out by -pl). The clone() semantics, thread-local isolation, and setCurrentProject() override behavior are all preserved.
Test coverage is thorough: unit tests for reactor ordering, filtered reactors, thread-local isolation, clone behavior, and setProjects reset — plus an integration test with a lifecycle participant that reproduces the original bug report.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
gnodet
added a commit
that referenced
this pull request
Sep 15, 2026
…3103) (#13143)
Use the selected execution root as the initial current project, retaining the first selected project as fallback when the root is absent. This keeps lifecycle participants independent of reactor dependency ordering.
Add regression coverage for lifecycle project selection, empty and filtered reactors, thread-local state, and cloned sessions.
Co-authored-by: Goutam Adwant <[email protected]>
Reviewers
1 more reviewer
Reviewers whose approvals may not affect merge requirements
Uh oh!
There was an error while loading. Please reload this page.
Labels
bug
Something isn't working
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.
|