Compile scope dependency, used as runtime scope transitively

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Compile scope dependency, used as runtime scope transitively

Andy Feldman
Assuming I have a dependency relationship of "my-project -> my-library ->
upstream-library", with each dependency in compile scope, I know that
my-project transitively picks up a compile scope dependency on
upstream-library. Reading the documentation at
https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
I see a note about this transitive dependency:

"(*) Note: it is intended that this should be runtime scope instead, so
that all compile dependencies must be explicitly listed - however, there is
the case where the library you depend on extends a class from another
library, forcing you to have available at compile time. For this reason,
compile time dependencies remain as compile scope even when they are
transitive."

If I know that my-library does not have this issue, is there any way to
declare the dependencies such that I can get the intended behavior? I want
upstream-library to be picked up as runtime scope for my-project, not as
compile scope.

Thanks,
--
Andy Feldman
Reply | Threaded
Open this post in threaded view
|

Re: Compile scope dependency, used as runtime scope transitively

stephenconnolly
On Sun 24 Dec 2017 at 18:01, Andy Feldman <[hidden email]> wrote:

> Assuming I have a dependency relationship of "my-project -> my-library ->
> upstream-library", with each dependency in compile scope, I know that
> my-project transitively picks up a compile scope dependency on
> upstream-library. Reading the documentation at
>
> https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
> I see a note about this transitive dependency:
>
> "(*) Note: it is intended that this should be runtime scope instead, so
> that all compile dependencies must be explicitly listed - however, there is
> the case where the library you depend on extends a class from another
> library, forcing you to have available at compile time. For this reason,
> compile time dependencies remain as compile scope even when they are
> transitive."
>
> If I know that my-library does not have this issue, is there any way to
> declare the dependencies such that I can get the intended behavior? I want
> upstream-library to be picked up as runtime scope for my-project, not as
> compile scope.


Declare it with scope “runtime”?

>
>
> Thanks,
> --
> Andy Feldman
>
--
Sent from my phone
Reply | Threaded
Open this post in threaded view
|

Re: Compile scope dependency, used as runtime scope transitively

Andy Feldman
On Dec 26, 2017 11:34, "Stephen Connolly" <[hidden email]>
wrote:

On Sun 24 Dec 2017 at 18:01, Andy Feldman <[hidden email]> wrote:

> Assuming I have a dependency relationship of "my-project -> my-library ->
> upstream-library", with each dependency in compile scope, I know that
> my-project transitively picks up a compile scope dependency on
> upstream-library. Reading the documentation at
>
> https://maven.apache.org/guides/introduction/introduction-to-dependency-
mechanism.html
> I see a note about this transitive dependency:
>
> "(*) Note: it is intended that this should be runtime scope instead, so
> that all compile dependencies must be explicitly listed - however, there
is
> the case where the library you depend on extends a class from another
> library, forcing you to have available at compile time. For this reason,
> compile time dependencies remain as compile scope even when they are
> transitive."
>
> If I know that my-library does not have this issue, is there any way to
> declare the dependencies such that I can get the intended behavior? I want
> upstream-library to be picked up as runtime scope for my-project, not as
> compile scope.


Declare it with scope “runtime”?


It needs to be compile scope in my-library since my-library uses classes
from upstream-library. I'd like to avoid declaring upstream-library at all
in my-project if possible, since my-project has nothing to do with
upstream-library.


>
>
> Thanks,
> --
> Andy Feldman
>
--
Sent from my phone
Reply | Threaded
Open this post in threaded view
|

Re: Compile scope dependency, used as runtime scope transitively

stephenconnolly
So you could have scope=compile&optional=true (which means the dep is
non-transitive)

On Wed 27 Dec 2017 at 00:26, Andy Feldman <[hidden email]> wrote:

> On Dec 26, 2017 11:34, "Stephen Connolly" <[hidden email]
> >
> wrote:
>
> On Sun 24 Dec 2017 at 18:01, Andy Feldman <[hidden email]> wrote:
>
> > Assuming I have a dependency relationship of "my-project -> my-library ->
> > upstream-library", with each dependency in compile scope, I know that
> > my-project transitively picks up a compile scope dependency on
> > upstream-library. Reading the documentation at
> >
> > https://maven.apache.org/guides/introduction/introduction-to-dependency-
> mechanism.html
> <https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html>
> > I see a note about this transitive dependency:
> >
> > "(*) Note: it is intended that this should be runtime scope instead, so
> > that all compile dependencies must be explicitly listed - however, there
> is
> > the case where the library you depend on extends a class from another
> > library, forcing you to have available at compile time. For this reason,
> > compile time dependencies remain as compile scope even when they are
> > transitive."
> >
> > If I know that my-library does not have this issue, is there any way to
> > declare the dependencies such that I can get the intended behavior? I
> want
> > upstream-library to be picked up as runtime scope for my-project, not as
> > compile scope.
>
>
> Declare it with scope “runtime”?
>
>
> It needs to be compile scope in my-library since my-library uses classes
> from upstream-library. I'd like to avoid declaring upstream-library at all
> in my-project if possible, since my-project has nothing to do with
> upstream-library.
>
>
> >
> >
> > Thanks,
> > --
> > Andy Feldman
> >
> --
> Sent from my phone
>
--
Sent from my phone
Reply | Threaded
Open this post in threaded view
|

Re: Compile scope dependency, used as runtime scope transitively

Nick_S
But I think that he wants it transitive, but only at runtime scope instead
of compile time.

I also wondered a while ago if this was possible. It would be nice to keep
clean projects clean. (As in, declared all compile time dependencies
instead of relying on transitive compile time dependencies.)

Would implementing this be an addition to the dependencies plugin?
(crossing fingers, I guess this is done in Maven itself and not in a
plugin).

