从不同的存储库申请gradle文件 [英] Apply gradle file from different repository
问题描述
我们有不同项目的多个git存储库。还有一个用于基础设施目的的git存储库。我们有定制的gradle插件写在这个基础架构仓库中,我们在其他仓库中使用
示例:
buildscript {
apply from:'foo / bar / devinfra-buildscript.gradle',to:buildscript
}
apply plugin:'devinfra'
这里我们在每个Git仓库中都有buildscript文件,foo / bar / buildscript.gradle。我想知道是否有方法可以直接从基础架构存储库应用文件。所以任何改变都可以直接在其他仓库中看到。
://git-scm.com/book/en/Git-Tools-Subtree-Mergingrel =nofollow noreferrer> git subtree合并(不同于git子树)到您的每个repo,指的是 git read-tree --prefix =< subdirectory_name> / -u< shared_library_branch>
您可以在使用GIT子树合并工作流程管理嵌套库。
您的情况:
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添加Infra子树
更新带子树的项目回购:
git checkout infra
git pull
git checkout master
git merge --squash -s subtree - 不提交下载
git commit -m更新下载
使用项目回购的子树文件夹中的更改更新子树回购:
git checkout infra
git merge --squash -s subtree --no-commit master
git commit -m(infra subtree )变化的性质
git push infrarepo infra
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
Example:
buildscript {
apply from: 'foo/bar/devinfra-buildscript.gradle', to: buildscript
}
apply plugin: 'devinfra'
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.
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>
You can see a study doing that in "Managing Nested Libraries Using the GIT Subtree Merge Workflow".
In your case:
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屋!