You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Raffaele <r....@prismasw.it> on 2007/10/03 12:28:30 UTC

Transitive dep misunderstanding

Hi all,
my very simple scenario:
project B dependes upon project A which dependes upon Junit, and so:
A --> B --> Junit

Project A also needs of Junit to compile its test classes, but I would like
that project A didn't define directly the dependency from Junit.

Can Junit in this scenario be considered a transitive dependency for project
A? I believe yes.

When I load my projects in Eclipse 3.3 after obviously mvn eclipse:eclipse,
I see compile error on project A which it don't find the reference to
Junit....
But how can it be possible? Shouldn't the references of right jars be
arranged?

The compile error is also visible when I try from command-line to run mvn
test on project A folder.

Thank you very much, 
best regards.
Raffaele
-- 
View this message in context: http://www.nabble.com/Transitive-dep-misunderstanding-tf4560954s177.html#a13016209
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Transitive dep misunderstanding

Posted by Raffaele <r....@prismasw.it>.
Really, I tried to set up another slightly different scenario, this one:
A --> B --> C
where both B and C are defined as compile scope

At this point, running mvn eclipse:eclipse on project A, in Eclipse this
time I see in the "Referenced Libraries" also the jar of project C.

In the end, it was all a scope matter...

Thanks to all guys.
Best regards.
Raffaele


struberg wrote:
> 
> may it be that the junit only has the scope='test' in
> the pom and this scope will not be taken by the
> eclipse:eclipse?
> 
> For what i know eclipse does not have an own 'test'
> classpath but only one-for-all.
> 
> LieGrü,
> strub
> 
> --- Nick Stolwijk <ni...@planet.nl> schrieb:
> 
>> A.F.A.I.K. transitive dependencies only count at
>> runtime. You need those 
>> dependencies to run your program. If you need a
>> dependency at compile 
>> time, it is your own dependency and not some
>> transitive dependency.
>> 
>> Hth,
>> 
>> Nick Stolwijk
>> 
>> Raffaele wrote:
>> > Hi all,
>> > my very simple scenario:
>> > project B dependes upon project A which dependes
>> upon Junit, and so:
>> > A --> B --> Junit
>> >
>> > Project A also needs of Junit to compile its test
>> classes, but I would like
>> > that project A didn't define directly the
>> dependency from Junit.
>> >
>> > Can Junit in this scenario be considered a
>> transitive dependency for project
>> > A? I believe yes.
>> >
>> > When I load my projects in Eclipse 3.3 after
>> obviously mvn eclipse:eclipse,
>> > I see compile error on project A which it don't
>> find the reference to
>> > Junit....
>> > But how can it be possible? Shouldn't the
>> references of right jars be
>> > arranged?
>> >
>> > The compile error is also visible when I try from
>> command-line to run mvn
>> > test on project A folder.
>> >
>> > Thank you very much, 
>> > best regards.
>> > Raffaele
>> >   
>> 
>> 
>>
> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> users-unsubscribe@maven.apache.org
>> For additional commands, e-mail:
>> users-help@maven.apache.org
>> 
>> 
> 
> 
> 
>       Wissenswertes für Bastler und Hobby Handwerker. BE A BETTER
> HEIMWERKER! www.yahoo.de/clever
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Transitive-dep-misunderstanding-tf4560954s177.html#a13020618
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Transitive dep misunderstanding

Posted by Mark Struberg <st...@yahoo.de>.
may it be that the junit only has the scope='test' in
the pom and this scope will not be taken by the
eclipse:eclipse?

For what i know eclipse does not have an own 'test'
classpath but only one-for-all.

LieGrü,
strub

--- Nick Stolwijk <ni...@planet.nl> schrieb:

> A.F.A.I.K. transitive dependencies only count at
> runtime. You need those 
> dependencies to run your program. If you need a
> dependency at compile 
> time, it is your own dependency and not some
> transitive dependency.
> 
> Hth,
> 
> Nick Stolwijk
> 
> Raffaele wrote:
> > Hi all,
> > my very simple scenario:
> > project B dependes upon project A which dependes
> upon Junit, and so:
> > A --> B --> Junit
> >
> > Project A also needs of Junit to compile its test
> classes, but I would like
> > that project A didn't define directly the
> dependency from Junit.
> >
> > Can Junit in this scenario be considered a
> transitive dependency for project
> > A? I believe yes.
> >
> > When I load my projects in Eclipse 3.3 after
> obviously mvn eclipse:eclipse,
> > I see compile error on project A which it don't
> find the reference to
> > Junit....
> > But how can it be possible? Shouldn't the
> references of right jars be
> > arranged?
> >
> > The compile error is also visible when I try from
> command-line to run mvn
> > test on project A folder.
> >
> > Thank you very much, 
> > best regards.
> > Raffaele
> >   
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> users-unsubscribe@maven.apache.org
> For additional commands, e-mail:
> users-help@maven.apache.org
> 
> 



      Wissenswertes für Bastler und Hobby Handwerker. BE A BETTER HEIMWERKER! www.yahoo.de/clever

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


Re: Transitive dep misunderstanding

Posted by Nick Stolwijk <ni...@planet.nl>.
A.F.A.I.K. transitive dependencies only count at runtime. You need those 
dependencies to run your program. If you need a dependency at compile 
time, it is your own dependency and not some transitive dependency.

Hth,

Nick Stolwijk

Raffaele wrote:
> Hi all,
> my very simple scenario:
> project B dependes upon project A which dependes upon Junit, and so:
> A --> B --> Junit
>
> Project A also needs of Junit to compile its test classes, but I would like
> that project A didn't define directly the dependency from Junit.
>
> Can Junit in this scenario be considered a transitive dependency for project
> A? I believe yes.
>
> When I load my projects in Eclipse 3.3 after obviously mvn eclipse:eclipse,
> I see compile error on project A which it don't find the reference to
> Junit....
> But how can it be possible? Shouldn't the references of right jars be
> arranged?
>
> The compile error is also visible when I try from command-line to run mvn
> test on project A folder.
>
> Thank you very much, 
> best regards.
> Raffaele
>   


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


Re: Transitive dep misunderstanding

Posted by Tim Kettler <ti...@udo.edu>.
Hi,

Raffaele schrieb:
> Hi all,
> my very simple scenario:
> project B dependes upon project A which dependes upon Junit, and so:

I guess you mean project A depends on project B which depends on Junit.

> A --> B --> Junit
> 
> Project A also needs of Junit to compile its test classes, but I would like
> that project A didn't define directly the dependency from Junit.

That's not the maven philosophy. If a project depends directly on 
classes from another project (class inheritance, imports...) it should 
specify a dependency to the projects artifact in its pom. What for 
example if project B be at some time doesn't depend on junit anymore?

> Can Junit in this scenario be considered a transitive dependency for project
> A? I believe yes.

I think no :-)

Additionally, as Nick pointed out only dependencies with a certain scope 
are part of the transitive dependency tree. See [1] for a table 
detailing the inclusion of transitive dependencies and their resulting 
scopes.

> 
> When I load my projects in Eclipse 3.3 after obviously mvn eclipse:eclipse,
> I see compile error on project A which it don't find the reference to
> Junit....
> But how can it be possible? Shouldn't the references of right jars be
> arranged?
> 
> The compile error is also visible when I try from command-line to run mvn
> test on project A folder.

As explained above, you have to include junit as a dependency in your 
project. If you want to avoid specifying common dependencies in every 
project you should look into creating a parent pom these projects share.

> Thank you very much, 
> best regards.
> Raffaele

-Tim

[1] 
http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html

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