如何设置Gradle环境变量?

How to set Gradle environment variables?

我正在尝试执行 Gradle 命令行任务 -setupDecompWorkspace 来设置 Minecraft Forge,但该任务卡在了 decompileMC 上。我已经尝试了这个 issue, but it didn't work. The second solution suggest setting the GRADLE_OPTS environment variable to -Xmx2G. I don't exactly know how to do this. After searching online for a couple of hours I am still found with no answer. Even the official Gradle documentation 的第一个解决方案没有帮助。我是否需要在 gradle.properties 文件中声明变量,将其作为命令行参数输入或完全不同的东西?

-Xmx2G是一个JVM命令行参数,如果你想把它设置成Gradle属性只要把它加到gradle.properties 项目根目录中的文件:

org.gradle.jvmargs=-Xmx2G

您还可以在这里找到一些更有用的信息:https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties