Refactoring and Building a multi-module project

My project now contains well over 10 modules so ability to refactor them (in an integrated manner); as well as building has become crucial.

Each of my modules is a maven module, tracked by git.

In my previous projects I used git’s submodule and also a subtree; but wasn’t quite satisfied with how it worked; primarily since git is not really designed as a dependency management tool (that what maven is for).

My current setup which has been working for me quite well is as following.  I created an aggregator project super-proj1 that aggregates all of the modules in pom (ref):



Note that all of my projects (even the super project are at the same level); and not the subdirectories of super-project1:


This offers a number of benefits:

  • I can easily add another super-project2 without needing to change any of the directory structure
  • using git with all of the modules being in a separate directories is simpler

The super-project1 is tracked by git; so I can easily get test any of the releases.  The only inconvenience is that when releasing a project I need to change versions of any of the modules that have changed since the last release (which is probably a good thing to do anyways).

Importantly, I am using IntelliJ which works effortlessly with maven projects.  It can read my aggregating pom; and automatically create links to all of the modules; this allows for easy refactoring.  Building is simple too; by building the aggregating (root) project all of the modules that belong to it will also be build (and tested, etc.); and you can also do these operations for each individual module; and this is all from the same window; and with no need to configure a project whatsoever (tip of the hat to IntelliJ).


keywords: submodules artifacts module milti project subtree submodule git maven integration deployment


About Neil Rubens

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *