私はGradleのタスク(例えばディレクトリ内のすべてのファイルを印刷します。)で、コマンドラインからいくつかのコマンドを実行したいで動作しない:それは仕事だGradleでは、タスクの種類:Execの - コマンドラインonLast
task dir(type: Exec) {
def adbCommand = ["dir", "*.*"]
commandLine adbCommand
standardOutput = new ByteArrayOutputStream()
doLast {
println ("result = " + standardOutput)
}
}
を。 OK。私はそれが動作していないonLast
セクションの上に置いたとき、しかし:
task dir(type: Exec) {
doLast {
def adbCommand = ["dir", "*.*"]
commandLine adbCommand
standardOutput = new ByteArrayOutputStream()
println ("result = " + standardOutput)
}
}
私はエラーを取得する:
FAILURE:例外で失敗しましたビルドを。
実行は、タスクに失敗しました ':アプリ:DIR' 何が悪かったのか
- 。
execCommand == null!
[Gradle、commandLine 'cmd'、 '/ c'、 'echo doLast!'何もしない](http://stackoverflow.com/questions/42055620/gradle-commandline-cmd-c-echo-dolast-does-nothing) – sm4