Fix BOM packaging in consumer POMs (#11427)

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
5 files changed
tree: 72a7eeeeb85a1cd99c81ed2fb32895f2468c2d0f
  1. .github/
  2. .idea/
  3. .mvn/
  4. apache-maven/
  5. api/
  6. compat/
  7. impl/
  8. its/
  9. src/
  10. .asf.yaml
  11. .git-blame-ignore-revs
  12. .gitattributes
  13. .gitignore
  14. CONTRIBUTING.md
  15. deploySite.sh
  16. doap_Maven.rdf
  17. Jenkinsfile
  18. LICENSE
  19. NOTICE
  20. pom.xml
  21. README.md
README.md

Apache Maven

Apache License, Version 2.0, January 2004 Reproducible Builds

Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.

If you think you have found a bug, please file an issue in the Maven Issue Tracker.

Documentation

More information can be found on Apache Maven Homepage. Questions related to the usage of Maven should be posted on the Maven User List.

Where can I get the latest release?

You can download the release source from our download page.

Contributing

If you are interested in the development of Maven, please consult the documentation first and afterward you are welcome to join the developers mailing list to ask questions or discuss new ideas/features/bugs etc.

Take a look into the contribution guidelines.

License

This code is under the Apache License, Version 2.0, January 2004.

See the NOTICE file for required notices and attributions.

Donations

Do you like Apache Maven? Then donate back to the ASF to support the development.

Quick Build

If you want to bootstrap Maven, you'll need:

  • Java 17+
  • Maven 3.6.3 or later
  • Run Maven, specifying a location into which the completed Maven distro should be installed:
    mvn -DdistributionTargetDir="$HOME/app/maven/apache-maven-4.1.x-SNAPSHOT" clean package