升级到 Java 16 后,我无法使 ktlint gradle 插件工作。它在扔
Execution failed for task ':runKtlintCheckOverMainSourceSet'.
A failure occurred while executing org.jlleitschuh.gradle.ktlint.worker.KtLintWorkAction
java.lang.ExceptionInInitializerError (no error message)
Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':runKtlintCheckOverMainSourceSet'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$3(ExecuteActionsTaskExecuter.java:186)
at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:268)
Caused by: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing org.jlleitschuh.gradle.ktlint.worker.KtLintWorkAction
at org.gradle.workers.internal.DefaultWorkerExecutor$WorkItemExecution.waitForCompletion(DefaultWorkerExecutor.java:336)
at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForItemsAndGatherFailures(DefaultAsyncWorkTracker.java:142)
at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForItemsAndGatherFailures(DefaultAsyncWorkTracker.java:94)
...
Caused by: java.lang.ExceptionInInitializerError
at org.jetbrains.kotlin.com.intellij.pom.java.LanguageLevel.<clinit>(LanguageLevel.java:25)
at org.jetbrains.kotlin.com.intellij.core.CoreLanguageLevelProjectExtension.<init>(CoreLanguageLevelProjectExtension.java:26)
at org.jetbrains.kotlin.com.intellij.core.JavaCoreProjectEnvironment.<init>(JavaCoreProjectEnvironment.java:42)
...
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected void java.util.ResourceBundle.setParent(java.util.ResourceBundle) accessible: module java.base does not "opens java.util" to unnamed module @58f87189
at org.jetbrains.kotlin.com.intellij.util.ReflectionUtil.makeAccessible(ReflectionUtil.java:252)
at org.jetbrains.kotlin.com.intellij.util.ReflectionUtil.getDeclaredMethod(ReflectionUtil.java:269)
at org.jetbrains.kotlin.com.intellij.DynamicBundle.<clinit>(DynamicBundle.java:22)
... 32 more
我知道这是由更严格的模块检查(JEP 396)引起的,但我无法为插件设置 JVM 参数。我试过了:
- 设置环境变量
JAVA_OPTS=--illegal-access=warn
- 设置
org.gradle.jvmargs=--illegal-access=warn -Dkotlin.daemon.jvm.options=--illegal-access=warn
_gradle.properties
但是这两种尝试都没有帮助,我没有想法。