首页 > 解决方案 > 如何在 gradle 文件中的一个任务中执行多个 shell 脚本

问题描述

我是 gradle 的新手,我有一个场景,我需要在 gradle 的单个任务中执行 2 个 shell 脚本。

我尝试了以下,但它没有执行 script1.sh 任务。

task downloadtheArtifacts(type: Exec) {
    commandLine './script1.sh'
    commandLine './script2.sh'
}

请让我知道我该如何解决这个问题?

标签: javashellgradlescriptingbuild.gradle

解决方案


试试看:

task downloadtheArtifacts {
    doLast {
        exec {
            commandLine './script1.sh'
        }
        exec {
            commandLine './script2.sh'
        }
    }
}

推荐阅读