You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Paul Benedict <pb...@apache.org> on 2009/09/29 05:54:03 UTC

Question on transitive dependency resolution

I have a project structure like this:

Parent A
  * Declares managed dependency org.slf4j:slf4j-api:1.5.8
  * Declares managed dependency org.hibernate:hibernate-core:3.3.1.GA
  * Declares managed dependency org.hibernate:hibernate-annotations:3.4.0.GA
Child A
  * Depends on org.hibernate:hibernate-core
  * Depends on org.hibernate:hibernate-annotations

When I run dependency:list for Child A, I see that version
org.slf4j:slf4j-api:1.5.8 is selected. This is expected and correct because:
 1) hibernate-core relies on 1.5.2 (loses)
 2) hibernate-annotations depends on 1.4.2 (loses)
 3) My managed version wins

Now here is my second project:

Parent B
  * Declares managed dependency Child A
  * Declares managed dependency org.hibernate:hibernate-core:3.3.1.GA
  * Declares managed dependency org.hibernate:hibernate-annotations:3.4.0.GA
Child B
  * Depends on Child A
  * Depends on org.hibernate:hibernate-core
  * Depends on org.hibernate:hibernate-annotations

When I run dependency:list for Child B, I see that version
org.slf4j:slf4j-api:1.5.2 is selected.

Why wouldn't the managed dependency from Child A win?

Paul

Re: Question on transitive dependency resolution

Posted by Paul Benedict <pb...@apache.org>.
Jason,

I just had one of those light bulb moments that only happens after hitting
the send button. :-)

Here is what I read at
http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html:

>> *"Dependency mediation* - this determines what version of a dependency
will be used when multiple versions of an artifact are encountered.
Currently, Maven 2.0 only supports using the "nearest definition" which
means that it will use the version of the closest dependency to your project
in the tree of dependencies."

Dependency hibernate-core takes less hops to find slf4j-api than Child A
does.

Paul

On Mon, Sep 28, 2009 at 11:07 PM, Jason van Zyl <ja...@sonatype.com> wrote:

> Make a test project to express the problem. In almost all cases it's
> impossible to debug or discuss this without a test project everyone can run.
>
> Unfortunately you can't rely 100% on the output of particular plugins wrt
> dependency resolution because they can all change the output with different
> input parameters and artifact filters.
>
>
> On 2009-09-28, at 8:54 PM, Paul Benedict wrote:
>
>  I have a project structure like this:
>>
>> Parent A
>>  * Declares managed dependency org.slf4j:slf4j-api:1.5.8
>>  * Declares managed dependency org.hibernate:hibernate-core:3.3.1.GA
>>  * Declares managed dependency org.hibernate:hibernate-annotations:
>> 3.4.0.GA
>> Child A
>>  * Depends on org.hibernate:hibernate-core
>>  * Depends on org.hibernate:hibernate-annotations
>>
>> When I run dependency:list for Child A, I see that version
>> org.slf4j:slf4j-api:1.5.8 is selected. This is expected and correct
>> because:
>> 1) hibernate-core relies on 1.5.2 (loses)
>> 2) hibernate-annotations depends on 1.4.2 (loses)
>> 3) My managed version wins
>>
>> Now here is my second project:
>>
>> Parent B
>>  * Declares managed dependency Child A
>>  * Declares managed dependency org.hibernate:hibernate-core:3.3.1.GA
>>  * Declares managed dependency org.hibernate:hibernate-annotations:
>> 3.4.0.GA
>> Child B
>>  * Depends on Child A
>>  * Depends on org.hibernate:hibernate-core
>>  * Depends on org.hibernate:hibernate-annotations
>>
>> When I run dependency:list for Child B, I see that version
>> org.slf4j:slf4j-api:1.5.2 is selected.
>>
>> Why wouldn't the managed dependency from Child A win?
>>
>> Paul
>>
>
> Thanks,
>
> Jason
>
> ----------------------------------------------------------
> Jason van Zyl
> Founder,  Apache Maven
> http://twitter.com/jvanzyl
> ----------------------------------------------------------
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

