gnodet opened a new pull request, #11347: URL: https://github.com/apache/maven/pull/11347
## Summary This PR introduces a new feature flag `maven.consumer.pom.flatten` that allows users to control whether consumer POMs are flattened or preserve their dependency management sections. ## Changes ### Core Implementation - **Constants.java**: Added `MAVEN_CONSUMER_POM_FLATTEN` constant with default value `true` - **Features.java**: Added `consumerPomFlatten()` method to check the feature flag - **DefaultConsumerPomBuilder**: Modified `buildNonPom()` to conditionally apply flattening based on the flag ### Integration Test - **MavenITgh11346DependencyManagementOverrideTest**: New integration test demonstrating the use case - **Test resources**: Multi-module test project in `gh-11346-dependency-management-override/` - **Test scenarios**: Covers both flattening enabled/disabled and dependency manager transitivity ## Use Case The feature addresses scenarios where transitive dependency management inheritance is crucial: - **Module A 1.0**: depends on B 1.0 and manages C to version 1.2 - **Module B 2.0**: depends on C 1.1 - **Module D**: depends on A 1.0 and manages B to version 2.0 **Expected behavior**: When `maven.consumer.pom.flatten=false`, Module D should get C 1.2 (from A's dependency management) instead of C 1.1 (from B 2.0's direct dependency). ## Backward Compatibility - **Default behavior unchanged**: Consumer POM flattening remains enabled by default - **Opt-in control**: Users can disable flattening with `-Dmaven.consumer.pom.flatten=false` - **No breaking changes**: Existing builds continue to work as before ## Testing - ✅ Integration test passes with both flag values - ✅ Verifies correct dependency resolution in complex scenarios - ✅ Confirms dependency management inheritance works when flattening is disabled - ✅ Alternative approach with `-Dmaven.resolver.dependencyManagerTransitivity=false` also tested ## Benefits 1. **Dependency Management Inheritance**: Enables proper transitive dependency management scenarios 2. **Flexibility**: Allows projects to choose appropriate consumer POM strategy 3. **Library Support**: Valuable for library authors who need dependency management inherited by consumers 4. **Complex Projects**: Supports multi-module projects requiring consistent dependency versions Fixes #11346 --- Pull Request opened by [Augment Code](https://www.augmentcode.com/) with guidance from the PR author -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
