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 OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification 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
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Maven: Gettng theParent folder of ${basedir}

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers,

We have a project structure similar to the one listed below:



The requirement here is to trigger the entire build process using the pom.xml of project2. What this basically means is that we need to run a single command that builds project 2, Project1-child1 and Project1-child2.

I have tried to define modules in my parent pom.



This does not seem to work. Is there a way we can get the parent directory of teh current directory in maven.
Would really appreciate any inputs here.

Thanks
 
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The child projects should declare their parents using
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry, but I do not understand your project hierarchy (even after adding code tags!). Could you post the full paths (or relative paths starting from a common folder) for each project's pom.xml file?

Usually, for my multi-module projects, I use this structure:

workspace/master.project/pom.xml
workspace/submodule1/pom.xml
workspace/submodule2/pom.xml
etc.

This structure makes it easy to store the projects in Subversion, and also makes it easy to check out all of the projects form Subversion (I select all projects and do a check-out).

My master.project/pom.xml uses this to pull in the subprojects:



By the way, I always try to convince the developers I work with to never do this! Using a master POM in this way to sequentially rebuild modules is not always the best idea. Instead, you should be using a continuous integration server, such as Hudson, and have it manage the builds, rebuilding things as necessary. Hudson understands the Maven dependencies and will rebuild modules as required. Of course, there are times that a master/submodule pattern is the only viable alternative.
 
Brace yourself while corporate america tries to sell us its things. Some day they will chill and use tiny ads.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!