From 227a9576e6bad5e7ff6a929065769d2b974edd8e Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Mon, 27 May 2024 18:15:28 +0800 Subject: [PATCH 01/20] update hide file --- .gitignore | 1 + .idea/codeStyles/Project.xml | 0 .idea/codeStyles/codeStyleConfig.xml | 7 +++++++ checkstyle/checkstyle.xml | 8 ++++++++ checkstyle/suppressions.xml | 3 +++ 5 files changed, 19 insertions(+) create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/codeStyles/codeStyleConfig.xml diff --git a/.gitignore b/.gitignore index 7dfe61c38cccf..0f007df3ba7b8 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ project/boot/ project/plugins/project/ patch-process/* .idea +!/.idea/codeStyles .svn .classpath /.metadata diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000000000..be4d81b73fd7d --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,7 @@ + + + + + diff --git a/checkstyle/checkstyle.xml b/checkstyle/checkstyle.xml index aff659638928b..f7f9705cb1f57 100644 --- a/checkstyle/checkstyle.xml +++ b/checkstyle/checkstyle.xml @@ -82,6 +82,14 @@ + + + + + + + + diff --git a/checkstyle/suppressions.xml b/checkstyle/suppressions.xml index a317fa558c10f..6103197ae5e06 100644 --- a/checkstyle/suppressions.xml +++ b/checkstyle/suppressions.xml @@ -361,4 +361,7 @@ + + + From 7596c2de769f87e694e285c1b799e07b19f5d87b Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Mon, 27 May 2024 23:05:29 +0800 Subject: [PATCH 02/20] add Project.xml --- .idea/codeStyles/Project.xml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index e69de29bb2d1d..601a11f182cde 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,28 @@ + + + + + From 00ad230f84a4a3af18a47ff39d9229b14fc4c62a Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Tue, 28 May 2024 10:16:05 +0800 Subject: [PATCH 03/20] upload Project.xml --- .idea/codeStyles/Project.xml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index 601a11f182cde..b52756dbf00be 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -1,5 +1,6 @@ + + From 2d6b289b7b067891126a42f78702a25d78706112 Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Tue, 28 May 2024 11:11:33 +0800 Subject: [PATCH 04/20] update suppressions.xml --- checkstyle/suppressions.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checkstyle/suppressions.xml b/checkstyle/suppressions.xml index 6103197ae5e06..ca17407cedda6 100644 --- a/checkstyle/suppressions.xml +++ b/checkstyle/suppressions.xml @@ -362,6 +362,6 @@ files="(ReplicaFetcherThreadBenchmark).java"/> - + From e9db586df5f3897e94b3ec24e3239eeaf81dbdd8 Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Wed, 29 May 2024 22:13:20 +0800 Subject: [PATCH 05/20] Delete .idea directory --- .idea/codeStyles/Project.xml | 58 ---------------------------- .idea/codeStyles/codeStyleConfig.xml | 7 ---- 2 files changed, 65 deletions(-) delete mode 100644 .idea/codeStyles/Project.xml delete mode 100644 .idea/codeStyles/codeStyleConfig.xml diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml deleted file mode 100644 index b52756dbf00be..0000000000000 --- a/.idea/codeStyles/Project.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml deleted file mode 100644 index be4d81b73fd7d..0000000000000 --- a/.idea/codeStyles/codeStyleConfig.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - From 37cc47329e5832453764c7ce7b264bcb750c646a Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Wed, 29 May 2024 22:20:50 +0800 Subject: [PATCH 06/20] revert gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 0f007df3ba7b8..7dfe61c38cccf 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,6 @@ project/boot/ project/plugins/project/ patch-process/* .idea -!/.idea/codeStyles .svn .classpath /.metadata From 2960a41e003303b0362eddd0a530903a1a41969f Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Thu, 30 May 2024 11:19:46 +0800 Subject: [PATCH 07/20] add spotless --- build.gradle | 23 +++++++++++++++++++++-- gradle.properties | 2 ++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 8d9326d9bc833..a2eda4844cb4e 100644 --- a/build.gradle +++ b/build.gradle @@ -47,7 +47,7 @@ plugins { // Updating the shadow plugin version to 8.1.1 causes issue with signing and publishing the shadowed // artifacts - see https://github.com/johnrengelman/shadow/issues/901 id 'com.github.johnrengelman.shadow' version '8.1.0' apply false - id 'com.diffplug.spotless' version '6.14.0' apply false // 6.14.1 and newer require Java 11 at compile time, so we can't upgrade until AK 4.0 + id 'com.diffplug.spotless' version "${spotlessVersion}" apply false } ext { @@ -196,6 +196,8 @@ def determineCommitId() { } } +def spotlessApplyModules = [''] + apply from: file('wrapper.gradle') if (repo != null) { @@ -787,6 +789,12 @@ subprojects { skipProjects = [ ":jmh-benchmarks", ":trogdor" ] skipConfigurations = [ "zinc" ] } + + afterEvaluate { + if (project.name in spotlessApplyModules) { + configureSpotless(project) + } + } } gradle.taskGraph.whenReady { taskGraph -> @@ -846,6 +854,17 @@ def connectPkgs = [ 'connect:mirror-client' ] +def configureSpotless = { project -> + project.apply plugin: 'com.diffplug.spotless' + + project.spotless { + java { + importOrder('kafka', 'org.apache.kafka', 'com', 'net', 'org', 'java', 'javax', '', '\\#') + removeUnusedImports() + } + } +} + tasks.create(name: "jarConnect", dependsOn: connectPkgs.collect { it + ":jar" }) {} tasks.create(name: "testConnect", dependsOn: connectPkgs.collect { it + ":test" }) {} @@ -1007,7 +1026,7 @@ project(':core') { testImplementation libs.junitJupiter testImplementation libs.slf4jlog4j testImplementation libs.caffeine - + generator project(':generator') } diff --git a/gradle.properties b/gradle.properties index e1809d04723a4..ed5165a9e7ce3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -28,6 +28,8 @@ scalaVersion=2.13.14 # Adding swaggerVersion in gradle.properties to have a single version in place for swagger # New version of Swagger 2.2.14 requires minimum JDK 11. swaggerVersion=2.2.8 +# 6.14.0 and newer are need for java 11 +spotlessVersion=6.13.0 task=build org.gradle.jvmargs=-Xmx2g -Xss4m -XX:+UseParallelGC org.gradle.parallel=true From 7cde3f80f85d30384b11b22fb7bb39832a8a64ca Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Thu, 30 May 2024 11:29:46 +0800 Subject: [PATCH 08/20] update build.gradle --- build.gradle | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/build.gradle b/build.gradle index a2eda4844cb4e..18a2dfd828370 100644 --- a/build.gradle +++ b/build.gradle @@ -198,6 +198,17 @@ def determineCommitId() { def spotlessApplyModules = [''] +def configureSpotless = { project -> + project.apply plugin: 'com.diffplug.spotless' + + project.spotless { + java { + importOrder('kafka', 'org.apache.kafka', 'com', 'net', 'org', 'java', 'javax', '', '\\#') + removeUnusedImports() + } + } +} + apply from: file('wrapper.gradle') if (repo != null) { @@ -854,17 +865,6 @@ def connectPkgs = [ 'connect:mirror-client' ] -def configureSpotless = { project -> - project.apply plugin: 'com.diffplug.spotless' - - project.spotless { - java { - importOrder('kafka', 'org.apache.kafka', 'com', 'net', 'org', 'java', 'javax', '', '\\#') - removeUnusedImports() - } - } -} - tasks.create(name: "jarConnect", dependsOn: connectPkgs.collect { it + ":jar" }) {} tasks.create(name: "testConnect", dependsOn: connectPkgs.collect { it + ":test" }) {} From 82de188368abb875b51ff3f2ee8fd3eb2dbc8aa2 Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Fri, 31 May 2024 10:10:38 +0800 Subject: [PATCH 09/20] revert blank From 5623a3b17884fe6b9cbcade3f3d6a299d7ef20e0 Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Fri, 31 May 2024 10:43:49 +0800 Subject: [PATCH 10/20] change the build.gradle --- build.gradle | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/build.gradle b/build.gradle index 18a2dfd828370..26879456e8ae2 100644 --- a/build.gradle +++ b/build.gradle @@ -198,16 +198,6 @@ def determineCommitId() { def spotlessApplyModules = [''] -def configureSpotless = { project -> - project.apply plugin: 'com.diffplug.spotless' - - project.spotless { - java { - importOrder('kafka', 'org.apache.kafka', 'com', 'net', 'org', 'java', 'javax', '', '\\#') - removeUnusedImports() - } - } -} apply from: file('wrapper.gradle') @@ -801,9 +791,13 @@ subprojects { skipConfigurations = [ "zinc" ] } - afterEvaluate { - if (project.name in spotlessApplyModules) { - configureSpotless(project) + if (project.name in spotlessApplyModules) { + apply plugin: 'com.diffplug.spotless' + spotless { + java { + importOrder('kafka', 'org.apache.kafka', 'com', 'net', 'org', 'java', 'javax', '', '\\#') + removeUnusedImports() + } } } } @@ -1026,7 +1020,7 @@ project(':core') { testImplementation libs.junitJupiter testImplementation libs.slf4jlog4j testImplementation libs.caffeine - + generator project(':generator') } From 3cb353dab465ed8517d8f358089dbe0ac94fbf1e Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Fri, 31 May 2024 10:57:04 +0800 Subject: [PATCH 11/20] update README --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 27ce0dc0bce64..7549c4fd1f3d6 100644 --- a/README.md +++ b/README.md @@ -232,6 +232,12 @@ You can run checkstyle using: The checkstyle warnings will be found in `reports/checkstyle/reports/main.html` and `reports/checkstyle/reports/test.html` files in the subproject build directories. They are also printed to the console. The build will fail if Checkstyle fails. +#### Spotless #### +This plugin can review code by rules,it is disabled by default. You can enable it by setting `build.gradle` add a module name into the `spotlessApplyModules` variable like +`def spotlessApplyModules = ['core']`,then you can run spotless using: + + ./gradlew spotlessApply` + #### Spotbugs #### Spotbugs uses static analysis to look for bugs in the code. You can run spotbugs using: From c3abfc2666294e5757890e29feaabe77b3f666d2 Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Sat, 1 Jun 2024 19:53:45 +0800 Subject: [PATCH 12/20] update checkstyle --- build.gradle | 5 +++-- checkstyle/checkstyle.xml | 10 +++------- checkstyle/suppressions.xml | 3 --- gradle.properties | 2 -- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/build.gradle b/build.gradle index 77dac591f38fa..7b51a89efd87e 100644 --- a/build.gradle +++ b/build.gradle @@ -46,8 +46,9 @@ plugins { id 'org.scoverage' version '8.0.3' apply false // Updating the shadow plugin version to 8.1.1 causes issue with signing and publishing the shadowed // artifacts - see https://github.com/johnrengelman/shadow/issues/901 + // 6.14.0 and newer are need for java 11 id 'com.github.johnrengelman.shadow' version '8.1.0' apply false - id 'com.diffplug.spotless' version "${spotlessVersion}" apply false + id 'com.diffplug.spotless' version "6.13.0" apply false } ext { @@ -1026,7 +1027,7 @@ project(':core') { testImplementation libs.junitJupiter testImplementation libs.slf4jlog4j testImplementation libs.caffeine - + generator project(':generator') } diff --git a/checkstyle/checkstyle.xml b/checkstyle/checkstyle.xml index f7f9705cb1f57..700640d9c2ccd 100644 --- a/checkstyle/checkstyle.xml +++ b/checkstyle/checkstyle.xml @@ -82,13 +82,9 @@ - - - - - - - + diff --git a/checkstyle/suppressions.xml b/checkstyle/suppressions.xml index 086cd6cf19434..fc6995dadfe7e 100644 --- a/checkstyle/suppressions.xml +++ b/checkstyle/suppressions.xml @@ -363,7 +363,4 @@ - - - diff --git a/gradle.properties b/gradle.properties index 8eabfc0091953..88d63be550942 100644 --- a/gradle.properties +++ b/gradle.properties @@ -28,8 +28,6 @@ scalaVersion=2.13.14 # Adding swaggerVersion in gradle.properties to have a single version in place for swagger # New version of Swagger 2.2.14 requires minimum JDK 11. swaggerVersion=2.2.8 -# 6.14.0 and newer are need for java 11 -spotlessVersion=6.13.0 task=build org.gradle.jvmargs=-Xmx2g -Xss4m -XX:+UseParallelGC org.gradle.parallel=true From 462625dab750d23354db19d99794419c163ec6bd Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Sat, 1 Jun 2024 23:06:22 +0800 Subject: [PATCH 13/20] update readme --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7549c4fd1f3d6..1f92ad3ec99d3 100644 --- a/README.md +++ b/README.md @@ -227,16 +227,15 @@ There are two code quality analysis tools that we regularly run, spotbugs and ch Checkstyle enforces a consistent coding style in Kafka. You can run checkstyle using: - ./gradlew checkstyleMain checkstyleTest + ./gradlew checkstyleMain checkstyleTest spotlessCheck The checkstyle warnings will be found in `reports/checkstyle/reports/main.html` and `reports/checkstyle/reports/test.html` files in the subproject build directories. They are also printed to the console. The build will fail if Checkstyle fails. #### Spotless #### -This plugin can review code by rules,it is disabled by default. You can enable it by setting `build.gradle` add a module name into the `spotlessApplyModules` variable like -`def spotlessApplyModules = ['core']`,then you can run spotless using: +This plugin can review code by rules and can also help you check the code , it is disabled by default. Some of our code reviews use `spotless` instead of `checkstyle`: - ./gradlew spotlessApply` + ./gradlew spotlessApply #### Spotbugs #### Spotbugs uses static analysis to look for bugs in the code. From 6f25e4d6acb3e772c538c08f421e472b01cb16d1 Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Sat, 1 Jun 2024 23:08:08 +0800 Subject: [PATCH 14/20] update build.gradle --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 7b51a89efd87e..88802929963d1 100644 --- a/build.gradle +++ b/build.gradle @@ -46,8 +46,8 @@ plugins { id 'org.scoverage' version '8.0.3' apply false // Updating the shadow plugin version to 8.1.1 causes issue with signing and publishing the shadowed // artifacts - see https://github.com/johnrengelman/shadow/issues/901 - // 6.14.0 and newer are need for java 11 id 'com.github.johnrengelman.shadow' version '8.1.0' apply false + // 6.14.0 and newer are need for java 11 id 'com.diffplug.spotless' version "6.13.0" apply false } From 7d99f0526253cc28aadfc723219c1af601f8ea0d Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Sat, 1 Jun 2024 23:10:48 +0800 Subject: [PATCH 15/20] update build.gradle --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 88802929963d1..081aefe782f9e 100644 --- a/build.gradle +++ b/build.gradle @@ -1027,7 +1027,7 @@ project(':core') { testImplementation libs.junitJupiter testImplementation libs.slf4jlog4j testImplementation libs.caffeine - + generator project(':generator') } From d956ba3981a3ed4188bbfe07e302923c8998980b Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Sun, 2 Jun 2024 10:01:10 +0800 Subject: [PATCH 16/20] update checkstyle.xml --- checkstyle/checkstyle.xml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/checkstyle/checkstyle.xml b/checkstyle/checkstyle.xml index 700640d9c2ccd..064bb35035301 100644 --- a/checkstyle/checkstyle.xml +++ b/checkstyle/checkstyle.xml @@ -82,9 +82,7 @@ - + From 9f316a93c9817a9c2c5f81f2b3c31d67d8816e3f Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Sun, 2 Jun 2024 16:00:51 +0800 Subject: [PATCH 17/20] update build.gradle --- build.gradle | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 081aefe782f9e..b74e03cc12c5d 100644 --- a/build.gradle +++ b/build.gradle @@ -47,7 +47,8 @@ plugins { // Updating the shadow plugin version to 8.1.1 causes issue with signing and publishing the shadowed // artifacts - see https://github.com/johnrengelman/shadow/issues/901 id 'com.github.johnrengelman.shadow' version '8.1.0' apply false - // 6.14.0 and newer are need for java 11 + // the minimum required JRE of 6.14.0+ is 11 + // refer:https://github.com/diffplug/spotless/tree/main/plugin-gradle#requirements id 'com.diffplug.spotless' version "6.13.0" apply false } @@ -1027,7 +1028,7 @@ project(':core') { testImplementation libs.junitJupiter testImplementation libs.slf4jlog4j testImplementation libs.caffeine - + generator project(':generator') } From 5e08003f6d5579be17cf8fe8eac4962cb5ca691f Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Sun, 2 Jun 2024 16:03:06 +0800 Subject: [PATCH 18/20] revert build.gradle --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index b74e03cc12c5d..a2a6531d29a62 100644 --- a/build.gradle +++ b/build.gradle @@ -1028,7 +1028,7 @@ project(':core') { testImplementation libs.junitJupiter testImplementation libs.slf4jlog4j testImplementation libs.caffeine - + generator project(':generator') } From 3702bb1b60ffabab41287dcdf1868934d8bb0626 Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Sun, 2 Jun 2024 16:04:46 +0800 Subject: [PATCH 19/20] lowercase --- checkstyle/checkstyle.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checkstyle/checkstyle.xml b/checkstyle/checkstyle.xml index 064bb35035301..61eb7e4b245fd 100644 --- a/checkstyle/checkstyle.xml +++ b/checkstyle/checkstyle.xml @@ -82,7 +82,7 @@ - + From 54277f3e450582ab471d09aa88aaa426d07dd60d Mon Sep 17 00:00:00 2001 From: gongxuanzhang Date: Sun, 2 Jun 2024 21:22:22 +0800 Subject: [PATCH 20/20] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1f92ad3ec99d3..ab7dcd7685bde 100644 --- a/README.md +++ b/README.md @@ -233,7 +233,7 @@ The checkstyle warnings will be found in `reports/checkstyle/reports/main.html` subproject build directories. They are also printed to the console. The build will fail if Checkstyle fails. #### Spotless #### -This plugin can review code by rules and can also help you check the code , it is disabled by default. Some of our code reviews use `spotless` instead of `checkstyle`: +The import order is a part of static check. please call `spotlessApply` to optimize the imports of Java codes before filing pull request : ./gradlew spotlessApply