diff --git a/README.md b/README.md index a4fd037ce8824..73221b5fd90ff 100644 --- a/README.md +++ b/README.md @@ -159,7 +159,7 @@ Please note for this to work you should create/update user maven settings (typic xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd"> - ... + ... ... diff --git a/build.gradle b/build.gradle index b589525dff501..290f3d1498346 100644 --- a/build.gradle +++ b/build.gradle @@ -187,6 +187,7 @@ subprojects { apply plugin: 'checkstyle' apply plugin: "com.github.spotbugs" apply plugin: 'org.gradle.test-retry' + apply plugin: 'com.diffplug.spotless' // We use the shadow plugin for the jmh-benchmarks module and the `-all` jar can get pretty large, so // don't publish it @@ -611,6 +612,26 @@ subprojects { } } + spotless { + java { + importOrder('kafka', 'org.apache.kafka', 'com', 'net', 'org', 'java', 'javax', '', '\\#') + + // auto-format specified modules only; the list of auto-format modules will be updated incrementally. + if ([].contains(project.name)) { + target 'src/**/*.java' + } else { + target = project.files([]) + } + + eclipse('4.13.0').configFile("$rootDir/eclipse-formatter.xml") + indentWithSpaces() + trimTrailingWhitespace() + removeUnusedImports() + + licenseHeaderFile file("$rootDir/checkstyle/java.header") + } + } + checkstyle { configFile = new File(rootDir, "checkstyle/checkstyle.xml") configProperties = checkstyleConfigProperties("import-control.xml") @@ -622,6 +643,9 @@ subprojects { description = 'Run checkstyle on all main Java sources' } + checkstyleMain.dependsOn('spotlessApply') + checkstyleTest.dependsOn('spotlessApply') + configure(checkstyleTest) { group = 'Verification' description = 'Run checkstyle on all test Java sources' diff --git a/checkstyle/checkstyle.xml b/checkstyle/checkstyle.xml index 7f912dc428a15..fe6cde0e2ba4a 100644 --- a/checkstyle/checkstyle.xml +++ b/checkstyle/checkstyle.xml @@ -34,6 +34,13 @@ + + + + + + + diff --git a/checkstyle/suppressions.xml b/checkstyle/suppressions.xml index 538feca238cb0..40e2e8419b549 100644 --- a/checkstyle/suppressions.xml +++ b/checkstyle/suppressions.xml @@ -19,9 +19,15 @@ files="(FieldSpec|MessageDataGenerator).java"/> - - - + + + + + @@ -81,8 +87,10 @@ - + + @@ -135,7 +143,12 @@ - + + + + @@ -150,6 +163,10 @@ + + + @@ -182,13 +199,12 @@ + + - - - @@ -226,10 +242,18 @@ files="TopologyTestDriver.java"/> + + + + + + + + + + + - + - + + + + + + + - diff --git a/eclipse-formatter.xml b/eclipse-formatter.xml new file mode 100644 index 0000000000000..df5fd356b9247 --- /dev/null +++ b/eclipse-formatter.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file