windows - Windows:无法从Groovy脚本执行gradle命令

标签 windows gradle groovy

我正在尝试从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/

相关文章:

Android Studio 3.1 gradle 构建抛出 java.util.zip.ZipException

gradle - 如何在执行时修改复制任务的属性?

windows - 在 bat 中处理文件

php - 在windows xp上添加mySQL包括管理工具

windows - 以编程方式将 CFF 字体转换为 OpenType 字体

java - 为什么 python 没有简单的安装命令(如 mvn install)?

grails - 在Grails中具有嵌套数组的Groovy JSONBuilder

c++ - 在 QtCreator (VS 2010) 中设置 CUDA v7.0

android - 如何在 gradle 中创建动态 url?

java - Android studio - Google 广告崩溃应用程序