Reputation: 763
Id like to share a common service between projects using git submodules. The project structure is similar to this:
contacts project
├ security module (shared, uses common security DB)
├ contacts dao module
├ contacts web module
└ contacts api module
products project
├ security module (shared, uses common security DB)
├ products dao module
├ products web module
└ products api module
accounts project
├ security module (shared, uses common security DB)
├ accounts dao module
├ accounts web module
└ accounts api module
Generally, this is a micro service architecture, each project is entirely self contained and has its on git repo. The one part that is not is the shared security DB (not my choice). I'd like to develop the shared security service once and share it with all of the microservice projects using a git submodule (versioned mapping of a separate repo as a sub folder).
The git submodule would contain a maven submodule that can be included in each multi module maven project.
My problem is the parent reference in the maven submodules pom.
<parent>
<groupId>com.org.project</groupId>
<artifactId>project-a-artifact</artifactId>
<version>1</version>
</parent>
Because the maven pom contains an explicit reference to its parent I don't see any way to accomplish what I want.
Any suggestions?
Upvotes: 3
Views: 3089
Reputation: 763
The answer is not to use maven submodules. Just create the shared service as a stand alone maven project in another git repo. Add the project as a git submodule to the target project and reference it from the parent pom and other submodules as needed.
This will set up the correct build dependencies but the shared project wont inherit anything from the parent pom.
Upvotes: 1