1
我要执行从gradle这个任务的命令行命令的一些(e.g打印目录中的所有文件):摇篮,任务类型:执行 - 命令行不行在onLast
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)
}
}
我得到错误:
失败:建立失败,一个例外。
- 出了什么问题:
执行失败的任务 ':应用程序:目录'。
execCommand == null!
可能重复[Gradle,commandLine'cmd','/ c','echo doLast!'什么都不做](http://stackoverflow.com/questions/42055620/gradle-commandline-cmd-c-echo-dolast-does-nothing) – sm4