Gradle:如何通过gradle执行git pull?

2023-12-21

我想在编译开始之前从 git repo 中提取更改。 我找到了这个Gradle:如何在任务中克隆 git 存储库? https://stackoverflow.com/questions/13719676/gradle-how-to-clone-a-git-repo-in-a-task,但它克隆存储库而不是仅获取更改。 如果 git 服务器不在本地网络上或者存储库很大,这可能会非常耗时。

我找不到怎么办git pull使用 gradle 或gradle-git 插件 https://github.com/ajoberstar/gradle-git.


您可以创建Exec任务并运行任何 shell/cmd 命令。简单任务不需要额外的插件依赖。

task gitPull(type: Exec) {
    description 'Pulls git.'
    commandLine "git", "pull"
}

Usage: gradlew gitPull

你应该看到这样的东西:

gradlew gitPull 
Parallel execution is an incubating feature.
:app:gitPull 
Already up-to-date.

BUILD SUCCESSFUL

Total time: 9.232 secs

Where Already up-to-date.是输出git pull命令。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Gradle:如何通过gradle执行git pull? 的相关文章

随机推荐