Building All Subprojects Simultaneously

Now that you have seen how to split a project into subprojects and how to build each of them individually, let's talk about building them all at once, in the correct dependency order.

How do I do that?

The Multiproject plug-in produces a project dependency graph that allows it to execute any goal on any project under its control. The best way to use the Multiproject plug-in is to set up a master Maven project. This master project is usually set up at the top level of the project directory structure. In the case of the QOTD web application, this means creating top-level project.xml, maven.xml, and project.properties files (see Figure 3-7).

Directory structure with top-level project files (maven.xml, project.properties, and project.xml)

Figure 3-7. Directory structure with top-level project files (maven.xml, project.properties, and project.xml)

This top-level Maven project is a project like any other, except that it doesn't have any source directory. The project.xml file extends the common/project.xml file, as do the other subprojects:

<?xml version="1.0"?>
<project>
  <extend>${basedir}/common/project.xml</extend>
  <artifactId>qotd</artifactId>
  <name>QOTD</name>
  <shortDescription>Quote Of The Day Webapp</shortDescription>
  <description>
    Sample Webapp displaying a Quote Of The Day
  </description>

The Multiproject plug-in offers a multiproject:goal goal which executes the goal specified by the Maven goal property on all the subprojects it can find. ...

Get Maven: A Developer's Notebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.