我正在尝试从时髦的脚本运行gradle命令。文件 : 文件.groovy
def command = "gradle clean"
command.execute()
得到以下错误,
$ groovy file.groovy
Caught: java.io.IOException: Cannot run program "gradle": CreateProcess
error=2, The system cannot find the file specified
java.io.IOException: Cannot run program "gradle": CreateProcess error=2, The
system cannot find the file specified
at file.run(file.groovy:2)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot
find the file specified
... 1 more
相同的文件在MAC上运行良好。
使用 Gradle 3.0 和 Groovy 2.4.7
此外,如果直接运行 gradle clean,它会按预期工作。
仅当从Windows系统上的时髦文件调用时,才会出现问题。
在Windows cmd和cygwin上尝试过。同样的问题。
在Windows cmd和cygwin上尝试过。同样的问题。
我会说你在 gradle 安装方面有问题。只需按照说明进行操作即可
https://docs.gradle.org/current/userguide/installation.html
并注意这一点:
3.4. 环境变量
要运行 Gradle,首先添加环境变量GRADLE_HOME。 这应该指向 Gradle 网站上的解压缩文件。下一个 将 GRADLE_HOME/bin 添加到 PATH 环境变量。通常,这个 足以运行 Gradle。