Maven Multi module tutorial

In this tutorial we will show how to use Maven multi-module projects using as sample a remote EJB client application.

The mechanism in Maven that handles multi-module projects is referred to as the reactor. This part of the Maven core does the following:

  •  Collects all the available modules to build
  •  Sorts the projects into the correct build order
  •  Builds the selected projects in order

A multi-module project is defined by a parent POM referencing one or more submodules. In root directory, you will find the parent POM (also called the top-level POM). In the subfolder you will find all the submodules used by the project.

maven multimodule maven tutorial jboss

Here's a simple top-level Project pom.xml

<project xmlns="" xmlns:xsi=""

    <name>JBoss AS Quickstarts: Parent for remote EJB and Java client</name>

            <name>Apache License, Version 2.0</name>






Notice that the parent defines a set of Maven coordinates: the groupId is com.sample, the artifactId is simple-parent . The parent project doesn’t create a JAR or a WAR; instead, it is simply a POM that refers to other Maven projects. The appropriate packaging for a project like simple-parent that simply provides a Project Object Model is pom.

The next section in the pom.xml lists the project’s submodules:


These modules are defined in the modules element, and each module element corresponds to a subdirectory beneath your top level pom.xml. Maven knows to look in these directories for pom.xml files, and it will add submodules to the list of Maven projects included in a build.

Lastly, we define some settings which will be inherited by all submodules. The setting we want to export is the which will be used both by the server and the client application. You can add here as well common dependencies and POM inheritance will export these dependencies to all submodules.

Follow us on Twitter