Gradle 脚本编写问题,求大神解惑

2022-10-20 11:33:02 +08:00
 lanxiner
想用编写 gralde 脚本批量执行多个 gradle 任务,从而生成多个渠道包
例如按顺序执行以下几个任务,应该如何编写 graldle 脚本代码呢?
assembleProduction1Release
assembleProduction2Release
assembleProduction3Release
assembleProduction4Release
assembleProduction5Release
4364 次点击
所在节点    Android
5 条回复
hu8245
2022-10-20 12:01:08 +08:00
白嫖啊?直接看 groovy 语法啊
janus77
2022-10-20 14:13:33 +08:00
这不是 shell 脚本的事么,直接执行 gradlew assembleProduction1Release 这个命令啊。有几个你就执行几个。跟 gradle 脚本没关系吧
winterbells
2022-10-20 14:23:17 +08:00
直接写个脚本文件不就行了
cmd 或者 shell 里
./gradlew assemble1
XXWHCA
2022-10-20 17:32:53 +08:00
如果你的 product 就这几个,你可以直接运行./gradlew assembleRelease
如果是只需要运行着 5 个 product ,那就在后面拼接就行了,gradle 会按顺序执行的,./gradlew assembleProduction1Release assembleProduction2Release assembleProduction3Release ...
yuanxiaosong
2022-10-23 20:55:29 +08:00
task assembleProduction1Release(type: Copy) {
}
assemble.finalizedBy(assembleProduction1Release)

task assembleProduction2Release(type: Copy) {
}
assembleProduction1Release.finalizedBy(assembleProduction2Release)

……

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/888363

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX