You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by ak...@gmail.com on 2007/12/21 19:33:05 UTC

what is ?

Say I have parent pom called A  and child pom called B. I specified
<module> element for B inside A and also
specified <parent> element for A inside B. Now I dont understand I
would have to declare <dependencyManagement> element in A. Say if I
have B, C, D as child modules and B, C, D all 3 depend on junit then
can I declare junit as dependency in A using <dependencies> element
instead <dependencyManagement> and in that B, C, D inherit that
<dependency> instead of each B, C, D declaring the dependency. If so
in what cases do I use <dependencyManagement>.

I read the online documentation available at maven site but the
<dependencyManagement> documentation section is not clear to me. Can
anyone please explain <dependencyManagement> with an example.

Thank you.

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


Re: what is ?

Posted by ak...@gmail.com.
Thank you Dennis Lundberg, Ian Springer, nicolas de loof , Andrew
Robinson for timely replies. Now the <dependencyManagment> concept of
Maven is clear to me.

On Dec 22, 2007 12:27 AM, Ian Springer <ia...@redhat.com> wrote:
> dependencyManagement is basically a way to standardize versions for dependencies across descendant modules. For example, if I put the following in the root pom of my multi-module project:
>
>    <dependencyManagement>
>      ...
>      <dependency>
>        <groupId>gnu-getopt</groupId>
>        <artifactId>getopt</artifactId>
>        <version>1.0.13</version>
>      </dependency>
>      ...
>    </dependencyManagement>
>
> Then in any descendant poms that have deps on getopt, I can put:
>
>    <dependencies>
>      ...
>      <dependency>
>        <groupId>gnu-getopt</groupId>
>        <artifactId>getopt</artifactId>
>        <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
>      </dependency>
>      ...
>    <dependencies>
>
> And they'll inherit the version that is defined in the root pom. Then when I want to upgrade my entire project to a newer version of getopt, I only need to edit a single line in the root pom.
>
>
>
> akkachotu@gmail.com wrote:
> > Say I have parent pom called A  and child pom called B. I specified
> > <module> element for B inside A and also
> > specified <parent> element for A inside B. Now I dont understand I
> > would have to declare <dependencyManagement> element in A. Say if I
> > have B, C, D as child modules and B, C, D all 3 depend on junit then
> > can I declare junit as dependency in A using <dependencies> element
> > instead <dependencyManagement> and in that B, C, D inherit that
> > <dependency> instead of each B, C, D declaring the dependency. If so
> > in what cases do I use <dependencyManagement>.
> >
> > I read the online documentation available at maven site but the
> > <dependencyManagement> documentation section is not clear to me. Can
> > anyone please explain <dependencyManagement> with an example.
> >
> > Thank you.
> >
>
> > ---------------------------------------------------------------------
> > 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
>
>

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


Re: what is ?

Posted by Ian Springer <ia...@redhat.com>.
dependencyManagement is basically a way to standardize versions for dependencies across descendant modules. For example, if I put the following in the root pom of my multi-module project:

    <dependencyManagement>
      ...
      <dependency>
        <groupId>gnu-getopt</groupId>
        <artifactId>getopt</artifactId>
        <version>1.0.13</version>         
      </dependency>
      ...
    </dependencyManagement>

Then in any descendant poms that have deps on getopt, I can put:

    <dependencies>
      ...
      <dependency>
        <groupId>gnu-getopt</groupId>
        <artifactId>getopt</artifactId>      
        <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
      </dependency> 
      ...    
    <dependencies>

And they'll inherit the version that is defined in the root pom. Then when I want to upgrade my entire project to a newer version of getopt, I only need to edit a single line in the root pom.


akkachotu@gmail.com wrote:
> Say I have parent pom called A  and child pom called B. I specified
> <module> element for B inside A and also
> specified <parent> element for A inside B. Now I dont understand I
> would have to declare <dependencyManagement> element in A. Say if I
> have B, C, D as child modules and B, C, D all 3 depend on junit then
> can I declare junit as dependency in A using <dependencies> element
> instead <dependencyManagement> and in that B, C, D inherit that
> <dependency> instead of each B, C, D declaring the dependency. If so
> in what cases do I use <dependencyManagement>.
>
> I read the online documentation available at maven site but the
> <dependencyManagement> documentation section is not clear to me. Can
> anyone please explain <dependencyManagement> with an example.
>
> Thank you.
>
> ---------------------------------------------------------------------
> 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: what is ?

