我想删除项目 makefile 并编写一些不错的 gradle 任务。 我需要按顺序执行以下任务:
- 清洁
- 增量版本
- build
- 上传
#1、#3 和#4 是来自 android 和插件 (bintray) 的任务,而#2 是自定义任务。这是我目前所拥有的:
task releaseMajor {
doLast {
clean.execute()
build.execute()
incrementVersion.execute()
bintrayUpload.execute()
}
}
运行顺序不如我认为 clean
在 build
之后运行。 binrayUpload
运行时没有任何味道 (release
)。我也尝试过使用 dependsOn
但没有成功(订单不工作)。
我在 Gradle 文档中找不到如何正确执行此操作。当从 CLI 以正确的顺序执行时,一切都完美无缺。
最佳答案
使用 mustRunAfter
或 finalizedBy
进行更精细的顺序控制:
task releaseMajor (dependsOn: ['clean', 'build', 'incrementVersion', 'bintrayUpload'])
build.mustRunAfter clean
incrementVersion.mustRunAfter build
bintrayUpload.mustRunAfter incrementVersion
关于android - 在自定义任务中执行android构建任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34638177/