[ 
https://issues.apache.org/jira/browse/MNG-5971?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15150725#comment-15150725
 ] 

Stephane Nicoll edited comment on MNG-5971 at 2/17/16 4:43 PM:
---------------------------------------------------------------

Okay let me try to clarify. I don't think I am asking for anything funky. I 
want that anything that is defined closers "wins" _regardless of how it is 
added_. 

Think it this way (with a A -> B -> C hierarchy where C is the  child and A the 
grand-parent). A resolves its dependency management (including the ones from 
BOM). That gives a unified dependency management. Then B applies and does the 
same thing, adding or overriding some entries if necessary. Then C does. To me 
it's much more consistent to do things that way because you need that whatever 
you define at a given level will override the values from the parent if 
necessary.

{quote}
Imports never overwrite anything already present in the model.
{quote}

This very issue is about the fact that adding the dependency directly works, 
adding a bom that defines said dependency doesn't. IMO this is inconsistent 
considering how we're using BOM (= share a dependency management section).

Answering to your question. Of course I don't want that. I just want that 
whatever is defined in the user project overrides what the parent provides. So 
let's say that the parent provides {{com.foo:bar:1.0.0}}. If the user adds 
{{com.foo:bar:2.0.0}} then all is well. If the user adds a bom that contains a 
dependency management for {{com.foo.bar:2.0.0}} it doesn't. That's the problem 
I am trying to raise here.

In my mind there is no conflict: I am using the tools Maven provides to have a 
decent dependency management. The only mechanism I know to share dependency 
management is the BOM. Is there another one? (Changing the parent is not an 
option). I don't think so. If we can't use that mechanism to override versions 
(while we can by adding the dependency directly), it looks like something is 
missing in Maven.

I am ok with whatever alternatives Maven offers that would allow me to share 
the dependency management. I just don't think there is one.





was (Author: snicoll):
Okay let me try to clarify. I don't think I am asking for anything funky. I 
want that anything that is defined closers "wins" _regardless of how it is 
added_. 

Think it this way (with a A -> B -> C hierarchy where C is the  child and A the 
grand-parent). A resolves its dependency management (including the ones from 
BOM). That gives a unified dependency management. Then B applies and does the 
same thing, adding or overriding some entries if necessary. Then C does. To me 
it's much more consistent to do things that way because you need that whatever 
you define at a given level will override the values from the parent if 
necessary.

{quote}
Imports never overwrite anything already present in the model.
{quote}

This very issue is about the fact that adding the dependency directly works, 
adding a bom that defines said dependency doesn't. IMO this is inconsistent 
considering how we're using BOM (= share a dependency management section).

Answering to your question. Of course I don't want that. I just want that 
whatever is defined in the user project overrides what the parent provides. So 
let's say that the parent provides {{com.foo:bar:1.0.0}}. If the user adds 
{{com.foo:bar:2.0.0}} then all is well. If the user adds a bom that contains a 
dependency management for {{com.foo.bar:2.0.0}} it doesn't. That's the problem 
I am trying to raise here.

In my mind there is no conflict: I am using the tools Maven provides to have a 
decent dependency management. The only mechanism I know to share dependency 
management is the BOM. Is there another one? I don't think so. If we can't use 
that mechanism to override versions (while we can by adding the dependency 
directly), it looks like something is missing in Maven.

I am ok with whatever alternatives Maven offers that would allow me to share 
the dependency management. I just don't think there is one.




> Dependency management in a child project cannot override a version using a BOM
> ------------------------------------------------------------------------------
>
>                 Key: MNG-5971
>                 URL: https://issues.apache.org/jira/browse/MNG-5971
>             Project: Maven
>          Issue Type: Wish
>          Components: Dependencies
>    Affects Versions: 3.3.3
>            Reporter: Stephane Nicoll
>            Priority: Trivial
>              Labels: close-pending
>
> When a project extends from a parent with a {{dependencyManagement}} section, 
> it is not always possible to properly override (and align) the version to use 
> for a group of dependencies.
> We typically use Bill Of Materials to gather a group of modules and make sure 
> their versions are consistent. 
> The following project demonstrates the issue: 
> https://github.com/snicoll-scratches/maven-dependency-management
> The first commit is a working use case where the parent uses a bom with 
> version A and we use the same bom with version B in the child. Version B is 
> used as expected.
> The second commit demonstrates the faulty scenario. Rather than using a bom 
> in the parent, we use a direct dependency (provided by that bom). We still 
> use the bom with a different version. In that case all the dependencies but 
> the one provided by the parent are overridden (leading to mixed versions for 
> the dependencies provided by the BOM).
> It looks like the distance is still used to compute the version while the 
> graph of dependencies should be flatten at each step for a proper override. 
> Thoughts? Thanks!



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to