You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by icet <ic...@yahoo.com.br> on 2009/04/29 19:25:46 UTC

Is there a way to exclude a inherited dependency?

Hi, I have a common POM to all my projects. This POM declares a dependency on
a common project X. The problem is that project X cannot use my common POM.

I don't think there is an easy solution, the closest I could find is to use
dependencyManagement instead of the dependency itself. But that would
increase the amount of code.

thanks
-- 
View this message in context: http://www.nabble.com/Is-there-a-way-to-exclude-a-inherited-dependency--tp23296345p23296345.html
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: Is there a way to exclude a inherited dependency?

Posted by Grant Rettke <gr...@acm.org>.
On Thu, Apr 30, 2009 at 7:53 AM, Jan Torben Heuer
<jt...@mail2004.dnsalias.org> wrote:
> I'd go another way: Create some kind of <project>-commons artifact and
> depend on it. If many artifacts share the same dependency, there is often
> more redundant code that can be refactored this way and makes the whole code
> cleaner.

This seems like a better approach than inheritance, but I don't see it
mentioned much.

Even the Sonatype book only mentions it once.

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


Re: Is there a way to exclude a inherited dependency?

Posted by Jan Torben Heuer <jt...@mail2004.dnsalias.org>.
David Hoffer wrote:

> I have a similar use case.  In a multi-module build all but two of the
> modules have the same base dependency so they are specified in the parent
> pom.  However I really don't want those dependencies in the two modules,
> so how can I exclude them?

I'd go another way: Create some kind of <project>-commons artifact and 
depend on it. If many artifacts share the same dependency, there is often 
more redundant code that can be refactored this way and makes the whole code 
cleaner.

Cheers,

Jan



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


Re: Is there a way to exclude a inherited dependency?

Posted by icet <ic...@yahoo.com.br>.
Thanks everyone for your suggestions. As I expected there is no way to do it,
its just a matter of finding the better alternative then.

For me these alternatives are not so good. Perhaps when there is a LOT of
common dependencies it makes sense to create a project for them.

The "provided" does not apply since my dependency declaration is in my
parent pom.

Right now I just rather remove my dependencies from the parent pom.


