You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by hx...@apache.org on 2022/05/02 11:11:44 UTC

[iotdb] 01/01: upgrade spotless and code format version. Add instruction for spotless and JDK17.

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 92231dcdc5b306fda6b526e0162284a42fee6bb7
Author: xiangdong huang <sa...@gmail.com>
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                             |  4 ++--
 4 files changed, 46 insertions(+), 3 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..8a7748328d 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>