If these library sources are not in the maven repository, you can follow " Using Git Submodules for Maven Artifacts Out of Center ".
Git submodules are great for linking a repo repository version to another.
Here is a version adapted to your setup:
You configure the Maven project to the parent pom and your own L1 project as the Maven module of this project.
You import the project you want into your project. For example, the L2 project in the right tag .
git submodule add /url/to/L2.git cd L2 git checkout <L2-vy.x> cd .. git add . git commit -m "Add submodule L2 at <L2-vy.x>" git push
The git submodule will now clone the L2 repository in a folder named L2.
Git will add a .gitmodule file that looks like this:
submodule ["L2"] path = L2 url = / url / to / L2.git
The directory structure should look like this
yourParentProject - pom.xml - .git - .gitmodule - L1 \- pom.xml - L2 \- pom.xml
- In the parent pom.xml, you add the L2 folder as a module.
<modules> <module>L1</module> <module>L2</module> </modules>
And in your L1 project, you add L2 as a dependency:
<groupId>com.github.user.L2</groupId> <artifactId>L2</artifactId> <version>L2-vy.x</version>
- Now everything is set up. If you call
mvm test in the parent project, you will see that it builds L2 first, and then your L1 project.
Using
When other developers clone your project, they also need to install the module using the Git command:
git submodule update
source share