Skip to content

[backport maven-4.0.x] Fix BOM consumer POM leaving property references unresolved - #12627

Merged
gnodet merged 2 commits into
maven-4.0.xfrom
backport/12625-to-maven-4.0.x
Jul 30, 2026
Merged

[backport maven-4.0.x] Fix BOM consumer POM leaving property references unresolved#12627
gnodet merged 2 commits into
maven-4.0.xfrom
backport/12625-to-maven-4.0.x

Conversation

@gnodet

@gnodet gnodet commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Backport of #12625

Cherry-pick of #12625 onto maven-4.0.x.

Original PR: #12625 - Fix BOM consumer POM leaving property references unresolved
Original author: @gnodet
Target branch: maven-4.0.x

Original description

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.

DefaultConsumerPomBuilder.buildBomWithoutFlatten() used getRawModel() (no interpolation), but then transformBom() strips both the parent and properties sections. The result is a consumer POM with dangling property references that no consumer can resolve.

Fix: Route all BOMs through buildBom() which uses getEffectiveModel() (fully interpolated). Delete the now-dead buildBomWithoutFlatten() method.

🤖 Generated with Claude Code

Route all BOMs through buildBom() which uses getEffectiveModel() (fully
interpolated), instead of buildBomWithoutFlatten() which used
getRawModel(). The latter was incompatible with transformBom() which
strips parent and properties — leaving dangling ${...} references in
the consumer POM. Delete the now-dead buildBomWithoutFlatten() method.

Reported by Karl Heinz Marbaise during the 4.0.0-rc-6 vote.

Closes #12625

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

LGTM

Clean backport of PR #12625 to maven-4.0.x. The diff is byte-for-byte identical to the original, the fix is correct (routing BOMs through getEffectiveModel() to prevent dangling property references after transformBom() strips parent/properties), and the integration tests comprehensively cover the bug scenario.

Details:

  • The backport is a perfect cherry-pick: production code changes and all new test/resource files are identical between #12625 (master) and #12627 (maven-4.0.x).
  • The fix is sound: buildBomWithoutFlatten() used getRawModel() (no interpolation), but transformBom() strips both the parent reference and properties via prune(). Using the un-interpolated model with a parent/properties-stripping transform is fundamentally incompatible. Routing through buildBom() which uses getEffectiveModel() resolves this correctly.
  • The deleted buildBomWithoutFlatten() method has exactly one call site and no other references, so its removal is clean.
  • Test coverage is thorough: three test methods covering default (no-flatten), flatten=true, and project-local-repo consumer POM paths.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of gnodet

The maven-4.0.x branch uses the older IT helper API where
extractResources() returns File, newVerifier() takes String, and
getArtifactPath() returns String. The test also needs a constructor
with a version range. Adapt accordingly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Re-reviewed after new commit — still LGTM

The new commit (cdcca89f) is a straightforward API adaptation of the integration test for the maven-4.0.x branch. The production code change remains identical to #12625.

The test adaptations cover 5 API differences between master and maven-4.0.x:

  1. extractResources() returns File instead of Path
  2. newVerifier() only accepts String
  3. getArtifactPath() returns String instead of Path
  4. Constructor requires version range super("[4.0.0-rc-4,)")
  5. Files.readAllLines replaced with Files.lines() try-with-resources

All adaptations match patterns used by existing tests on the maven-4.0.x branch (e.g., MavenITgh11427BomConsumerPomTest).

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
gnodet merged commit 9e0d9de into maven-4.0.x Jul 30, 2026
23 checks passed
@gnodet
gnodet deleted the backport/12625-to-maven-4.0.x branch July 30, 2026 14:29
@github-actions github-actions Bot added this to the 4.0.0-rc-6 milestone Jul 30, 2026
@github-actions

Copy link
Copy Markdown

@gnodet Please assign appropriate label to PR according to the type of change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant