java - 管理多模块项目

标签 java git maven spring-boot jenkins

当前设置:

  1. Maven
  2. Spring 启动
  3. 角度
  4. 12个maven项目+1个Pom项目
  5. Git
  6. 詹金

目前我有 13 个单独的项目。 每次如果我必须在另一台机器上进行设置,那么我必须单独克隆每个项目。 我还为自动构建进行了 Jenkin 管道设置。

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.

我想到的解决方案:

  1. Maven 子项目
  2. 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 模块及其所有子模块。

您可以采取的一组步骤是:

  1. 使用 git submodule add [ssh 或 https 路径] 添加项目中的所有子模块,例如git子模块添加https://github.com/test
  2. 添加其他子模块并推送更改
  3. 通过运行获取子模块内容
git submodule init
 git submodule update

或者运行git clone --recurse-submodules https://github.com/chaconinc/MainProject来获取子模块

我建议您通读 this链接并确保您的要求由此得到满足。

关于java - 管理多模块项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57052536/

相关文章:

java - Java 中的 Lambda 函数会跳过元素

java - 高效提升一个目录级别的字符串切割挑战

java - 尝试获取签名的 apk 时 Android Studio 出现 "Got negative length for block"错误

git - 为什么我需要一直执行 `--set-upstream`?

Git 存储库唯一标识

java - 为嵌入式 Jetty 指定 JAR "resources/webapp"文件夹的 ResourceBase 的正确 URL 是什么?

Maven编译报错ProjectBuildingException

java - 使用 maven 生成一个包含所有依赖项的 xml 文件

git - 将 git 的 submodule.recurse 配置选项设置为 true 有什么缺点?

html - 使用 Maven 插件将 asciidoc 转换为 html5 时如何启用(自定义)警告图标