我正在尝试从groovy脚本运行gradle命令。
文件:file.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系统上的groovy文件调用时才会出现问题。
在Windows cmd和cygwin上尝试过。同样的问题。
最佳答案
Tried on windows cmd as well as cygwin. Same issue.
我会说您在安装gradle时遇到问题。只要按照指示
https://docs.gradle.org/current/userguide/installation.html
并注意这一点:
3.4. Environment variables
For running Gradle, firstly add the environment variable GRADLE_HOME. This should point to the unpacked files from the Gradle website. Next add GRADLE_HOME/bin to your PATH environment variable. Usually, this is sufficient to run Gradle.
关于windows - Windows:无法从Groovy脚本执行gradle命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44228693/