-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Add validation for mixins in consumer POM without flattening (fixes #11456) #11463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…attening
Maven now fails with a clear error message when a POM contains mixins
but consumer POM flattening is disabled. Mixins require model version 4.2.0
and cannot be part of the consumer POM, so they must be removed during
transformation through flattening.
Changes:
- Added validation in DefaultConsumerPomBuilder to check for mixins when
flattening is disabled and throw MavenException with helpful message
- Added integration test MavenITgh11456MixinsConsumerPomTest with two scenarios:
1. testMixinsWithoutFlattening: Verifies build fails with proper error message
2. testMixinsWithFlattening: Verifies build succeeds and mixins are removed
from consumer POM when flattening is enabled
- Created test resources with POMs using mixins and local repository
The error message guides users to either enable flattening by setting
maven.consumer.pom.flatten=true or remove mixins from their POM.
Fixes apache#11456
40f09e3 to
d566cc1
Compare
9318f82 to
2639425
Compare
cstamas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: I keep coming back to this, but we may tie these features to "maven level" (model version?) instead to have these freely (and independent) flags for ON/OFF them?
This is purely bulld time, as it's used when unit testing Maven 4 plugins. The flag has been added to avoid having to escape XML-reserved chars in some cases ( |
Sorry, I mixed the PRs. |
In any case, this can be done in a follow-up PR. The point is that mixins require flattening so that they can be translated into 4.0.0 model. |
|
FTR, I've slightly modified the check to take into account the |
Description
This PR adds validation to prevent creating consumer POMs when mixins are present without flattening enabled.
Changes
DefaultConsumerPomBuilder: Checks for mixins when flattening is disabled and throwsMavenExceptionwith a helpful error messageMavenITgh11456MixinsConsumerPomTestwith two scenarios:testMixinsWithoutFlattening: Verifies build fails with proper error messagetestMixinsWithFlattening: Verifies build succeeds and mixins are removed from consumer POM when flattening is enabledtestMixinsWithPreserveModelerVersion: Verifies that mixins are kept when preserving the modelVersion in the consumer POM.Problem
Mixins require model version 4.2.0 and cannot be part of the consumer POM. When consumer POM flattening is disabled (
maven.consumer.pom.flatten=false), mixins would remain in the consumer POM, which is invalid.Solution
Maven now fails early with a clear error message that guides users to either:
maven.consumer.pom.flatten=true, orpreserve.model.version=trueflag on the POM, orTesting
mvn clean install -DskipTestsmvn spotless:checkFixes #11456
Pull Request opened by Augment Code with guidance from the PR author