I understand that we need to find a solution when there is a conflict between 
different versions of the same artifact. In this case, the nearest-strategy is 
used. But, concerning the scope, why someone would need to override scope of an 
artifact? If I declare that A compile-dep on B, and I also declare that B 
compile-dep on L, that's because B needs L for production. Now, A also uses L 
for unit tests, so I declare that A test-dep on L. Why thinking of overriding 
the scope of L? In this case, we have the same dependency twice (note that the 
two dependencies correspond to the same artifact - same version), on one hand, 
I need L for production, on another hand, I need L for unit tests only, I think 
that there should be a priority between scopes, so we can make a choice. 
Choosing a scope test for L in this example is a bad idea (I think), because 
now I get an error message at runtime or even compilation. And now, I need to 
check all my projects to look if this special case appears and if yes, to use 
one of the previous 'workaround'.

Maybe I'm missing something, maybe there is another issue (maybe more 
important) in the other side.

Mickael

-----Original Message-----
From: Wayne Fay [mailto:[email protected]] 
Sent: Thursday, January 19, 2012 5:38 PM
To: Maven Users List
Subject: Re: Dependency scope precedence?

> What's wrong here? My project A only uses L for unit tests so I define the 
> dependency with
> 'test' scope. But, at the end, I want L to be on my classpath since project A 
> depends on
> project B for production, and B needs (transitively) library L also for 
> production. (By production,

OK so in a nutshell...
A compile-dep B
A test-dep L
B compile-dep L

Because A has a test-dep to L, that overrides the B compile-dep on L
which is brought in to A transitively. You are effectively downgrading
the scope of this library by declaring it locally as a test
dependency.

What kind of package are you building?

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to