Benny Bottema
Benny Bottema

Reputation: 11513

How to split up git repo and apply Maven submodules and Maven parent?

I need some advice on how to configure multiple repo's such that they share a Maven parent and also are configured as submodules in a Maven root project.

I'm maintaining open source project Simple Java Mail and as there are optional functions that are becoming larger and larger, I'm planning to split the project up into sub-modules each in there own GIT repo.

  1. My first concern is that there should be a shared Maven parent config that handles all default test and build config as well as default test and utility dependencies. That is one extra repo I can think of.
  2. Next, to easily build and release everything together with the same version numbers, I thought having a Maven submodules setup would be useful. How can I set this up in GIT repo's? My first thought would be another repo for the main/root Maven project which defines the submodules, then checkout this and all other repo's in the same folder and the main Maven project would find the module projects with ..\submodule-xyz relative folders.

I have configured a similar setup before, but that was all in a single repository (in the good old Subversion days). Can anyone please advise on how to approach this best with split up repo's? Preferably I would have one repo for the parent pom and the main/root pom (is that common?). Is it preferable to combine with git submodules?

Upvotes: 5

Views: 9875

Answers (1)

VonC
VonC

Reputation: 1330082

The term module is a bit overloaded here.

Yes, you can define in one repo a parent pom, declaring a multi-module maven project, each module referring to a subfolder.

Those subfolders can be created through git submodule add command, referencing each a remote repository where the sub-project is versioned.
The subfolders are relative to the root folder of the parent directory, but should not need ../.

Each submodule repo can have its own pom.xml, which would reference the main project pom as a parent pom.

Upvotes: 10

Related Questions