Xiangdong Huang created IOTDB-3078:
--------------------------------------
Summary: Problem of using spotless plugin with JDK17
Key: IOTDB-3078
URL: https://issues.apache.org/jira/browse/IOTDB-3078
Project: Apache IoTDB
Issue Type: Task
Reporter: Xiangdong Huang
When using JDK17 to run spotless plugin, there will be errors:
{code:java}
Execution default-cli of goal
com.diffplug.spotless:spotless-maven-plugin:2.22.3:apply failed:
java.lang.reflect.InvocationTargetException: class
com.google.googlejavaformat.java.JavaInput (in unnamed module @0x7c447c76)
cannot access class com.sun.tools.javac.parser.Tokens$TokenKind (in module
jdk.compiler) because module jdk.compiler does not export
com.sun.tools.javac.parser to unnamed module @0x7c447c76 -> [Help 1]
{code}
Many solutions told us to add some arguments of JVM.
However, IT DOES NOT WORK by using maven-compiler-plugin.
It is because when we use `mvn spotless:apply`, it is not in the `compile`
lifecycle
while maven-compiler-plugin is built for the compile lifecycle....
(So, if IoTDB needs some JVM arguments when compiling IoTDB, we can use the
plugin).
Two temporary solutions (see [1]) are:
1. use `MAVEN_OPTS` environment:
{code:sh}
export MAVEN_OPTS="--add-exports
jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports
jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports
jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports
jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports
jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"
{code}
2. add a jvm.config file to .mvn folder:
{code:sh}
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
{code}
Notice that do not add those content when you are using JDK8.
Fortunately, the issue will be fixed quickly, see [1] and [2].
[1] [https://github.com/diffplug/spotless/issues/834]
[2] [https://github.com/diffplug/spotless/blob/main/plugin-maven/CHANGES.md]
--
This message was sent by Atlassian Jira
(v8.20.7#820007)