You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by John Fallows <jo...@gmail.com> on 2005/10/05 21:40:51 UTC

[m2] managing transitive dependencies

Suppose I have 3 Maven2 projects, A, B and C.

A is self-contained.
B depends on A for-implementation-only.
C depends on B.

My understanding of dependency scopes is that if C depends on B at
"compile" scope, then all of B's "compile" scope dependencies will
also become transitive "compile" scope dependencies of C.

How do I prevent the classes in A from being visible during
compilation of C?  Is this another usecase for "provided" scope?  Or
does marking the A dependency as "provided" scope may have other
implications for project B?

I am concerned about the potential to introduce an accidental direct
dependency from A to C.

Ideally, I'd like project B to control the full set of compile
dependencies that are valid exports as transitive dependencies.

Although I don't want to expose B's dependencies during compilation of
C, some of those dependencies will be necessary at runtime or during
unit test execution of C.

Perhaps we could specify "compile" scope for C's dependency on project
B itself, but "test" scope (say) for all of project B's dependencies?

Kind Regards,
John Fallows.

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


Re: [m2] managing transitive dependencies

Posted by John Fallows <jo...@gmail.com>.
On 10/7/05, Brett Porter <br...@gmail.com> wrote:
> The reason for this difference is because if B extends a class from A,
> and C uses the class from B, A is required at compile time.

Often this is not strictly necessary, but one usecase would be where
Class-from-C extends Class-from-B, which extends Class-from-A and
Class-from-C needs to call some protected method of Class-from-A, so
it is needed at compile time, right?

Thanks for helping to clarify my thinking on this. :-)

Kind Regards,
John Fallows.

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


Re: [m2] managing transitive dependencies

Posted by Brett Porter <br...@gmail.com>.
The reason for this difference is because if B extends a class from A,
and C uses the class from B, A is required at compile time.

Otherwise, I'd agree.

- Brett

On 10/7/05, John Fallows <jo...@gmail.com> wrote:
> On 10/6/05, Brett Porter <br...@gmail.com> wrote:
> > Sorry, I'm missing something. Why isn't B depending on A with "runtime" scope?
>
> B depends on A with "compile" scope because it directly uses classes
> from A during compilation, not just at runtime.
>
> This gives the following scenario.
> C --(compile)--> B --(compile)--> A
>
> But, I am concerned that this implies..
> C --(compile)--> B
> C --(compile)--> A
>
> when all that is necessary is..
> C --(compile)--> B
> C --(runtime)--> A
>
> so that C can successfully compile and so that the classes in both A
> and B can be loaded and resolved during unit testing of C.
>
> Kind Regards,
> John Fallows
>
> > On 10/6/05, John Fallows <jo...@gmail.com> wrote:
> > > Suppose I have 3 Maven2 projects, A, B and C.
> > >
> > > A is self-contained.
> > > B depends on A for-implementation-only.
> > > C depends on B.
> > >
> > > My understanding of dependency scopes is that if C depends on B at
> > > "compile" scope, then all of B's "compile" scope dependencies will
> > > also become transitive "compile" scope dependencies of C.
> > >
> > > How do I prevent the classes in A from being visible during
> > > compilation of C?  Is this another usecase for "provided" scope?  Or
> > > does marking the A dependency as "provided" scope may have other
> > > implications for project B?
> > >
> > > I am concerned about the potential to introduce an accidental direct
> > > dependency from A to C.
> > >
> > > Ideally, I'd like project B to control the full set of compile
> > > dependencies that are valid exports as transitive dependencies.
> > >
> > > Although I don't want to expose B's dependencies during compilation of
> > > C, some of those dependencies will be necessary at runtime or during
> > > unit test execution of C.
> > >
> > > Perhaps we could specify "compile" scope for C's dependency on project
> > > B itself, but "test" scope (say) for all of project B's dependencies?
> > >
> > > Kind Regards,
> > > John Fallows.
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > > For additional commands, e-mail: users-help@maven.apache.org
> > >
> > >
> >
>

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


Re: [m2] managing transitive dependencies

Posted by John Fallows <jo...@gmail.com>.
On 10/6/05, Brett Porter <br...@gmail.com> wrote:
> Sorry, I'm missing something. Why isn't B depending on A with "runtime" scope?

B depends on A with "compile" scope because it directly uses classes
from A during compilation, not just at runtime.

This gives the following scenario.
C --(compile)--> B --(compile)--> A

But, I am concerned that this implies..
C --(compile)--> B
C --(compile)--> A

when all that is necessary is..
C --(compile)--> B
C --(runtime)--> A

so that C can successfully compile and so that the classes in both A
and B can be loaded and resolved during unit testing of C.

Kind Regards,
John Fallows

> On 10/6/05, John Fallows <jo...@gmail.com> wrote:
> > Suppose I have 3 Maven2 projects, A, B and C.
> >
> > A is self-contained.
> > B depends on A for-implementation-only.
> > C depends on B.
> >
> > My understanding of dependency scopes is that if C depends on B at
> > "compile" scope, then all of B's "compile" scope dependencies will
> > also become transitive "compile" scope dependencies of C.
> >
> > How do I prevent the classes in A from being visible during
> > compilation of C?  Is this another usecase for "provided" scope?  Or
> > does marking the A dependency as "provided" scope may have other
> > implications for project B?
> >
> > I am concerned about the potential to introduce an accidental direct
> > dependency from A to C.
> >
> > Ideally, I'd like project B to control the full set of compile
> > dependencies that are valid exports as transitive dependencies.
> >
> > Although I don't want to expose B's dependencies during compilation of
> > C, some of those dependencies will be necessary at runtime or during
> > unit test execution of C.
> >
> > Perhaps we could specify "compile" scope for C's dependency on project
> > B itself, but "test" scope (say) for all of project B's dependencies?
> >
> > Kind Regards,
> > John Fallows.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>

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


Re: [m2] managing transitive dependencies

Posted by Brett Porter <br...@gmail.com>.
Sorry, I'm missing something. Why isn't B depending on A with "runtime" scope?

- Brett

On 10/6/05, John Fallows <jo...@gmail.com> wrote:
> Suppose I have 3 Maven2 projects, A, B and C.
>
> A is self-contained.
> B depends on A for-implementation-only.
> C depends on B.
>
> My understanding of dependency scopes is that if C depends on B at
> "compile" scope, then all of B's "compile" scope dependencies will
> also become transitive "compile" scope dependencies of C.
>
> How do I prevent the classes in A from being visible during
> compilation of C?  Is this another usecase for "provided" scope?  Or
> does marking the A dependency as "provided" scope may have other
> implications for project B?
>
> I am concerned about the potential to introduce an accidental direct
> dependency from A to C.
>
> Ideally, I'd like project B to control the full set of compile
> dependencies that are valid exports as transitive dependencies.
>
> Although I don't want to expose B's dependencies during compilation of
> C, some of those dependencies will be necessary at runtime or during
> unit test execution of C.
>
> Perhaps we could specify "compile" scope for C's dependency on project
> B itself, but "test" scope (say) for all of project B's dependencies?
>
> Kind Regards,
> John Fallows.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

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