Nick Stolwijk

~~~ Try to leave this world a little better than you found it and, when
your turn comes to die, you can die happy in feeling that at any rate you
have not wasted your time but have done your best ~~~

Lord Baden-Powell

On Wed, Dec 27, 2017 at 10:54 AM, Stephen Connolly <
[hidden email]> wrote:

> So you could have scope=compile&optional=true (which means the dep is
> non-transitive)
>
> On Wed 27 Dec 2017 at 00:26, Andy Feldman <[hidden email]> wrote:
>
> > On Dec 26, 2017 11:34, "Stephen Connolly" <stephen.alan.connolly@gmail.
> com
> > >
> > wrote:
> >
> > On Sun 24 Dec 2017 at 18:01, Andy Feldman <[hidden email]> wrote:
> >
> > > Assuming I have a dependency relationship of "my-project -> my-library
> ->
> > > upstream-library", with each dependency in compile scope, I know that
> > > my-project transitively picks up a compile scope dependency on
> > > upstream-library. Reading the documentation at
> > >
> > > https://maven.apache.org/guides/introduction/
> introduction-to-dependency-
> > mechanism.html
> > <https://maven.apache.org/guides/introduction/
> introduction-to-dependency-mechanism.html>
> > > I see a note about this transitive dependency:
> > >
> > > "(*) Note: it is intended that this should be runtime scope instead, so
> > > that all compile dependencies must be explicitly listed - however,
> there
> > is
> > > the case where the library you depend on extends a class from another
> > > library, forcing you to have available at compile time. For this
> reason,
> > > compile time dependencies remain as compile scope even when they are
> > > transitive."
> > >
> > > If I know that my-library does not have this issue, is there any way to
> > > declare the dependencies such that I can get the intended behavior? I
> > want
> > > upstream-library to be picked up as runtime scope for my-project, not
> as
> > > compile scope.
> >
> >
> > Declare it with scope “runtime”?
> >
> >
> > It needs to be compile scope in my-library since my-library uses classes
> > from upstream-library. I'd like to avoid declaring upstream-library at
> all
> > in my-project if possible, since my-project has nothing to do with
> > upstream-library.
> >
> >
> > >
> > >
> > > Thanks,
> > > --
> > > Andy Feldman
> > >
> > --
> > Sent from my phone
> >
> --
> Sent from my phone
>
Reply | Threaded
Open this post in threaded view
|

Re: Compile scope dependency, used as runtime scope transitively

Anders Hammar
Declaring "upstream-library" with scope "runtime" in the
dependencyManagement section of "my-project" should do it. However, I don't
see the real benefit of going through this hassle.

/Anders

On Wed, Dec 27, 2017 at 11:30 AM, Nick Stolwijk <[hidden email]>
wrote:

> But I think that he wants it transitive, but only at runtime scope instead
> of compile time.
>
> I also wondered a while ago if this was possible. It would be nice to keep
> clean projects clean. (As in, declared all compile time dependencies
> instead of relying on transitive compile time dependencies.)
>
> Would implementing this be an addition to the dependencies plugin?
> (crossing fingers, I guess this is done in Maven itself and not in a
> plugin).
>
> Nick Stolwijk
>
> ~~~ Try to leave this world a little better than you found it and, when
> your turn comes to die, you can die happy in feeling that at any rate you
> have not wasted your time but have done your best ~~~
>
> Lord Baden-Powell
>
> On Wed, Dec 27, 2017 at 10:54 AM, Stephen Connolly <
> [hidden email]> wrote:
>
> > So you could have scope=compile&optional=true (which means the dep is
> > non-transitive)
> >
> > On Wed 27 Dec 2017 at 00:26, Andy Feldman <[hidden email]> wrote:
> >
> > > On Dec 26, 2017 11:34, "Stephen Connolly" <stephen.alan.connolly@gmail.
> > com
> > > >
> > > wrote:
> > >
> > > On Sun 24 Dec 2017 at 18:01, Andy Feldman <[hidden email]>
> wrote:
> > >
> > > > Assuming I have a dependency relationship of "my-project ->
> my-library
> > ->
> > > > upstream-library", with each dependency in compile scope, I know that
> > > > my-project transitively picks up a compile scope dependency on
> > > > upstream-library. Reading the documentation at
> > > >
> > > > https://maven.apache.org/guides/introduction/
> > introduction-to-dependency-
> > > mechanism.html
> > > <https://maven.apache.org/guides/introduction/
> > introduction-to-dependency-mechanism.html>
> > > > I see a note about this transitive dependency:
> > > >
> > > > "(*) Note: it is intended that this should be runtime scope instead,
> so
> > > > that all compile dependencies must be explicitly listed - however,
> > there
> > > is
> > > > the case where the library you depend on extends a class from another
> > > > library, forcing you to have available at compile time. For this
> > reason,
> > > > compile time dependencies remain as compile scope even when they are
> > > > transitive."
> > > >
> > > > If I know that my-library does not have this issue, is there any way
> to
> > > > declare the dependencies such that I can get the intended behavior? I
> > > want
> > > > upstream-library to be picked up as runtime scope for my-project, not
> > as
> > > > compile scope.
> > >
> > >
> > > Declare it with scope “runtime”?
> > >
> > >
> > > It needs to be compile scope in my-library since my-library uses
> classes
> > > from upstream-library. I'd like to avoid declaring upstream-library at
> > all
> > > in my-project if possible, since my-project has nothing to do with
> > > upstream-library.
> > >
> > >
> > > >
> > > >
> > > > Thanks,
> > > > --
> > > > Andy Feldman
> > > >
> > > --
> > > Sent from my phone
> > >
> > --
> > Sent from my phone
> >
>