Repository navigation
Fix #13883: Do not shadow a custom rootDirectory property - #13885
Merged
slawekjaranowski merged 1 commit intoNov 7, 2026
Merged
slawekjaranowski merged 1 commit into
slawekjaranowski merged 1 commit into
Conversation
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>
cstamas
approved these changes
Nov 7, 2026
gnodet-bot
approved these changes
Nov 7, 2026
gnodet-bot
left a comment
Contributor
There was a problem hiding this comment.
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.
6 of 8 tasks
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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
rootDirectoryproperty defined in the POM, e.g.:In a multi-module build,
${rootDirectory}then resolved to the project root directory instead ofthe module basedir (as it did in Maven 3.9.x), breaking builds such as assertj/assertj-generator#339.
Change
AbstractStringBasedModelInterpolator: therootDirectoryvalue 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 byStringSearchModelInterpolatorTestandStringVisitorModelInterpolatorTest):testRootDirectory:${project.rootDirectory}resolves to the root directory from a moduletestCustomRootDirectoryPropertyIsNotShadowed: a custom${rootDirectory}property resolvesto 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