Gradle - 构建子项目子项目

时间:2015-12-04 12:14:32

标签: gradle

假设我有一个看起来像

的Gradle项目
RootProject
  |-- SubProject1
  |   |- SubProject1A
  |   |  `- build.gradle
  |   `- SubProject1B
  |      `- build.gradle
  |-- SubProject2
  |    |- SubProject2A
  |    |  `- build.gradle
  |    `- SubProject2B
  |       `- build.gradle
  |- gradle.build
  `- settings.gradle

是否可以在子项目中构建所有子项目?我想跑

gradle :SubProject1:build

但它没有构建子项目SubProject1ASubProject1A

我的settings.gradle看起来像

include ":SubProject1:SubProject1A"
include ":SubProject1:SubProject1B"
include ":SubProject2:SubProject2A"
include ":SubProject2:SubProject2A"

如何构建所有子项目的子项目?

1 个答案:

答案 0 :(得分:1)

我可能错了,但我相信你在SubProject1和SubProject2中也需要build.gradle

编辑:

我找到了解决方案。

在SubProject1和SubProject2中创建build.gradle,并将任务依赖项添加到SubProject1A和SubProject1B等,如下所示:

build.dependsOn ':SubProject1:SubProject1A:build', ':SubProject1:SubProject1B:build'

然后,您可以运行:SubProject1:build,它也会执行:SubProject1:SubProject1A:build:SubProject1:SubProject1B:build