我在安装了3.2.1
的MacOS X 10.12.1上运行Gradle brew install gradle
,我自己未设置任何环境变量等,试图使用Java 9 EA:
gradle build -Dorg.gradle.java.home=~/jdk-9.jdk/Contents/Home
但是构建失败了
FAILURE: Build failed with an exception.
- What went wrong: Unable to start the daemon process. This problem might be caused by incorrect configuration of the daemon. For example, an unrecognized jvm option is used.
据我所知它失败了,因为守护程序试图使用maxpermsize JVM选项(在Java 8+中不支持,但在Java 8中只是警告)。
所以我试图禁用守护程序:
mkdir -p ~/.gradle && echo "org.gradle.daemon=false" >> ~/.gradle/gradle.properties
但是
gradle build
仍在尝试启动守护程序...我在项目目录中删除了~/.gradle
和.gradle
。还有其他想法吗?$ gradle build -Dorg.gradle.daemon=false -Dorg.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/3.2.1/userguide/gradle_daemon.html.
FAILURE: Build failed with an exception.
* What went wrong:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at https://docs.gradle.org/3.2.1/userguide/gradle_daemon.html
Please read the following process output to find out more:
-----------------------
FAILURE: Build failed with an exception.
* What went wrong:
java.lang.ExceptionInInitializerError (no error message)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
> Starting Daemon%
最佳答案
好的,因为我正在运行这样的构建,所以我弄清楚了:
gradle build -Dorg.gradle.java.home=~/jdk-9.jdk/Contents/Home
Gradle必须产生一个新线程以使用与JAVA_HOME所指向的Java版本不同的Java版本。这是通过使用该Java版本生成守护程序线程(即使使用
false
选项)而完成的,并且失败了。如果我显然将JVM args传递给构建,也会发生同样的情况。解决方案是改为在终端
export JAVA_HOME=~/jdk-9.jdk/Contents/Home
中设置JAVA_HOME,然后仅运行gradle build
。仍然不起作用,因为最新的Java9构建打破了Gradle的思考,但这是另一回事。
关于java - Gradle忽略守护程序忽略标志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41929067/