[GH-11772] Fail-fast consumer POM validation for non-4.0.0 model versions#11780
Open
[GH-11772] Fail-fast consumer POM validation for non-4.0.0 model versions#11780
Conversation
...e/src/main/java/org/apache/maven/internal/transformation/impl/DefaultConsumerPomBuilder.java
Outdated
Show resolved
Hide resolved
...e/src/main/java/org/apache/maven/internal/transformation/impl/DefaultConsumerPomBuilder.java
Outdated
Show resolved
Hide resolved
…ions 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.
de91c68 to
8b30eac
Compare
cstamas
approved these changes
Mar 11, 2026
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.
Summary
Fixes #11772
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.
Changes
Consumer POM validation (
DefaultConsumerPomBuilder): After building the consumer POM for a POM-packaged project on the non-flatten path, validates that the computed model version is 4.0.0. If not, throws aMavenExceptionlisting the available options:maven.consumer.pom.flatten=true)preserve.model.version=true)Managed dependency removal flag (
Constants/Features): Addedmaven.consumer.pom.removeUnusedManagedDependenciesproperty (default:true) to control whether unused managed dependencies are removed during consumer POM flattening.Scope
The validation only applies to:
preserve.model.version=trueUse cases
root/subprojectsonly (e.g. JLine)Test plan
testParentWithConditionsFailsConsumerPom— validates fail-fast for profile conditionstestMultiModuleConsumerPreserveModelVersion— validatespreserveModelVersionbypassMavenITgh11772ConsumerPom410Test— verifies consumer POMs are 4.0.0 and build POMs retain 4.1.0 content for a parent+child project using 4.1.0 namespace