当前设置:
- Maven
- Spring 启动
- 角度
- 12个maven项目+1个Pom项目
- Git
- 詹金
目前我有 13 个单独的项目。 每次如果我必须在另一台机器上进行设置,那么我必须单独克隆每个项目。 我还为自动构建进行了 Jenkin 管道设置。
Looking for
- Once i clone the single pom/main project , all other project should get cloned
- If i take pull of the main project then all other projects code should get updated
Child project should get head revision every time i start the jenkin build.
Want to keep separate repo for each sub projects so that it can be reuse in other project as i have multiple requirements.
我想到的解决方案:
- Maven 子项目
- Git 子模块
上述解决方案面临的问题
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.
是否有可以解决所有问题的最佳方法。
最佳答案
您可以通过指定要从其他存储库添加哪些模块来添加 git 子模块。将在根目录上创建一个 .gitmodules
文件,其中包含所有子模块的列表以及您的其他首选项。
Creating git submodules for projects in different repositories
有一组命令可用于同步 git 模块及其所有子模块。
您可以采取的一组步骤是:
- 使用 git submodule add [ssh 或 https 路径] 添加项目中的所有子模块,例如
git子模块添加https://github.com/test
- 添加其他子模块并推送更改
- 通过运行获取子模块内容
git submodule init
git submodule update
或者运行git clone --recurse-submodules https://github.com/chaconinc/MainProject
来获取子模块
我建议您通读 this链接并确保您的要求由此得到满足。
关于java - 管理多模块项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57052536/