Gradle 忽略守护进程忽略标志
Gradle ignores daemon ignore flag
我 运行 Gradle 3.2.1
在安装了 brew install gradle
的 MacOS X 10.12.1 上,我自己没有设置任何环境变量等,尝试使用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 版本生成守护线程(即使有 false
选项)来完成的,但失败了。如果我显然将 JVM args 传递给构建,也会发生同样的情况。
解决方案是在终端 export JAVA_HOME=~/jdk-9.jdk/Contents/Home
中设置 JAVA_HOME 而只是 运行 gradle build
.
仍然不起作用,因为最新的 Java9 构建破坏了 Gradle 的反射,但这是另一回事。
我在这里发布这个是因为它的评论太大了(但肯定不是答案)。
如果您 运行 您的脚本带有 --debug,您将看到潜在的错误。我直接通过 java-9 运行 宁此,而没有设置 JAVA_HOME 顺便说一句。
我在几个 jdk-9 构建后遇到了同样的问题并解决了它:
set _JAVA_OPTIONS "-Dsun.reflect.debugModuleAccessChecks=true
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.util=ALL-UNNAMED
--add-opens=java.base/java.lang.invoke=ALL-UNNAMED
--add-opens=java.base/java.io=ALL-UNNAMED
--add-opens=java.base/java.util.concurrent=ALL-UNNAMED
--add-opens=java.base/java.text=ALL-UNNAMED"
set 而不是 export 因为我使用的是鱼,但应该以相同的方式为 bash 工作。
有趣的是,构建 153 仍然失败:
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Map java.util.Collections$UnmodifiableMap.m accessible: module java.base does not "opens java.util" to unnamed module @67080771
但那是在 _JAVA_OPTIONS 中指定的。这可能是对 build 153 的回归。
我 运行 Gradle 3.2.1
在安装了 brew install gradle
的 MacOS X 10.12.1 上,我自己没有设置任何环境变量等,尝试使用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 版本生成守护线程(即使有 false
选项)来完成的,但失败了。如果我显然将 JVM args 传递给构建,也会发生同样的情况。
解决方案是在终端 export JAVA_HOME=~/jdk-9.jdk/Contents/Home
中设置 JAVA_HOME 而只是 运行 gradle build
.
仍然不起作用,因为最新的 Java9 构建破坏了 Gradle 的反射,但这是另一回事。
我在这里发布这个是因为它的评论太大了(但肯定不是答案)。
如果您 运行 您的脚本带有 --debug,您将看到潜在的错误。我直接通过 java-9 运行 宁此,而没有设置 JAVA_HOME 顺便说一句。
我在几个 jdk-9 构建后遇到了同样的问题并解决了它:
set _JAVA_OPTIONS "-Dsun.reflect.debugModuleAccessChecks=true
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.util=ALL-UNNAMED
--add-opens=java.base/java.lang.invoke=ALL-UNNAMED
--add-opens=java.base/java.io=ALL-UNNAMED
--add-opens=java.base/java.util.concurrent=ALL-UNNAMED
--add-opens=java.base/java.text=ALL-UNNAMED"
set 而不是 export 因为我使用的是鱼,但应该以相同的方式为 bash 工作。
有趣的是,构建 153 仍然失败:
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Map java.util.Collections$UnmodifiableMap.m accessible: module java.base does not "opens java.util" to unnamed module @67080771
但那是在 _JAVA_OPTIONS 中指定的。这可能是对 build 153 的回归。