Gradle更新Git子模块

3
我有一个Gradle项目,它被分成了子模块。每次需要使用最新源代码构建项目时执行git submodule update --init不是很方便,因此我想知道是否已知道创建一个Gradle任务来执行此操作的方法?也许有现有的插件?Unix和Windows兼容性都很好。

回答后更新

正如@VonC所说,ajoberstar/gradle-git可以完成此工作。

以下是我最终配置的内容:

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath 'org.ajoberstar:gradle-git:1.6.0'
  }
}

apply plugin: 'org.ajoberstar.grgit'

task submodulesUpdate(type:Exec) {
  description 'Updates (and inits) git submodules'
  commandLine 'git', 'submodule', 'update', '--init', '--recursive'
  group 'Build Setup'
}

task build

build.dependsOn submodulesUpdate

// ...
1个回答

3

就像这个拉取请求中所述,您可以尝试添加一个gradle任务来为您执行子模块的初始化。
这将依赖并使用ajoberstar/gradle-git

task submodulesUpdate(type:Exec) {
    description 'Updates (and inits) git submodules'
    commandLine 'git', 'submodule', 'update', '--init', '--recursive'
    group 'Build Setup'
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接