mahesh
mahesh

Reputation: 969

Manage multi module project

Current setup:

  1. Maven
  2. Spring Boot
  3. Angular
  4. 12 maven project + 1 Pom project
  5. Git
  6. Jenkin

Currently i have separate 13 project. Every time if i have to setup on another machine then i have to clone each project individually. Also i did the Jenkin pipeline setup for auto build.

Looking for

  1. Once i clone the single pom/main project , all other project should get cloned
  2. If i take pull of the main project then all other projects code should get updated
  3. Child project should get head revision every time i start the jenkin build.

  4. Want to keep separate repo for each sub projects so that it can be reuse in other project as i have multiple requirements.

Solution that i have thought of:

  1. Maven Child projects
  2. Git Sub modules

Issues facing in above solution

 1. Maven Child projects
 --> If we are using maven child projects then we are literally copying the sub projects in pom/main project. 
In this case i cannot reuse the project. Every time i have to clone the project to use it. 
For big project with number of team member working, merging issue will come.

2. Git Sub modules
--> This is best solution for me but when we create sub module it always point to commit not the head revision.
Every time i have to manually pull the latest code  push it to parent project.
This approach we can not use in Jenkins.

Is there best approach which can resolve all the issue.

Upvotes: 1

Views: 1129

Answers (1)

Vinay Prajapati
Vinay Prajapati

Reputation: 7505

You can add git sub-modules by specifying what modules to be added from other repositories. A .gitmodules file will be created on root that will contain list of all submodules and other preferences of yours.

Creating git submodules for projects in different repositories

There are set of commands available that you can use to sync up the git module and all it's sub-modules.

Set of steps that you could take is:

  1. Add all submodules in project using git submodule add [ssh or https path] e.g. git submodule add https://github.com/test
  2. Add other submodules and push the changes
  3. Fetch submodule content by running
git submodule init
 git submodule update

or alternatively run git clone --recurse-submodules https://github.com/chaconinc/MainProject to get sub-modules as well

I would recommend that you read through this link and ensure your requirement is fulfilled by this.

Upvotes: 1

Related Questions