Posted by nicolas de loof <ni...@apache.org>.
Typically  another use case of dependencyManagement :

setting commons-logging to version 1.1.1 on <dependencyManagement> will also
force this version to be used whatever transitive dependencies would
resolve.


2007/12/22, Dennis Lundberg <de...@apache.org>:
>
> nicolas de loof wrote:
> > Typical use of dependencyManagement is to set version for commons libs
> in
> > parent POM, and to only refer to artifactId + groupId in children POM.
> This
> > ensure consistent versionning.
> >
> > Other use case is to "fix" bad maven metadatas. For example, exclude
> logkit
> > &, avalon... from commons-logging.
>
> Either that or upgrade to commons-logging-1.1.1 which has correct
> metadata. That might not be possible if the dependency on
> commons-logging is a transitive one though.
>
> > This can be done in parent POM or even (this is my case) in corporate
> POM.
> >
> >
> >
> > 2007/12/21, Andrew Robinson <an...@gmail.com>:
> >> <dependencyManagement> can be used to set common attributes for a dep,
> >> like exclusions, version etc.
> >>
> >> So:
> >>
> >> Parent P:
> >> <dependencyManagement>
> >> <dependency>
> >> <groupId>something</groupId>
> >> <artifactId>something</artifactId>
> >> <version>1.0.0</version>
> >> </dependency>
> >> </dependencyManagement>
> >>
> >> Child A & C:
> >> <dependencies>
> >> <dependency>
> >> <groupId>something</groupId>
> >> <artifactId>something</artifactId>
> >> </dependency>
> >> </dependencies>
> >>
> >> Child B doesn't use something
> >>
> >> Now I can change the version for something for both A and C in one
> place.
> >>
> >> Basically you want this if not all your child projects use a
> dependency.
> >>
> >> -Andrew
> >>
> >> On Dec 21, 2007 11:33 AM,  <ak...@gmail.com> wrote:
> >>> Say I have parent pom called A  and child pom called B. I specified
> >>> <module> element for B inside A and also
> >>> specified <parent> element for A inside B. Now I dont understand I
> >>> would have to declare <dependencyManagement> element in A. Say if I
> >>> have B, C, D as child modules and B, C, D all 3 depend on junit then
> >>> can I declare junit as dependency in A using <dependencies> element
> >>> instead <dependencyManagement> and in that B, C, D inherit that
> >>> <dependency> instead of each B, C, D declaring the dependency. If so
> >>> in what cases do I use <dependencyManagement>.
> >>>
> >>> I read the online documentation available at maven site but the
> >>> <dependencyManagement> documentation section is not clear to me. Can
> >>> anyone please explain <dependencyManagement> with an example.
> >>>
> >>> Thank you.
> >>>
> >>> ---------------------------------------------------------------------
> >>> 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
> >>
> >>
> >
>
>
> --
> Dennis Lundberg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: what is ?

Posted by Dennis Lundberg <de...@apache.org>.
nicolas de loof wrote:
> Typical use of dependencyManagement is to set version for commons libs in
> parent POM, and to only refer to artifactId + groupId in children POM. This
> ensure consistent versionning.
> 
> Other use case is to "fix" bad maven metadatas. For example, exclude logkit
> &, avalon... from commons-logging.

Either that or upgrade to commons-logging-1.1.1 which has correct
metadata. That might not be possible if the dependency on
commons-logging is a transitive one though.

> This can be done in parent POM or even (this is my case) in corporate POM.
> 
> 
> 
> 2007/12/21, Andrew Robinson <an...@gmail.com>:
>> <dependencyManagement> can be used to set common attributes for a dep,
>> like exclusions, version etc.
>>
>> So:
>>
>> Parent P:
>> <dependencyManagement>
>> <dependency>
>> <groupId>something</groupId>
>> <artifactId>something</artifactId>
>> <version>1.0.0</version>
>> </dependency>
>> </dependencyManagement>
>>
>> Child A & C:
>> <dependencies>
>> <dependency>
>> <groupId>something</groupId>
>> <artifactId>something</artifactId>
>> </dependency>
>> </dependencies>
>>
>> Child B doesn't use something
>>
>> Now I can change the version for something for both A and C in one place.
>>
>> Basically you want this if not all your child projects use a dependency.
>>
>> -Andrew
>>
>> On Dec 21, 2007 11:33 AM,  <ak...@gmail.com> wrote:
>>> Say I have parent pom called A  and child pom called B. I specified
>>> <module> element for B inside A and also
>>> specified <parent> element for A inside B. Now I dont understand I
>>> would have to declare <dependencyManagement> element in A. Say if I
>>> have B, C, D as child modules and B, C, D all 3 depend on junit then
>>> can I declare junit as dependency in A using <dependencies> element
>>> instead <dependencyManagement> and in that B, C, D inherit that
>>> <dependency> instead of each B, C, D declaring the dependency. If so
>>> in what cases do I use <dependencyManagement>.
>>>
>>> I read the online documentation available at maven site but the
>>> <dependencyManagement> documentation section is not clear to me. Can
>>> anyone please explain <dependencyManagement> with an example.
>>>
>>> Thank you.
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
> 


