« - »

Pulling it all together: the Maven parent project

19 May 2008

It’s always good to make things work. It’s even better when you make things work better, faster, or cheaper. It was good to finally get my Maven-generated .ear file to run successfully on WebSphere, but it was quite the pain to go through all of the steps to rebuild it each time I made change, particularly when the change was to one of the lower-level dependent projects such as one of the .jar files. Surely there had to be a better way than to have to build each project independently, one project at a time.

Fortunately, there is a better way: the Maven multi-modules project. To implement this solution, I created one more project, example-parent, with the following pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">


      <name>The Restamon</name>



Once the parent project was created, I had to go back into the pom.xml file for every one of the listed modules and add the following lines:


After all of the child projects were updated, all I needed to do was right-click on the parent project and select Run as -> Maven whatever to execute whatever Maven target that I wanted to run against the entire lot. For example, Run as -> Maven clean runs the clean process on all projects in the group and Run as -> Maven install does the same with the install process. And based on the dependencies specified in the individual projects, everything is executed in the proper sequence so that dependent projects are built first before those projects that require them.

So, now we have one more project committed to the repository:


Yes, it’s one extra project that produces no useful artifacts, but it sure makes building things a whole lot simpler. I think it’s quite an improvement, actually.


Comments are closed.

Sorry, the comment form is closed at this time.