dahoffer wrote:
> 
> Okay, I think I'll move them out of the parent.
> 
> -Dave
> 
> On Wed, Apr 29, 2009 at 12:27 PM, Nick Stolwijk
> <ni...@gmail.com>wrote:
> 
>> Short of not doing it, as it is not "the right way", you can always
>> put those dependencies on provided to not include them in any final
>> artifacts. Maybe, somewhere down the line you will start experience
>> other strange behaviour, like some dependencies which should be
>> included aren't anymore.
>>
>> Ie. project A and B has the same dependency (call it X) and it is
>> marked as provided by A, but not by B. When you start having B as a
>> dependency of A, X will be marked by A as provided instead of
>> included.
>>
>> Hth,
>>
>> Nick Stolwijk
>> ~Java Developer~
>>
>> Iprofs BV.
>> Claus Sluterweg 125
>> 2012 WS Haarlem
>> www.iprofs.nl
>>
>>
>>
>> On Wed, Apr 29, 2009 at 8:13 PM, David Hoffer <dh...@gmail.com> wrote:
>> > I have a similar use case.  In a multi-module build all but two of the
>> > modules have the same base dependency so they are specified in the
>> parent
>> > pom.  However I really don't want those dependencies in the two
>> modules,
>> so
>> > how can I exclude them?
>> >
>> > (BTW, my use case is a Java project that has a couple of Flex modules,
>> > obviously Flex doesn't need the otherwise global log4j dependency.)
>> >
>> > Short of not putting any dependencies in the parent how can I exclude
>> them?
>> >
>> > -Dave
>> >
>> > On Wed, Apr 29, 2009 at 11:58 AM, Nick Stolwijk
>> <nick.stolwijk@gmail.com
>> >wrote:
>> >
>> >> > Hi, I have a common POM to all my projects.
>> >> Each project should have its own POM, with a parent pom hierarchy to
>> >> avoid duplication, declare dependencyManagement and plugin
>> >> versions/configuration.
>> >>
>> >> > The problem is that project X cannot use my common POM.
>> >> Then let it have its own POM, like each project.
>> >>
>> >> > I don't think there is an easy solution,
>> >> I don't understand your problem, maybe try to better describe the
>> >> problem with some code examples (not the whole code!)
>> >>
>> >> >the closest I could find is to use dependencyManagement instead of
>> the
>> >> dependency itself. But that > would increase the amount of code.
>> >> No, that would decrease the amount of code. You don't have to specify
>> >> the version in each POM, but only in your company pom. It is not
>> >> logical that each project has exactly the same set of dependencies.
>> >>
>> >> If you could try to explain what your current setup looks like, maybe
>> >> we could give you some pointers how to improve it.
>> >>
>> >> Hth,
>> >>
>> >> Nick Stolwijk
>> >> ~Java Developer~
>> >>
>> >> Iprofs BV.
>> >> Claus Sluterweg 125
>> >> 2012 WS Haarlem
>> >> www.iprofs.nl
>> >>
>> >>
>> >>
>> >> On Wed, Apr 29, 2009 at 7:25 PM, icet <ic...@yahoo.com.br> wrote:
>> >> > Hi, I have a common POM to all my projects.
>> >>
>> >> ---------------------------------------------------------------------
>> >> 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
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Is-there-a-way-to-exclude-a-inherited-dependency--tp23296345p23321539.html
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: Is there a way to exclude a inherited dependency?

Posted by David Hoffer <dh...@gmail.com>.
Okay, I think I'll move them out of the parent.

-Dave

On Wed, Apr 29, 2009 at 12:27 PM, Nick Stolwijk <ni...@gmail.com>wrote:

> Short of not doing it, as it is not "the right way", you can always
> put those dependencies on provided to not include them in any final
> artifacts. Maybe, somewhere down the line you will start experience
> other strange behaviour, like some dependencies which should be
> included aren't anymore.
>
> Ie. project A and B has the same dependency (call it X) and it is
> marked as provided by A, but not by B. When you start having B as a
> dependency of A, X will be marked by A as provided instead of
> included.
>
> Hth,
>
> Nick Stolwijk
> ~Java Developer~
>
> Iprofs BV.
> Claus Sluterweg 125
> 2012 WS Haarlem
> www.iprofs.nl
>
>
>
> On Wed, Apr 29, 2009 at 8:13 PM, David Hoffer <dh...@gmail.com> wrote:
> > I have a similar use case.  In a multi-module build all but two of the
> > modules have the same base dependency so they are specified in the parent
> > pom.  However I really don't want those dependencies in the two modules,
> so
> > how can I exclude them?
> >
> > (BTW, my use case is a Java project that has a couple of Flex modules,
> > obviously Flex doesn't need the otherwise global log4j dependency.)
> >
> > Short of not putting any dependencies in the parent how can I exclude
> them?
> >
> > -Dave
> >
> > On Wed, Apr 29, 2009 at 11:58 AM, Nick Stolwijk <nick.stolwijk@gmail.com
> >wrote:
> >
> >> > Hi, I have a common POM to all my projects.
> >> Each project should have its own POM, with a parent pom hierarchy to
> >> avoid duplication, declare dependencyManagement and plugin
> >> versions/configuration.
> >>
> >> > The problem is that project X cannot use my common POM.
> >> Then let it have its own POM, like each project.
> >>
> >> > I don't think there is an easy solution,
> >> I don't understand your problem, maybe try to better describe the
> >> problem with some code examples (not the whole code!)
> >>
> >> >the closest I could find is to use dependencyManagement instead of the
> >> dependency itself. But that > would increase the amount of code.
> >> No, that would decrease the amount of code. You don't have to specify
> >> the version in each POM, but only in your company pom. It is not
> >> logical that each project has exactly the same set of dependencies.
> >>
> >> If you could try to explain what your current setup looks like, maybe
> >> we could give you some pointers how to improve it.
> >>
> >> Hth,
> >>
> >> Nick Stolwijk
> >> ~Java Developer~
> >>
> >> Iprofs BV.
> >> Claus Sluterweg 125
> >> 2012 WS Haarlem
> >> www.iprofs.nl
> >>
> >>
> >>
> >> On Wed, Apr 29, 2009 at 7:25 PM, icet <ic...@yahoo.com.br> wrote:
> >> > Hi, I have a common POM to all my projects.
> >>
> >> ---------------------------------------------------------------------
> >> 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: Is there a way to exclude a inherited dependency?

Posted by Nick Stolwijk <ni...@gmail.com>.
Short of not doing it, as it is not "the right way", you can always
put those dependencies on provided to not include them in any final
artifacts. Maybe, somewhere down the line you will start experience
other strange behaviour, like some dependencies which should be
included aren't anymore.

Ie. project A and B has the same dependency (call it X) and it is
marked as provided by A, but not by B. When you start having B as a
dependency of A, X will be marked by A as provided instead of
included.

Hth,

Nick Stolwijk
~Java Developer~

Iprofs BV.
Claus Sluterweg 125
2012 WS Haarlem
www.iprofs.nl



On Wed, Apr 29, 2009 at 8:13 PM, David Hoffer <dh...@gmail.com> wrote:
> I have a similar use case.  In a multi-module build all but two of the
> modules have the same base dependency so they are specified in the parent
> pom.  However I really don't want those dependencies in the two modules, so
> how can I exclude them?
>
> (BTW, my use case is a Java project that has a couple of Flex modules,
> obviously Flex doesn't need the otherwise global log4j dependency.)
>
> Short of not putting any dependencies in the parent how can I exclude them?
>
> -Dave
>
> On Wed, Apr 29, 2009 at 11:58 AM, Nick Stolwijk <ni...@gmail.com>wrote:
>
>> > Hi, I have a common POM to all my projects.
>> Each project should have its own POM, with a parent pom hierarchy to
>> avoid duplication, declare dependencyManagement and plugin
>> versions/configuration.
>>
>> > The problem is that project X cannot use my common POM.
>> Then let it have its own POM, like each project.
>>
>> > I don't think there is an easy solution,
>> I don't understand your problem, maybe try to better describe the
>> problem with some code examples (not the whole code!)
>>
>> >the closest I could find is to use dependencyManagement instead of the
>> dependency itself. But that > would increase the amount of code.
>> No, that would decrease the amount of code. You don't have to specify
>> the version in each POM, but only in your company pom. It is not
>> logical that each project has exactly the same set of dependencies.
>>
>> If you could try to explain what your current setup looks like, maybe
>> we could give you some pointers how to improve it.
>>
>> Hth,
>>
>> Nick Stolwijk
>> ~Java Developer~
>>
>> Iprofs BV.
>> Claus Sluterweg 125
>> 2012 WS Haarlem
>> www.iprofs.nl
>>
>>
>>
>> On Wed, Apr 29, 2009 at 7:25 PM, icet <ic...@yahoo.com.br> wrote:
>> > Hi, I have a common POM to all my projects.
>>
>> ---------------------------------------------------------------------
>> 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: Is there a way to exclude a inherited dependency?

Posted by David Hoffer <dh...@gmail.com>.
I have a similar use case.  In a multi-module build all but two of the
modules have the same base dependency so they are specified in the parent
pom.  However I really don't want those dependencies in the two modules, so
how can I exclude them?

(BTW, my use case is a Java project that has a couple of Flex modules,
obviously Flex doesn't need the otherwise global log4j dependency.)

Short of not putting any dependencies in the parent how can I exclude them?

-Dave

On Wed, Apr 29, 2009 at 11:58 AM, Nick Stolwijk <ni...@gmail.com>wrote:

> > Hi, I have a common POM to all my projects.
> Each project should have its own POM, with a parent pom hierarchy to
> avoid duplication, declare dependencyManagement and plugin
> versions/configuration.
>
> > The problem is that project X cannot use my common POM.
> Then let it have its own POM, like each project.
>
> > I don't think there is an easy solution,
> I don't understand your problem, maybe try to better describe the
> problem with some code examples (not the whole code!)
>
> >the closest I could find is to use dependencyManagement instead of the
> dependency itself. But that > would increase the amount of code.
> No, that would decrease the amount of code. You don't have to specify
> the version in each POM, but only in your company pom. It is not
> logical that each project has exactly the same set of dependencies.
>
> If you could try to explain what your current setup looks like, maybe
> we could give you some pointers how to improve it.
>
> Hth,
>
> Nick Stolwijk
> ~Java Developer~
>
> Iprofs BV.
> Claus Sluterweg 125
> 2012 WS Haarlem
> www.iprofs.nl
>
>
>
> On Wed, Apr 29, 2009 at 7:25 PM, icet <ic...@yahoo.com.br> wrote:
> > Hi, I have a common POM to all my projects.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Is there a way to exclude a inherited dependency?

Posted by Nick Stolwijk <ni...@gmail.com>.
> Hi, I have a common POM to all my projects.
Each project should have its own POM, with a parent pom hierarchy to
avoid duplication, declare dependencyManagement and plugin
versions/configuration.

> The problem is that project X cannot use my common POM.
Then let it have its own POM, like each project.

> I don't think there is an easy solution,
I don't understand your problem, maybe try to better describe the
problem with some code examples (not the whole code!)

>the closest I could find is to use dependencyManagement instead of the dependency itself. But that > would increase the amount of code.
No, that would decrease the amount of code. You don't have to specify
the version in each POM, but only in your company pom. It is not
logical that each project has exactly the same set of dependencies.

If you could try to explain what your current setup looks like, maybe
we could give you some pointers how to improve it.

Hth,

Nick Stolwijk
~Java Developer~

Iprofs BV.
Claus Sluterweg 125
2012 WS Haarlem
www.iprofs.nl



On Wed, Apr 29, 2009 at 7:25 PM, icet <ic...@yahoo.com.br> wrote:
> Hi, I have a common POM to all my projects.

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