Fix BOM packaging in consumer POMs by gnodet · Pull Request #11427 · apache/maven (original) (raw)

added a commit to gnodet/maven that referenced this pull request

Nov 10, 2025

@gnodet

…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 with XML format
    • List 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
    • Added proper type declarations for Map, Properties, arrays, and custom beans

All tests pass successfully (22 tests in maven-testing module).

@gnodet

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:

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

gnodet added a commit to gnodet/maven that referenced this pull request

Nov 18, 2025

@gnodet

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:

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

@gnodet

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:

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

@gnodet

…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 with XML format
    • List 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
    • 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

[ Show hidden characters]({{ revealButtonHref }})