Multi-Module development with Maven

I switched from Ant to Maven some time ago because it is easy to setup a project with Maven. Ok, I had my common Ant scripts, so it was also easy 🙂 . But when it comes to projects with a multi-module structure then Maven can be a really good or evil friend. Currently I’m working in a multi-module project with more than ten modules. And sometimes Maven makes life not easier.

The question about structuring the project came up very often. But in the end the solution can be nice and easy. It really only depends on what is written in which POM file. The first thing is to use a sibling module for the overall root POM which defines all dependencies and project settings. This module is created once and has everytime a fixed version number. In the root of the project there can be a POM file only defining the modules for people doing building the overall project.

Inside the module there can also again be modules. Then inside the module there should also be a child sub-module which defines the dependencies and project settings and a base POM file in the root containing only the modules element. The POM files in the sub-modules of a module don’t use the POM file of the module, but instead the POM file from the sibling sub-module with all dependencies and project settings. Also the version number of the module is defined only there.


Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

Du kommentierst mit Deinem Abmelden /  Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden /  Ändern )


Du kommentierst mit Deinem Twitter-Konto. Abmelden /  Ändern )


Du kommentierst mit Deinem Facebook-Konto. Abmelden /  Ändern )


Verbinde mit %s