我应该如何在单个 gradle 任务中运行执行两个 git 命令



我有两个命令来初始化和更新 git 子模块,我怎样才能一起运行它。 以下是任务。

task gitSubModuleInit(type: Exec) {
    description 'Initialize  the git submodule'
    commandLine "git", "submodule", "init"
}
task gitSubModuleUpdate(type: Exec) {
    description 'Update the git submodule'
    commandLine "git", "submodule", "update"
}

两个问题

1( 如何在单个任务中运行 git 子模块初始化和更新任务?2( 是否可以将这些任务作为构建任务的一部分链接?所以当我构建它时,它会自动更新子模块

当然:

task gitSubModuleInit(type: Exec) {
    description 'Initialize  the git submodule'
    commandLine "git", "submodule", "init"
}
task gitSubModuleUpdate(type: Exec, dependsOn: gitSubModuleInit) {
    description 'Update the git submodule'
    commandLine "git", "submodule", "update"
}
<taskThatNeeds the files, probably compileJava>.dependsOn gitSubModuleUpdate

最新更新