-- 
Dennis Lundberg

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


Re: what is ?

Posted by nicolas de loof <ni...@apache.org>.
Typical use of dependencyManagement is to set version for commons libs in
parent POM, and to only refer to artifactId + groupId in children POM. This
ensure consistent versionning.

Other use case is to "fix" bad maven metadatas. For example, exclude logkit
&, avalon... from commons-logging.
This can be done in parent POM or even (this is my case) in corporate POM.



2007/12/21, Andrew Robinson <an...@gmail.com>:
>
> <dependencyManagement> can be used to set common attributes for a dep,
> like exclusions, version etc.
>
> So:
>
> Parent P:
> <dependencyManagement>
> <dependency>
> <groupId>something</groupId>
> <artifactId>something</artifactId>
> <version>1.0.0</version>
> </dependency>
> </dependencyManagement>
>
> Child A & C:
> <dependencies>
> <dependency>
> <groupId>something</groupId>
> <artifactId>something</artifactId>
> </dependency>
> </dependencies>
>
> Child B doesn't use something
>
> Now I can change the version for something for both A and C in one place.
>
> Basically you want this if not all your child projects use a dependency.
>
> -Andrew
>
> On Dec 21, 2007 11:33 AM,  <ak...@gmail.com> wrote:
> > Say I have parent pom called A  and child pom called B. I specified
> > <module> element for B inside A and also
> > specified <parent> element for A inside B. Now I dont understand I
> > would have to declare <dependencyManagement> element in A. Say if I
> > have B, C, D as child modules and B, C, D all 3 depend on junit then
> > can I declare junit as dependency in A using <dependencies> element
> > instead <dependencyManagement> and in that B, C, D inherit that
> > <dependency> instead of each B, C, D declaring the dependency. If so
> > in what cases do I use <dependencyManagement>.
> >
> > I read the online documentation available at maven site but the
> > <dependencyManagement> documentation section is not clear to me. Can
> > anyone please explain <dependencyManagement> with an example.
> >
> > Thank you.
> >
> > ---------------------------------------------------------------------
> > 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: what is ?

Posted by Andrew Robinson <an...@gmail.com>.
<dependencyManagement> can be used to set common attributes for a dep,
like exclusions, version etc.

So:

Parent P:
<dependencyManagement>
<dependency>
<groupId>something</groupId>
<artifactId>something</artifactId>
<version>1.0.0</version>
</dependency>
</dependencyManagement>

Child A & C:
<dependencies>
<dependency>
<groupId>something</groupId>
<artifactId>something</artifactId>
</dependency>
</dependencies>

Child B doesn't use something

Now I can change the version for something for both A and C in one place.

Basically you want this if not all your child projects use a dependency.

-Andrew

On Dec 21, 2007 11:33 AM,  <ak...@gmail.com> wrote:
> Say I have parent pom called A  and child pom called B. I specified
> <module> element for B inside A and also
> specified <parent> element for A inside B. Now I dont understand I
> would have to declare <dependencyManagement> element in A. Say if I
> have B, C, D as child modules and B, C, D all 3 depend on junit then
> can I declare junit as dependency in A using <dependencies> element
> instead <dependencyManagement> and in that B, C, D inherit that
> <dependency> instead of each B, C, D declaring the dependency. If so
> in what cases do I use <dependencyManagement>.
>
> I read the online documentation available at maven site but the
> <dependencyManagement> documentation section is not clear to me. Can
> anyone please explain <dependencyManagement> with an example.
>
> Thank you.
>
> ---------------------------------------------------------------------
> 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