应用来自不同存储库的 gradle 文件 [英] Apply gradle file from different repository
问题描述
我们有多个用于不同项目的 git 存储库.还有一个用于基础设施目的的 git 存储库.我们在这个基础设施存储库中编写了自定义 gradle 插件,我们在其他存储库中使用了这些插件
We have multiple git repositories for different projects. There is also a git repository for infrastructure purpose. We have custom gradle plugins written in this infrastructure repository which we use in other repositories
示例:
buildscript {
apply from: 'foo/bar/devinfra-buildscript.gradle', to: buildscript
}
apply plugin: 'devinfra'
这里我们在每个 Git 存储库中都有 buildscript{} 文件 foo/bar/buildscript.gradle.我想知道是否有办法直接从基础架构存储库应用文件.这样可以直接在其他存储库中看到任何更改.
Here we are having the buildscript{} file, foo/bar/buildscript.gradle in every Git repository. I want to know if there is a way where we can apply the file directly from a infrastructure repository. So that any change is visible across other repositories directly.
推荐答案
在这种情况下,你可以添加一个 git subtree 合并(不同于 git subtree)到你的每个 repo,参考 infra repo.
In that case, you could add a git subtree Merging (different to git subtree) to each of your repo, referring to the infra repo.
git read-tree --prefix=<subdirectory_name>/ –u <shared_library_branch>
就你而言:
cd /path/to/project
git remote add infrarepo /url/to/infra/repo
git fetch infrarepo
git checkout -b infra infrarepo/master
git checkout master
git read-tree --prefix=infra/ –u infra
git commit -m "Add Infra subtree"
使用子树更改更新项目存储库:
To update the project repo with subtree changes:
git checkout infra
git pull
git checkout master
git merge --squash –s subtree –-no-commit infra
git commit -m "update infra"
使用项目存储库的子树文件夹中的更改更新子树存储库:
To update the subtree repo with change from the subtree folder of the project repo:
git checkout infra
git merge --squash –s subtree --no-commit master
git commit -m "(infra subtree) nature of changes"
git push infrarepo infra
这篇关于应用来自不同存储库的 gradle 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!