Skip to content

[maven-4.0.x] Fix BOM packaging in consumer POMs (#11427)#11464

Merged
gnodet merged 2 commits intoapache:maven-4.0.xfrom
gnodet:backport/maven-4.0.x/pr-11427
Nov 18, 2025
Merged

[maven-4.0.x] Fix BOM packaging in consumer POMs (#11427)#11464
gnodet merged 2 commits intoapache:maven-4.0.xfrom
gnodet:backport/maven-4.0.x/pr-11427

Conversation

@gnodet
Copy link
Contributor

@gnodet gnodet commented Nov 18, 2025

Backport

This will backport the following commits from master to maven-4.0.x:

Questions ?

Please refer to the Backport tool documentation

This commit addresses two issues with BOM (Bill of Materials) handling in consumer POMs:

1. BOM packaging not transformed to POM in consumer POMs:
   When a project uses packaging=bom, the consumer POM was incorrectly
   retaining this packaging type. Since 'bom' is not a valid packaging
   type in Maven 4.0.0 model, this caused errors when the consumer POM
   was used. The fix ensures that BOM packaging is always transformed
   to 'pom' in consumer POMs, regardless of whether flattening is enabled.

2. Dependency versions preserved in dependencyManagement:
   The effective model already contains resolved versions for dependencies
   in dependencyManagement sections. The fix ensures these versions are
   properly preserved in the consumer POM for both flattened and
   non-flattened BOMs.

Changes:
- Modified DefaultConsumerPomBuilder.build() to detect BOMs based on
  original packaging and handle them appropriately
- Added buildBomWithoutFlatten() method to handle BOMs when flattening
  is disabled, using the raw model but still transforming packaging
- Added integration test to verify both issues are fixed

Fixes issues reported in:
https://lists.apache.org/thread/41q40v598pd8mr32lmgwdfb2xm7lzm6l

(cherry picked from commit 7d6fd87)
@gnodet gnodet added bug Something isn't working backport mvn40 labels Nov 18, 2025
@gnodet gnodet merged commit ba5c9a4 into apache:maven-4.0.x Nov 18, 2025
22 checks passed
@github-actions github-actions bot added this to the 4.0.0 milestone Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport bug Something isn't working mvn40

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant