Skip to content

Fix #13883: Do not shadow a custom rootDirectory property - #13885

Merged
slawekjaranowski merged 1 commit into
apache:maven-3.10.xfrom
slawekjaranowski:issue-13883-root-directory-3.10.x
Nov 7, 2026
Merged

slawekjaranowski merged 1 commit into
apache:maven-3.10.xfrom
slawekjaranowski:issue-13883-root-directory-3.10.x

Conversation

@slawekjaranowski

Copy link
Copy Markdown
Member

Fixes #13883

Maven 3.10.0 accepted an unprefixed ${rootDirectory} as an alias for ${project.rootDirectory}.
Since this value source is evaluated before the model properties, it shadowed a custom
rootDirectory property defined in the POM, e.g.:

<properties>
  <rootDirectory>${project.basedir}</rootDirectory>
</properties>

In a multi-module build, ${rootDirectory} then resolved to the project root directory instead of
the module basedir (as it did in Maven 3.9.x), breaking builds such as assertj/assertj-generator#339.

Change

AbstractStringBasedModelInterpolator: the rootDirectory value source now accepts only the prefixed
${project.rootDirectory} (and ${pom.rootDirectory}), as ${project.baseUri} does.
The unprefixed form was never documented, and file-based profile activation already supports
the prefixed form only.

Maven 4 is not affected; regression tests for it were added in #13884.

Tests

  • AbstractModelInterpolatorTest (run by StringSearchModelInterpolatorTest and StringVisitorModelInterpolatorTest):
    • testRootDirectory: ${project.rootDirectory} resolves to the root directory from a module
    • testCustomRootDirectoryPropertyIsNotShadowed: a custom ${rootDirectory} property resolves
      to its own value (fails without the fix)
    • testUnprefixedRootDirectoryIsNotInterpolated: ${rootDirectory} is not an alias
      (fails without the fix)
  • FileProfileActivatorTest: the same two cases for file-based profile activation
    (already working, guarded against regressions)

Documentation

maven-model-builder/src/site/markdown/index.md: file-based profile activation supports
${project.rootDirectory} since Maven 3.10.0.

🤖 Generated with Claude Code

Maven 3.10.0 accepted an unprefixed ${rootDirectory} as an alias for
${project.rootDirectory}. As this value source is evaluated before the model
properties, it shadowed a custom rootDirectory property defined in the POM,
e.g. <rootDirectory>${project.basedir}</rootDirectory>, which then resolved
to the project root directory instead of the module basedir.

Only accept the prefixed ${project.rootDirectory} (and ${pom.rootDirectory}),
as for ${project.baseUri}. The unprefixed form was never documented, and
profile activation already supports the prefixed form only.

Add tests for model interpolation and file-based profile activation, and
document ${project.rootDirectory} for profile activation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@slawekjaranowski slawekjaranowski self-assigned this Nov 7, 2026
@slawekjaranowski slawekjaranowski added the bug Something isn't working label Nov 7, 2026
@slawekjaranowski slawekjaranowski linked an issue Nov 7, 2026 that may be closed by this pull request

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Minimal, correct fix — allowUnprefixedExpressions: false on the rootDirectory value source correctly stops ${rootDirectory} from shadowing user-defined POM properties. The documentation update and regression tests are consistent and thorough.

Pre-fix validation: testCustomRootDirectoryPropertyIsNotShadowed and testUnprefixedRootDirectoryIsNotInterpolated confirmed failing before the fix on both StringSearchModelInterpolatorTest and StringVisitorModelInterpolatorTest, passing after. ✅

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@slawekjaranowski
slawekjaranowski merged commit b40b50e into apache:maven-3.10.x Nov 7, 2026
15 checks passed
@github-actions github-actions Bot added this to the 3.10.1 milestone Nov 7, 2026
@slawekjaranowski
slawekjaranowski deleted the issue-13883-root-directory-3.10.x branch November 7, 2026 20:47
cstamas pushed a commit that referenced this pull request Nov 9, 2026
Follow-up to #13885, related to #13883. Targets `maven-3.10.x`.

The original shadowing fix is already merged. A custom `rootDirectory` that refers to `${project.rootDirectory}` or `${pom.rootDirectory}` can still fail interpolation because the recursion detector treats the custom property and the built-in expression as the same key.

Track bare `rootDirectory` separately and retain prefix-aware cycle detection for the other expressions. Tests cover model, user and system aliases, early model consumers, genuine cycles and tracker reset in both interpolators.

### Validation

- New regressions fail on unchanged current `maven-3.10.x`.
- `mvn -B -ntp verify`: 1,154 tests reported, 8 skipped, zero failures or errors.
- Four focused Core IT cases pass with the fix; the explicit-root alias case fails on the current upstream distribution. [Companion integration tests](https://github.com/goutamadwant/maven/tree/29cb5e6764418ce6f46734e5cbb7ac57e6191b72/its/core-it-suite/src/test/resources/gh-13883-custom-root-directory).
- Full Core IT suite and hosted CI have not been run.

Following this checklist to help us incorporate your
contribution quickly and easily:

- [x] Your pull request should address just one issue, without pulling in other changes.
- [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
- [x] 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.
- [x] 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.
- [x] 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][core-its] successfully.

If your pull request is about ~20 lines of code you don't need to sign an
[Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) 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](http://www.apache.org/licenses/LICENSE-2.0)
you have to acknowledge this by using the following check-box.

- [x] I hereby declare this contribution to be licensed under the [Apache License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
- [ ] I hereby declare that I have filed an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Maven 3.10.0 shadows custom rootDirectory property

3 participants