[4.0.x] [GH-11772] Fail-fast consumer POM validation for non-4.0.0 model versions#12236
Conversation
…l versions (apache#11780) * [apacheGH-11772] Fail-fast consumer POM validation for non-4.0.0 model versions When a POM-packaged project (parent POM) uses Maven 4.1.0 features like profile conditions that cannot be stripped during consumer POM transformation, the build now fails fast with actionable guidance instead of silently deploying a consumer POM that Maven 3 and Gradle cannot resolve. The validation applies only to: - POM-packaged projects (parent POMs) on the non-flatten path - Projects without preserve.model.version=true Also adds a maven.consumer.pom.removeUnusedManagedDependencies property (default: true) to control whether unused managed dependencies are removed during consumer POM flattening. * Refactor consumer POM validation error message to use text blocks Convert string concatenation in the consumer POM model version validation error message to use Java text blocks for improved readability and maintainability. The multi-line error message is now expressed as a text block with .formatted() for parameter substitution. This change affects the validation that ensures POM-packaged projects can be downgraded to model version 4.0.0 for Maven 3/Gradle compatibility. * Fix Spotless formatting violation Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Code <claude@anthropic.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
|
@gnodet Please assign appropriate label to PR according to the type of change. |
|
Real-world adopter feedback — tested apache/plc4x against a current 4.0.x SNAPSHOT (pre-RC-6). Posting here since this backport first ships with RC-6. The fail-fast works as designed: PLC4X's parent POM (model 4.1.0, using
With the flatten property in Three observations that may be worth acting on before RC-6:
Happy to re-run this against RC-6 staging when it's cut. |
Cherry-pick of #11780
Adaptation for 4.0.x:
deployBuildPom()method (constant not yet on 4.0.x)MavenExceptionimportsuper("[4.0.0-rc-1,)")constructor to IT test