Re: Question on transitive dependency resolution

Posted by Jason van Zyl <ja...@sonatype.com>.
Make a test project to express the problem. In almost all cases it's  
impossible to debug or discuss this without a test project everyone  
can run.

Unfortunately you can't rely 100% on the output of particular plugins  
wrt dependency resolution because they can all change the output with  
different input parameters and artifact filters.

On 2009-09-28, at 8:54 PM, Paul Benedict wrote:

> I have a project structure like this:
>
> Parent A
>  * Declares managed dependency org.slf4j:slf4j-api:1.5.8
>  * Declares managed dependency org.hibernate:hibernate-core:3.3.1.GA
>  * Declares managed dependency org.hibernate:hibernate-annotations: 
> 3.4.0.GA
> Child A
>  * Depends on org.hibernate:hibernate-core
>  * Depends on org.hibernate:hibernate-annotations
>
> When I run dependency:list for Child A, I see that version
> org.slf4j:slf4j-api:1.5.8 is selected. This is expected and correct  
> because:
> 1) hibernate-core relies on 1.5.2 (loses)
> 2) hibernate-annotations depends on 1.4.2 (loses)
> 3) My managed version wins
>
> Now here is my second project:
>
> Parent B
>  * Declares managed dependency Child A
>  * Declares managed dependency org.hibernate:hibernate-core:3.3.1.GA
>  * Declares managed dependency org.hibernate:hibernate-annotations: 
> 3.4.0.GA
> Child B
>  * Depends on Child A
>  * Depends on org.hibernate:hibernate-core
>  * Depends on org.hibernate:hibernate-annotations
>
> When I run dependency:list for Child B, I see that version
> org.slf4j:slf4j-api:1.5.2 is selected.
>
> Why wouldn't the managed dependency from Child A win?
>
> Paul

Thanks,

Jason

----------------------------------------------------------
Jason van Zyl
Founder,  Apache Maven
http://twitter.com/jvanzyl
----------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Question on transitive dependency resolution

Posted by Brian Fox <br...@infinity.nu>.
The managing of Child A doesn't necessarily mean that Child A's
dependencies are weighed higher than other direct dependencies. Also,
given the same depth in the tree, the first version processed for a
given group:artifact wins...ie the order in the pom can have subtle
impacts.

On Mon, Sep 28, 2009 at 8:54 PM, Paul Benedict <pb...@apache.org> wrote:
> I have a project structure like this:
>
> Parent A
>  * Declares managed dependency org.slf4j:slf4j-api:1.5.8
>  * Declares managed dependency org.hibernate:hibernate-core:3.3.1.GA
>  * Declares managed dependency org.hibernate:hibernate-annotations:3.4.0.GA
> Child A
>  * Depends on org.hibernate:hibernate-core
>  * Depends on org.hibernate:hibernate-annotations
>
> When I run dependency:list for Child A, I see that version
> org.slf4j:slf4j-api:1.5.8 is selected. This is expected and correct because:
>  1) hibernate-core relies on 1.5.2 (loses)
>  2) hibernate-annotations depends on 1.4.2 (loses)
>  3) My managed version wins
>
> Now here is my second project:
>
> Parent B
>  * Declares managed dependency Child A
>  * Declares managed dependency org.hibernate:hibernate-core:3.3.1.GA
>  * Declares managed dependency org.hibernate:hibernate-annotations:3.4.0.GA
> Child B
>  * Depends on Child A
>  * Depends on org.hibernate:hibernate-core
>  * Depends on org.hibernate:hibernate-annotations
>
> When I run dependency:list for Child B, I see that version
> org.slf4j:slf4j-api:1.5.2 is selected.
>
> Why wouldn't the managed dependency from Child A win?
>
> Paul
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org