Skip to content

[MNG-11133] Fix mixin property precedence - mixins should override parent properties#11141

Open
gnodet wants to merge 1 commit into
apache:masterfrom
gnodet:fix-mng-11133-mixin-precedence
Open

[MNG-11133] Fix mixin property precedence - mixins should override parent properties#11141
gnodet wants to merge 1 commit into
apache:masterfrom
gnodet:fix-mng-11133-mixin-precedence

Conversation

@gnodet
Copy link
Copy Markdown
Contributor

@gnodet gnodet commented Sep 17, 2025

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:

  • Parent defines maven.compiler.release=11
  • Mixin defines maven.compiler.release=21
  • Expected: effective property should be 21 (mixin wins)
  • Actual: effective property was 11 (parent wins)

Solution

  • 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

Changes

Core Changes

  1. DefaultInheritanceAssembler.java: Added package-private overload with sourceDominant parameter
  2. DefaultModelBuilder.java: Use sourceDominant=true when applying mixins in two places:
    • Main mixin application (line ~1195)
    • Mixin application to parent models when building subprojects (line ~1633)

Test Changes

  1. MavenITmng11133MixinsPrecedenceTest.java: New integration test that:
    • Creates a parent with maven.compiler.release=11
    • Creates a mixin with maven.compiler.release=21
    • Creates a project using both parent and mixin
    • Asserts that the effective property is 21 (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

@gnodet gnodet added this to the 4.1.0 milestone Sep 23, 2025
@gnodet gnodet force-pushed the fix-mng-11133-mixin-precedence branch from 6cad66a to 8082092 Compare October 9, 2025 06:58
@gnodet gnodet force-pushed the fix-mng-11133-mixin-precedence branch from 8082092 to 0cc534c Compare June 1, 2026 06:20
…rent properties

Ensures that properties defined in mixins take precedence over properties
inherited from parent POMs. The fix maintains correct consumer POM generation
while properly resolving the mixin property precedence order.
@gnodet gnodet force-pushed the fix-mng-11133-mixin-precedence branch from 49ab6cf to d7968fe Compare June 1, 2026 11:10
@gnodet gnodet marked this pull request as ready for review June 1, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mixins - Property Handling / Precendence

1 participant