Task 'apkcopy' not found in root project
来源:7-9 gradle执行外部命令实战

周康武
2018-11-20
执行gradlew apkcopy 命令的结果
FAILURE: Build failed with an exception.
* What went wrong:
Task 'apkcopy' not found in root project 'CongBao'.
* Try:
Run gradlew tasks to get a list of available tasks. Run with --stacktrace opt
ion to get the stack trace. Run with --info or --debug option to get more log
output. Run with --scan to get full insights.
为什么?
1回答
-
周康武
提问者
2018-11-20
```
task('apkcopy'){
doLast {
def sourcePath = this.buildDir.path + '/outputs/apk'
def destination = 'E:/私人文档/youbaoProject/'
def command = "mv -f ${sourcePath} ${destination}"
exec {//执行外部命令
try {
executable 'bash'
args '-c', command
println 'the command is execute success'
} catch (GradleException e) {
println 'the command is execute failed'
}
}
}
}```
把 task(name: 'apkcopy') 改成 task('apkcopy') 可以执行,但是报下面这个错误
```
* What went wrong:
Execution failed for task ':app:apkcopy'.
> A problem occurred starting process 'command 'bash''
```
请问是不是 win 平台下不能执行“mv” 命令?
042021-10-04
相似问题