[MNG-8432] Inherit properties from imported BOMs#12417
Conversation
elharo
left a comment
There was a problem hiding this comment.
I'm not yet convinced this is a feature we want. It could have unforeseen consequences. care is warranted.
|
@elharo Thank you for the review. That is a very fair point, and I completely understand the hesitation. Changing the semantics of BOM imports to include To provide some context on the motivation: this was implemented to address MNG-8432 / #10196. It's a frequent pain point for users (as seen in this StackOverflow thread with 10k+ views). Currently, if a project imports a BOM to manage dependency versions, but needs to use one of those versions for a plugin configuration (like To mitigate the "unforeseen consequences", I've implemented a safeguard in this PR:
However, I understand there are still risks (e.g., conflicting properties if multiple BOMs are imported). How would you prefer to handle this design decision? A few potential options:
I'm happy to take this in whatever direction the core team feels is safest. |
[MNG-8432] Inherit properties from imported BOMs
fixes #10196
Description
This PR resolves MNG-8432 (also referenced as #10196 on GitHub), which adds the capability to inherit properties from imported BOMs.
Previously, when a child project imported a BOM using
<dependencyManagement>with<scope>import</scope>, Maven only extracted and merged the<dependencyManagement>sections. The<properties>block of the BOM was entirely ignored. This limitation forced users to manually duplicate property definitions (e.g., version placeholders) in their consuming POMs to use them in plugins or standard dependencies.Changes in this PR:
DefaultModelBuilder.loadBomModelto fetch and return the complete resolvedModelof the BOM rather than just theDependencyManagementobject.importDependencyManagementto collect the properties from all imported BOM models and merge them into the consuming model. The consuming model's existing properties take precedence, preventing unwanted overrides.importDependencyManagementruns after the initial model interpolation pass (readEffectiveModel), added a second pass ofinterpolateModel(resultModel, request, this)immediately after importing the properties. This correctly substitutes BOM properties into the unresolved placeholders (e.g.,<version>${lib.version}</version>) within the model.Checklist