Abh*_*hik 2 android gradle gradlew build.gradle android-gradle-plugin
我正在写一个gradle任务。它调用的任务为成功运行返回 3 而不是 3。我该怎么做?
task copyToBuildShare(){
def robocopySourceDir = "build\\outputs\\apk"
def cmd = "robocopy "+ robocopySourceDir + " C:\\TEST *.* /MIR /R:5 2>&1"
exec {
ignoreExitValue = true
workingDir '.'
commandLine "cmd", "/c", cmd
if (execResult.exitValue == 3) {
println("It probably succeeded")
}
}
}
Run Code Online (Sandbox Code Playgroud)
它给出了错误:
在任务上找不到属性“execResult”
我不想创建单独的任务。我希望它在 exec 块中。我究竟做错了什么?
project.exec() 有一个类型为 ExecResult 的返回值。
def result = exec {
ignoreExitValue true
executable "cmd"
args = ["/c", "exit", "1"]
}
println "exit value:"+result.getExitValue()
Run Code Online (Sandbox Code Playgroud)
参考这里:
| 归档时间: |
|
| 查看次数: |
2889 次 |
| 最近记录: |