Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use git submodule with a maven submodule?

Tags:

java

git

maven

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?

like image 363
Eli Pulsifer Avatar asked Mar 28 '26 06:03

Eli Pulsifer


1 Answers

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.

like image 190
Eli Pulsifer Avatar answered Mar 29 '26 18:03

Eli Pulsifer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!