You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Guillaume CHAUVET <gu...@qualiformed.com> on 2013/11/05 10:47:57 UTC

Scope question

Hello,

I wondering if it is possible to change the scope of a dependency depending on the position in the tree of dependencies ?
Here is a small example:
An artifact "A" with a dependence on a "z" artifact defined with "compile" scope.
If I use artifact "A" in a project "B", I would like the dependency scope of "z" becomes "runtime", in order to prevent the user to explicitly call classes from artifact "z ".

Do you think it is possible to have this kind of behaviour ?
Thanks in advance,

Guillaume

Re: Scope question

Posted by Jörg Schaible <Jo...@scalaris.com>.
Hi Guillaume,

Guillaume CHAUVET wrote:

> Hello,
> 
> I wondering if it is possible to change the scope of a dependency
> depending on the position in the tree of dependencies ? Here is a small
> example: An artifact "A" with a dependence on a "z" artifact defined with
> "compile" scope. If I use artifact "A" in a project "B", I would like the
> dependency scope of "z" becomes "runtime", in order to prevent the user to
> explicitly call classes from artifact "z ".
> 
> Do you think it is possible to have this kind of behaviour ?

Use a dependencyManagement section to define version and scope of runtime 
for z. If you share the section in a parent for A and B, then you can simply 
redeclare the scope in A to compile.

- Jörg


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


Re: Scope question

Posted by Anders Hammar <an...@hammar.net>.
Introducing a new scope is not possible without breaking backwards
compatibility. Thus, unlikely to happen in the near future. Your option
right now is to use depMgmt.

/Anders


On Tue, Nov 5, 2013 at 12:15 PM, Guillaume CHAUVET <
guillaume.chauvet@qualiformed.com> wrote:

> Thank you for your quick answers,
>
> Use the dependencyManagement section seems a little bit cumbersome to
> implement, because it implies to define a parent POM for all libraries to
> which I would apply this "retention classes" mechanism.
>
> It's somewhat speculative on my part, but It could be very convenient to
> provide a new scope (or an option like "optional") that allows Maven to
> change the scope of  "z" dependency to "runtime" when the artifact "A" is
> included as dependency of project "B". I think it would be an interesting
> feature.
>
> What do you think about this idea ?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

RE: Scope question

Posted by Guillaume CHAUVET <gu...@qualiformed.com>.
Hi, 

I will dig in the dependency manager.

Best regards,
Guillaume

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

RE: Scope question

Posted by Jörg Schaible <Jo...@scalaris.com>.
Hi Guillaume,

Guillaume CHAUVET wrote:

> Thank you for your quick answers,
> 
> Use the dependencyManagement section seems a little bit cumbersome to
> implement, because it implies to define a parent POM for all libraries to
> which I would apply this "retention classes" mechanism.

No it does not. You may as well define the depMgmt locally. You don't have 
to share it.

- Jörg


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


RE: Scope question

Posted by Guillaume CHAUVET <gu...@qualiformed.com>.
Thank you for your quick answers,

Use the dependencyManagement section seems a little bit cumbersome to implement, because it implies to define a parent POM for all libraries to which I would apply this "retention classes" mechanism.

It's somewhat speculative on my part, but It could be very convenient to provide a new scope (or an option like "optional") that allows Maven to change the scope of  "z" dependency to "runtime" when the artifact "A" is included as dependency of project "B". I think it would be an interesting feature.

What do you think about this idea ?

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


Re: Scope question

Posted by Anders Hammar <an...@hammar.net>.
Should be possible to change through the dependencyManagement section.

/Anders


On Tue, Nov 5, 2013 at 10:47 AM, Guillaume CHAUVET <
guillaume.chauvet@qualiformed.com> wrote:

> Hello,
>
> I wondering if it is possible to change the scope of a dependency
> depending on the position in the tree of dependencies ?
> Here is a small example:
> An artifact "A" with a dependence on a "z" artifact defined with "compile"
> scope.
> If I use artifact "A" in a project "B", I would like the dependency scope
> of "z" becomes "runtime", in order to prevent the user to explicitly call
> classes from artifact "z ".
>
> Do you think it is possible to have this kind of behaviour ?
> Thanks in advance,
>
> Guillaume
>