This is an automated email from the ASF dual-hosted git repository.

hxd pushed a commit to branch issue-3078
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 201eacb6554a6f13626a19112708054a0282466c
Author: xiangdong huang <[email protected]>
AuthorDate: Mon May 2 19:11:25 2022 +0800

    upgrade spotless and code format version. Add instruction for spotless and 
JDK17.
---
 README.md                           | 14 ++++++++++++++
 README_ZH.md                        | 13 +++++++++++++
 docs/Development/ContributeGuide.md | 18 +++++++++++++++++-
 pom.xml                             |  7 ++++---
 4 files changed, 48 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index 928c85950c..0ccc8d0dc8 100644
--- a/README.md
+++ b/README.md
@@ -175,6 +175,20 @@ and "`antlr/target/generated-sources/antlr4`" need to be 
added to sources roots
 **In IDEA, you just need to right click on the root project name and choose 
"`Maven->Reload Project`" after 
 you run `mvn package` successfully.**
 
+#### Spotless problem
+**NOTE**: IF you are using JDK16+, you have to create a file called 
`jvm.config`,
+put it under `.mvn/`, before you use `spotless:apply`. The file contains the 
following content:
+```
+--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
+```
+
+This is [an issue of 
Spotless](https://github.com/diffplug/spotless/issues/834),
+Once the issue is fixed, we can remove this file.
+
 ### Configurations
 
 configuration files are under "conf" folder
diff --git a/README_ZH.md b/README_ZH.md
index 7831b88915..9b50c1d137 100644
--- a/README_ZH.md
+++ b/README_ZH.md
@@ -161,6 +161,19 @@ git checkout vx.x.x
 
 **IDEA的操作方法:在上述maven命令编译好后,右键项目名称,选择"`Maven->Reload project`",即可。**
 
+#### Spotless问题(JDK16+)
+**NOTE**: 如果你在使用 JDK16+, 并且要做`spotless:apply`或者`spotless:check`,
+那么需要在`.mvn/`文件夹下创建一个文件 `jvm.config`, 内容如下:
+```
+--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
+```
+这是spotless依赖的googlecodeformat的 
[问题](https://github.com/diffplug/spotless/issues/834),
+近期可能会被官方解决。
+
 ### 配置
 
 配置文件在"conf"文件夹下
diff --git a/docs/Development/ContributeGuide.md 
b/docs/Development/ContributeGuide.md
index 7fe9c54ded..1df694d9dd 100644
--- a/docs/Development/ContributeGuide.md
+++ b/docs/Development/ContributeGuide.md
@@ -102,7 +102,7 @@ We use the [Spotless
 plugin](https://github.com/diffplug/spotless/tree/main/plugin-maven) together 
with [google-java-format](https://github.com/google/google-java-format) to 
format our Java code. You can configure your IDE to automatically apply 
formatting on saving with these steps(Take idea as an example):
 
 1. Download the [google-java-format
-   plugin 
v1.7.0.5](https://plugins.jetbrains.com/plugin/8527-google-java-format/versions/stable/83169),
 it can be installed in IDEA (Preferences -> plugins -> search 
google-java-format), [More detailed setup 
manual](https://github.com/google/google-java-format#intellij-android-studio-and-other-jetbrains-ides)
+   plugin 
v1.15.0.0](https://plugins.jetbrains.com/plugin/8527-google-java-format/versions/stable/161816),
 it can be installed in IDEA (Preferences -> plugins -> search 
google-java-format), [More detailed setup 
manual](https://github.com/google/google-java-format#intellij-android-studio-and-other-jetbrains-ides)
 2. Install the plugin from disk (Plugins -> little gear icon -> "Install 
plugin from disk" -> Navigate to downloaded zip file)
 3. In the plugin settings, enable the plugin and keep the default Google code 
style (2-space indents)
 4. Remember to never update this plugin to a later version,until Spotless was 
upgraded to version 1.8+.
@@ -119,6 +119,22 @@ 
plugin](https://github.com/diffplug/spotless/tree/main/plugin-maven) together wi
    <blank line>
    import static all other imports
 ```
+8. Before you submit codes, you can use `mvn spotless:check` to check your 
codes manually,
+and use `mvn spotless:apply` to format your codes.
+
+**NOTICE (if you are using JDK16+)**: IF you are using JDK16+, you have to 
create a file called 
+`jvm.config`, put it under `.mvn/`, before you use `spotless:apply`. 
+The file contains the following content:
+```
+--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
+```
+
+This is [an issue of 
Spotless](https://github.com/diffplug/spotless/issues/834),
+Once the issue is fixed, we can remove this file.
 
 ## Code Sytle
 We use the 
[maven-checkstyle-plugin](https://checkstyle.sourceforge.io/config_filefilters.html)
 to make Java codes obey a consistent ruleset defined in 
[checkstyle.xml](https://github.com/apache/iotdb/blob/master/checkstyle.xml) 
under the project root.
diff --git a/pom.xml b/pom.xml
index 2840b10274..3e9c386c26 100644
--- a/pom.xml
+++ b/pom.xml
@@ -171,7 +171,7 @@
         <client-cpp>false</client-cpp>
         <!-- disable enforcer by default-->
         <enforcer.skip>true</enforcer.skip>
-        <spotless.version>2.4.2</spotless.version>
+        <spotless.version>2.22.3</spotless.version>
         <httpclient.version>4.5.13</httpclient.version>
         <httpcore.version>4.4.15</httpcore.version>
         <!-- for REST service -->
@@ -714,7 +714,7 @@
                     <configuration>
                         <java>
                             <googleJavaFormat>
-                                <version>1.7</version>
+                                <version>1.15.0</version>
                                 <style>GOOGLE</style>
                             </googleJavaFormat>
                             <importOrder>
@@ -1172,7 +1172,8 @@
             </activation>
             <properties>
                 <maven.compiler.release>8</maven.compiler.release>
-                <argLine>--illegal-access=permit 
--add-opens=java.base/java.util.concurrent=ALL-UNNAMED 
--add-opens=java.base/java.lang=ALL-UNNAMED 
--add-opens=java.base/java.util=ALL-UNNAMED 
--add-opens=java.base/java.nio=ALL-UNNAMED 
--add-opens=java.base/java.io=ALL-UNNAMED 
--add-opens=java.base/java.net=ALL-UNNAMED 
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED 
--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED 
--add-exports=jdk.compiler/com.sun.tools.java [...]
+                <!-- the following command does not work for fix spotless 
problem. can be deleted once the spotless problem is finally fixed.-->
+<!--                <argLine>&#45;&#45;illegal-access=permit 
&#45;&#45;add-opens=java.base/java.util.concurrent=ALL-UNNAMED 
&#45;&#45;add-opens=java.base/java.lang=ALL-UNNAMED 
&#45;&#45;add-opens=java.base/java.util=ALL-UNNAMED 
&#45;&#45;add-opens=java.base/java.nio=ALL-UNNAMED 
&#45;&#45;add-opens=java.base/java.io=ALL-UNNAMED 
&#45;&#45;add-opens=java.base/java.net=ALL-UNNAMED 
&#45;&#45;add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED 
&#45;&#45;add-exports=jdk.compiler/com.s [...]
             </properties>
         </profile>
         <!--

Reply via email to