[MNG-11133] Fix mixin property precedence - mixins should override parent properties#11141
Draft
gnodet wants to merge 6 commits intoapache:masterfrom
Draft
[MNG-11133] Fix mixin property precedence - mixins should override parent properties#11141gnodet wants to merge 6 commits intoapache:masterfrom
gnodet wants to merge 6 commits intoapache:masterfrom
Conversation
Mixins are applied after parent inheritance, but the merge was using sourceDominant=false, causing the existing model's properties to win over the mixin's properties. This meant that parent properties would override mixin properties, which is incorrect behavior. Changes: - Add package-private overload in DefaultInheritanceAssembler to control source dominance during model inheritance - Use sourceDominant=true when applying mixins so mixin properties override previously inherited ones - Apply the same fix for mixins applied to parent models when building subprojects - Add integration test to reproduce and verify the fix The fix ensures that mixins behave as expected: properties defined in mixins override those inherited from the parent, maintaining the correct precedence order.
The integration test was failing in CI because it depended on maven-it-plugin-expression which is not available in the CI environment. Updated the test to use help:effective-pom instead, which is a standard Maven plugin that's always available. The test still validates that mixin properties override parent properties by checking that maven.compiler.release=21 (from mixin) instead of maven.compiler.release=11 (from parent) in the effective POM.
Applied spotless formatting to MavenITmng11133MixinsPrecedenceTest.java: - Fixed license header indentation - Reordered imports (static imports last) - Removed trailing blank line
Applied manual formatting fixes to XML files: - Consolidated project element attributes to single line - Removed extra blank lines - Fixed trailing whitespace These files are not covered by spotless configuration but need to follow the same formatting standards for CI to pass.
The integration test XML file was missing a newline at the end, causing spotless:check to fail. Added the required newline to make the file compliant with formatting standards.
The test was using verifier.loadFile() which returns List<String> but assigning it to a String variable. Changed to use Files.readString() to read the file content as a String, which matches the expected variable type. This fixes the compilation error: incompatible types: java.lang.String cannot be converted to java.io.File
6cad66a to
8082092
Compare
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 MNG-11133 where mixin properties were not overriding properties inherited from the parent.
Problem
Mixins are applied after parent inheritance, but the merge was using
sourceDominant=false, causing the existing model's properties to win over the mixin's properties. This meant that parent properties would override mixin properties, which is incorrect behavior.For example:
maven.compiler.release=11maven.compiler.release=2121(mixin wins)11(parent wins)Solution
DefaultInheritanceAssemblerto control source dominance during model inheritancesourceDominant=truewhen applying mixins so mixin properties override previously inherited onesChanges
Core Changes
sourceDominantparametersourceDominant=truewhen applying mixins in two places:Test Changes
maven.compiler.release=11maven.compiler.release=2121(mixin wins)Testing
The integration test should fail before the fix and pass after the fix, confirming that the bug is reproduced and resolved.
Backward Compatibility
This change corrects the behavior to match the expected semantics of mixins. While it changes the effective property values in some cases, it aligns with the documented and expected behavior that mixins should override parent properties.
Note: This is a draft PR. The integration test may need the full Maven build to run properly due to dependencies on IT support modules.
Pull Request opened by Augment Code with guidance from the PR author