【发布时间】:2017-02-14 18:02:44
【问题描述】:
我想在 gradle 任务中从命令行执行一些命令(例如打印目录中的所有文件):
task dir(type: Exec) {
def adbCommand = ["dir", "*.*"]
commandLine adbCommand
standardOutput = new ByteArrayOutputStream()
doLast {
println ("result = " + standardOutput)
}
}
这是工作。好的。但是当我把它放在onLast 部分时它不起作用:
task dir(type: Exec) {
doLast {
def adbCommand = ["dir", "*.*"]
commandLine adbCommand
standardOutput = new ByteArrayOutputStream()
println ("result = " + standardOutput)
}
}
我得到错误:
FAILURE:构建失败并出现异常。
- 出了什么问题:
任务 ':app:dir' 执行失败。
execCommand == null!
【问题讨论】:
-
这能回答你的问题吗? Gradle exec task with doLast fails
标签: gradle