Fix BOM consumer POM leaving property references unresolved - #12625
Merged
gnodet merged 1 commit intoJul 30, 2026
Conversation
The BOM consumer POM builder used getRawModel() (no interpolation)
when consumer POM flattening was disabled (the default). Since
transformBom() always strips both the parent and properties sections,
any ${...} property references in dependency versions became
dangling and unresolvable in the published consumer POM.
This affected virtually all real-world BOMs:
- Properties for dependency versions (e.g. ${junit.version})
- ${project.version} references
- CI-friendly ${revision} properties
- Inherited groupId/version (missing entirely in the consumer POM)
The fix removes buildBomWithoutFlatten() and routes all BOMs through
buildBom(), which uses getEffectiveModel() (fully interpolated).
The flatten flag has no semantic effect on BOMs because transformBom()
always produces a self-contained POM regardless.
Reported-by: Karl Heinz Marbaise (during the 4.0.0-rc-6 vote)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gnodet
commented
Jul 30, 2026
gnodet
left a comment
Contributor
Author
There was a problem hiding this comment.
LGTM ✅
Clean, well-motivated bugfix for a real and severe issue (dangling ${...} in BOM consumer POMs) reported during the Maven 4.0.0-rc-6 vote. The two-line code change is correct, the dead-code removal is safe (no subclasses, no other callers), and the new integration test provides thorough coverage of the fix.
Details:
- The root-cause analysis is accurate:
buildBomWithoutFlatten()usedgetRawModel()(uninterpolated), and thentransformBom()stripped parent and properties viaprune(), leaving dangling${...}references. Routing all BOMs throughbuildBom()(which usesgetEffectiveModel()) is the correct fix. - The removed
buildBomWithoutFlatten()method has no subclass overrides and only one call site, so the removal is safe. - The new integration test covers all three relevant paths: default/no-flatten, flatten=true, and project-local-repo consumer POM.
- The existing test did not catch this bug because it only checked packaging and
<dependencyManagement>, not property resolution. The new test fills that gap.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of gnodet
|
@gnodet Please assign appropriate label to PR according to the type of change. |
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.
Summary
Fixes the BOM consumer POM builder leaving
${...}property references unresolved when consumer POM flattening is disabled (the default).Reported by Karl Heinz Marbaise during the 4.0.0-rc-6 vote.
Problem
DefaultConsumerPomBuilder.buildBomWithoutFlatten()usedgetRawModel()(no interpolation), but thentransformBom()strips both the parent and properties sections. The result is a consumer POM with dangling property references that no consumer can resolve.Example — a BOM with
${junit.version}defined in its parent produced this consumer POM:Scope of breakage
This affects virtually all real-world BOMs on the default (no-flatten) code path:
${junit.version})${...}${project.version}in dependency versions${revision}groupId/versionfrom parentRoot cause
The
buildBomWithoutFlatten()method (introduced in #11427) was modeled afterbuildPom()which also usesgetRawModel(). ButtransformPom()preserves the parent reference and properties (so consumers can resolve${...}by reading the parent), whiletransformBom()strips them (BOMs are self-contained). UsinggetRawModel()with a parent-stripping transform is fundamentally incompatible.Fix
buildBom()which usesgetEffectiveModel()(fully interpolated)buildBomWithoutFlatten()methodThe flatten flag has no semantic effect on BOMs because
transformBom()always strips parent and properties to produce a self-contained POM, regardless of the flag. The distinction only matters for regular POM packaging (where no-flatten preserves the parent reference).Before → After
groupIdorg.apache.maven.its.bom-propertyversion1.0.0-SNAPSHOT${junit.version}4.13.2Test plan
MavenITBomConsumerPomPropertyResolutionTestwith 3 test methods:testBomConsumerPomResolvesParentProperties— default (no-flatten) pathtestBomConsumerPomWithFlattenResolvesParentProperties— flatten=true pathtestConsumerPomInProjectLocalRepo— verifies the-consumer.pomartifactMavenITgh11427BomConsumerPomTest(2 tests)MavenITConsumerPomBomFromSettingsRepoTest(1 test)MavenITmng8293BomImportFromReactor(1 test)🤖 Generated with Claude Code