Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Does <dependencyManagement> install the dependencies in the project it is declared in?

 
Ranch Hand
Posts: 640
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having this pom file in one of the module of a multi-module maven project.

I want the validation-api to be included in my sample-common module only, and not in its child modules and that's why I declared it in <dependencyManagement>. But putting it this way, doesn't even include the validation-api in the sample-common. It's not even brining dependencies in this module.

What is the correct way then?
 
Saloon Keeper
Posts: 10420
223
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, <dependencyManagement> only configures dependencies, it doesn't include them.

Regardless, what you want isn't possible and doesn't make much sense. You can't use a JAR project as a parent, and declaring dependencies in a POM project doesn't make sense of you don't want to include them in child modules.
 
Puspender Tanwar
Ranch Hand
Posts: 640
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:No, <dependencyManagement> only configures dependencies, it doesn't include them.

Regardless, what you want isn't possible and doesn't make much sense. You can't use a JAR project as a parent, and declaring dependencies in a POM project doesn't make sense of you don't want to include them in child modules.



actually it's a multi module maven project.

sample-common contains some common classes/operations to the other two modules.
sample-persistence contains Database entities other other persistence related stuff.
sample-rest contains the Controllers and other stuff for creating REST API.

These all three modules are <packaging>pom</packaging>

The dependency I use in sample-common, I don't want them to include in the other two modules. How do I achieve this?
 
Stephan van Hulst
Saloon Keeper
Posts: 10420
223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are those three sub-modules POM projects?
 
Puspender Tanwar
Ranch Hand
Posts: 640
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Why are those three sub-modules POM projects?


Sorry, typo it was. All those three are jar projects
 
Stephan van Hulst
Saloon Keeper
Posts: 10420
223
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If they're JARs they can't have children so you don't have to worry about inheritance. Just declare the dependencies in the <dependencies> element and be done with it.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!