V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
lanxiner
V2EX  ›  Android

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

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

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

    ……
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   985 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 22:41 · PVG 06:41 · LAX 15:41 · JFK 18:41
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.