You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Stéphane TOUSSAINT <st...@4dconcept.fr> on 2010/03/02 16:30:14 UTC

Reflexion about dependencies.

Hi,

First of all, sorry if I talk about something already well debated. But 
I haven't found informations (best practice), about this point.

If I understand well the maven documentation, I MUST added into my 
pom.xml any dependences with which I currently work (at least any 
dependency from which a class is used as import).
The fact is that some dependencies that I use, handles other 
dependencies that I use too. My IDE is therefore unable to tell me that 
I forget to add a dependency because of the transitivity.

The question I just come to asked me is why transitive dependencies are 
not seen as 'RUNTIME' dependencies so they are not part of the 
compilation of my own code ?
With such a feature, my IDE is able to enlights packages, classes that I 
don't explicitly includes in my pom.xml

Guess that it isn't that easy but then, can I have some inputs on this ?

Thanks in advance.

Stéphane Toussaint

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


Re: Reflexion about dependencies.

Posted by Jörg Schaible <jo...@gmx.de>.
Stéphane TOUSSAINT wrote at Mittwoch, 3. März 2010 13:48:

> 
>> http://jira.codehaus.org/browse/MNG-2589 and linked stuff.
>>   
> Thanks Jörg this is the issue I have to keep an eye on.

You can already simulate this though. Assuming you're already using a 
depMgmt section to define your versions, you may simply declare all 
artifacts also with scope runtime. That way you're forced to declare all 
deps for scope compile locally again. However, as Benjamin explained, there 
might be more than you expect.

- Jörg


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


Re: Reflexion about dependencies.

Posted by Stéphane TOUSSAINT <st...@4dconcept.fr>.
> http://jira.codehaus.org/browse/MNG-2589 and linked stuff.
>   
Thanks Jörg this is the issue I have to keep an eye on.

Stéphane

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


Re: Reflexion about dependencies.

Posted by Jörg Schaible <jo...@gmx.de>.
Stéphane TOUSSAINT wrote at Mittwoch, 3. März 2010 10:59:

> That is the point.
> 
> A sample :
> my.project:test:1.0-SNAPSHOT (a Project)
> my.utility:xml:1.0 (an utils librarie)
> dom4j:dom4j:1.6 (the well known XML library)
> 
> I added to my.project:test the my.utility:xml which talk about XML which
> use (and include in it's pom.xml) the dom4j:dom4j:1.6 artifact.
> 
> my.project:test
> |----> my.utility:xml
>                 |----> dom4j:dom4j
> 
> 
> I can now work with classes from my.utility:xml. Everything OK,
> compiles, packages, as expected.
> 
> But now, nothing prevents me to use directly classes from dom4j in my
> own code. The compiler will not complains, but it should because the
> dom4j is only a transitive dependency. I must add dom4j to
> my.project:test pom.xml before using it, mustn't I ?.
> This sample is light enough to take care of, but what if I play with a
> lot more librairies.
> 
> The point is why not treat dom4j:dom4j as a 'RUNTIME' library from the
> my.project:test point of view ? The compiler will explicitly tell me
> that dom4j classes are not part of my compilation classpath and that I
> have to add it in my pom
> 
> my.project:test
> |----> my.utility:xml
> |                |----> dom4j:dom4j
> |----> dom4j:dom4j
> 
> Hoping I make things more clear.

http://jira.codehaus.org/browse/MNG-2589 and linked stuff.

- Jörg


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


Re: Reflexion about dependencies.

Posted by Stéphane TOUSSAINT <st...@4dconcept.fr>.
That is the point.

A sample :
my.project:test:1.0-SNAPSHOT (a Project)
my.utility:xml:1.0 (an utils librarie)
dom4j:dom4j:1.6 (the well known XML library)

I added to my.project:test the my.utility:xml which talk about XML which 
use (and include in it's pom.xml) the dom4j:dom4j:1.6 artifact.

my.project:test
|----> my.utility:xml
                |----> dom4j:dom4j


I can now work with classes from my.utility:xml. Everything OK, 
compiles, packages, as expected.

But now, nothing prevents me to use directly classes from dom4j in my 
own code. The compiler will not complains, but it should because the 
dom4j is only a transitive dependency. I must add dom4j to 
my.project:test pom.xml before using it, mustn't I ?.
This sample is light enough to take care of, but what if I play with a 
lot more librairies.

The point is why not treat dom4j:dom4j as a 'RUNTIME' library from the 
my.project:test point of view ? The compiler will explicitly tell me 
that dom4j classes are not part of my compilation classpath and that I 
have to add it in my pom

my.project:test
|----> my.utility:xml
|                |----> dom4j:dom4j
|----> dom4j:dom4j

Hoping I make things more clear.

Stéphane


Wayne Fay a écrit :
>> The fact is that some dependencies that I use, handles other dependencies
>> that I use too. My IDE is therefore unable to tell me that I forget to add a
>> dependency because of the transitivity.
>>     
>
> If a given module uses an artifact directly, it must be included as a
> dependency in its pom file, not as a transitive dep.
>
> If that doesn't answer your question, perhaps a concrete explanation
> of what you're describing would make things more clear.
>
> Wayne
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>   

-- 
4Dconcept
Stéphane TOUSSAINT
Tel : 01.61.08.50.27
Std : 01.61.08.50.20
Fax : 01.61.38.24.41

Re: Reflexion about dependencies.

Posted by Stéphane TOUSSAINT <st...@4dconcept.fr>.
Hi Patrick
> For a more complete anwser, read:
>
> http://www.sonatype.com/people/2009/10/maven-tips-and-tricks-optimizing-with-the-maven-dependency-plugin/
>   
Thank you for your input.

Stéphane

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


Re: Reflexion about dependencies.

Posted by Patrick Turcotte <pa...@revolutionlinux.com>.
For a more complete anwser, read:

http://www.sonatype.com/people/2009/10/maven-tips-and-tricks-optimizing-with-the-maven-dependency-plugin/

Patrick

On 10-03-02 01:06 PM, Patrick Turcotte wrote:
> mvn dependency:tree
>
> should help you see nested dependencies. The codehaus maven eclipse
> plugin can also help you visualize it.
>
> Patrick
>
> On 10-03-02 12:16 PM, Wayne Fay wrote:
>   
>>> The fact is that some dependencies that I use, handles other dependencies
>>> that I use too. My IDE is therefore unable to tell me that I forget to add a
>>> dependency because of the transitivity.
>>>     
>>>       
>> If a given module uses an artifact directly, it must be included as a
>> dependency in its pom file, not as a transitive dep.
>>
>> If that doesn't answer your question, perhaps a concrete explanation
>> of what you're describing would make things more clear.
>>
>> Wayne
>>
>> ---------------------------------------------------------------------
>> 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
>
>   

-- 
Patrick Turcotte
Développeur/Architecte Java
------------------------------------
patrick.turcotte@revolutionlinux.com
(819) 780-8955, poste 1129
Sans frais 1-800-996-8955, poste 1129


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


Re: Reflexion about dependencies.

Posted by Patrick Turcotte <pa...@revolutionlinux.com>.
mvn dependency:tree

should help you see nested dependencies. The codehaus maven eclipse
plugin can also help you visualize it.

Patrick

On 10-03-02 12:16 PM, Wayne Fay wrote:
>> The fact is that some dependencies that I use, handles other dependencies
>> that I use too. My IDE is therefore unable to tell me that I forget to add a
>> dependency because of the transitivity.
>>     
> If a given module uses an artifact directly, it must be included as a
> dependency in its pom file, not as a transitive dep.
>
> If that doesn't answer your question, perhaps a concrete explanation
> of what you're describing would make things more clear.
>
> Wayne
>
> ---------------------------------------------------------------------
> 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: Reflexion about dependencies.

Posted by Wayne Fay <wa...@gmail.com>.
> The fact is that some dependencies that I use, handles other dependencies
> that I use too. My IDE is therefore unable to tell me that I forget to add a
> dependency because of the transitivity.

If a given module uses an artifact directly, it must be included as a
dependency in its pom file, not as a transitive dep.

If that doesn't answer your question, perhaps a concrete explanation
of what you're describing would make things more clear.

Wayne

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