7

Sorry to ask this again. Please let me know if I got this right?

We have a parent pom and multiple modules. Now if all children projects want to inherit the same jar files (for example spring), I can put them in in the parent project pom and need not include them in the child pom.

And if I put in dependencies under in the parent pom, they are not included in all the children projects, but I can include the ones I need (for example test) by adding them in without the need to specify a version.

Is this right or am I totally off? Hope I'm clear on my q.

All I need is a giant parent pom with all dependencies. The children should get some of the common dependencies automatically and the specific ones that each child needs.

Thanks

Harish

Harry
  • 546
  • 6
  • 22
  • 50
  • possible duplicate of [differences between dependencymanagement and dependencies in maven](http://stackoverflow.com/questions/2619598/differences-between-dependencymanagement-and-dependencies-in-maven) – user902383 Feb 24 '14 at 12:05

1 Answers1

17

In dependencyManagement you declare dependency versions, exclusions and other things that let you manage them in place (e.g. a parent pom) for multiple projects.

In dependencies you then declare the actual usage/need of a dependency and if the dependency is managed in a parent pom you can do so without using a version and it will be inherited and therefore be consistant across your usages downstream of the the parent pom.

Same logic applies for pluginManagement and plugins by the way including plugin configuration.

Manfred Moser
  • 29,539
  • 13
  • 92
  • 123
  • Thanks so much for your reply. So I will create in the parent pom with versions and exclusions. Then I need to add in the parent pom that need to be inherited by all children and then create in the children for the ones that they alone need. The dependencies created under will not be inherited by any of the projects. Is that right? – Harry Jun 25 '13 at 14:57
  • Still not very clear: In the parent pom under I have listed all the dependencies with exclusions, version, etc. Then under in the parent I have listed some dependencies that would be used for all projects (like logging). So the other dependencies under will not be included in the children, right? – Harry Jun 27 '13 at 20:51
  • Do not add dependencies in the parent. Just add them where they are actual dependencies. The depMgt will always be inherited. If you really need to manage a bunch of deps you can use the import scope but thats getting more complicated than necessary. – Manfred Moser Jun 28 '13 at 00:25