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 — [MNG-6979] Initialize the current project from the execution root by goutamadwant · Pull Request #13103 · apache/maven

Conversation

@goutamadwant

@goutamadwant goutamadwant commented Sep 13, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

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.

  • I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004
  • In any other case, please file an Apache Individual Contributor License Agreement.

Sorry, something went wrong.

Uh oh!

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

All reactions
@goutamadwant
[MNG-6979] Initialize the current project from the execution root
2310bb7
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.
@goutamadwant goutamadwant mentioned this pull request Sep 13, 2026
[MNG-6979] MavenSession.getCurrentProject may return an incorrect project in a multimodule build #8057
Closed
gnodet-bot
gnodet-bot approved these changes Sep 13, 2026
View reviewed changes

@gnodet-bot gnodet-bot 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.

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.

All reactions
@gnodet gnodet added the bug Something isn't working label Sep 15, 2026
@gnodet gnodet added this to the 4.1.0 milestone Sep 15, 2026
@gnodet
gnodet merged commit 4c3a661 into apache:master Sep 15, 2026
20 checks passed

Uh oh!

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

@github-actions github-actions Bot assigned gnodet Sep 15, 2026
@gnodet gnodet added the backport-to-4.0.x label Sep 15, 2026
@gnodet gnodet mentioned this pull request Sep 15, 2026
[MNG-6979] Initialize the current project from the execution root (backport of #13103 to 4.0.x) #13143
Merged
gnodet added a commit that referenced this pull request Sep 15, 2026
@gnodet @goutamadwant
[MNG-6979] Initialize the current project from the execution root (#1…
7f68413
…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]>
@gnodet gnodet removed the backport-to-4.0.x label Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@gnodet-bot gnodet-bot gnodet-bot approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

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

Assignees

@gnodet gnodet

Labels

bug Something isn't working

Projects

None yet

Milestone

4.2.0

Development

Successfully merging this pull request may close these issues.

[MNG-6979] MavenSession.getCurrentProject may return an incorrect project in a multimodule build

Uh oh!

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

3 participants

@goutamadwant @gnodet-bot @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.