Fix BOM packaging in consumer POMs#11427
Merged
gnodet merged 1 commit intoapache:masterfrom Nov 18, 2025
Merged
Conversation
gnodet
added a commit
to gnodet/maven
that referenced
this pull request
Nov 10, 2025
…ting Fixes apachegh-11427 This commit enhances the @MojoParameter annotation to support injection of complex data types when unit testing mojos, with comprehensive test coverage. Key features: 1. Added xml attribute to @MojoParameter annotation: - xml=true (default): Parse value as XML content (existing behavior) - xml=false: Treat value as plain text, escaping XML special characters - Enables comma-separated lists and values with special characters 2. Updated MojoExtension to handle the xml flag: - When xml=true, value is parsed as XML elements - When xml=false, value is escaped and treated as plain text - Properly handles special characters like <, >, &, etc. 3. Added comprehensive unit tests (15 new tests) covering: - List<String> with XML format - List<String> with comma-separated format using xml=false - String arrays with both XML and comma-separated formats - Map<String, String> with XML format - Properties with XML format - Custom bean objects with nested properties - Primitive types (int, boolean) - Special characters in values with xml=false 4. Fixed plugin.xml type declarations: - Changed from java.lang.List<java.lang.String> (HTML-encoded) - To java.util.List (proper Maven plugin descriptor format) - Maven's plugin descriptor doesn't support parameterized types in <type> - Added proper type declarations for Map, Properties, arrays, and custom beans All tests pass successfully (22 tests in maven-testing module).
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
0f318a7 to
3465bf1
Compare
cstamas
approved these changes
Nov 18, 2025
Contributor
Author
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
gnodet
added a commit
to gnodet/maven
that referenced
this pull request
Nov 18, 2025
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
added a commit
that referenced
this pull request
Nov 18, 2025
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
added a commit
that referenced
this pull request
Nov 26, 2025
…ting (#11426) Fixes gh-11427 This commit enhances the @MojoParameter annotation to support injection of complex data types when unit testing mojos, with comprehensive test coverage. Key features: 1. Added xml attribute to @MojoParameter annotation: - xml=true (default): Parse value as XML content (existing behavior) - xml=false: Treat value as plain text, escaping XML special characters - Enables comma-separated lists and values with special characters 2. Updated MojoExtension to handle the xml flag: - When xml=true, value is parsed as XML elements - When xml=false, value is escaped and treated as plain text - Properly handles special characters like <, >, &, etc. 3. Added comprehensive unit tests (15 new tests) covering: - List<String> with XML format - List<String> with comma-separated format using xml=false - String arrays with both XML and comma-separated formats - Map<String, String> with XML format - Properties with XML format - Custom bean objects with nested properties - Primitive types (int, boolean) - Special characters in values with xml=false 4. Fixed plugin.xml type declarations: - Changed from java.lang.List<java.lang.String> (HTML-encoded) - To java.util.List (proper Maven plugin descriptor format) - Maven's plugin descriptor doesn't support parameterized types in <type> - Added proper type declarations for Map, Properties, arrays, and custom beans
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.
This PR addresses two issues with BOM (Bill of Materials) handling in consumer POMs reported in https://lists.apache.org/thread/41q40v598pd8mr32lmgwdfb2xm7lzm6l:
Issues Fixed
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.2. Dependency versions preserved in dependencyManagement
When using
-Dmaven.consumer.pom.flatten=truewith a BOM, dependencies in dependencyManagement were missing their version tags.Solution
The fix ensures that:
Changes
DefaultConsumerPomBuilder.build()to detect BOMs based on original packaging and handle them appropriatelybuildBomWithoutFlatten()method to handle BOMs when flattening is disabled, using the raw model but still transforming packagingTesting
Manual testing confirms:
packaging=pominstead ofpackaging=bom-Dmaven.consumer.pom.flatten=truework correctlyPull Request opened by Augment Code with guidance from the PR author