From 4fd84ce451ca583895ba21a4a49c0ed9c2c6b970 Mon Sep 17 00:00:00 2001 From: Mitchell Gale Date: Tue, 22 Aug 2023 08:40:13 -0700 Subject: [PATCH] Added spotless to plugins: common, core, doctest, integ-test, legacy, opensearch, plugin, ppl, protocol, sql Signed-off-by: Mitchell Gale --- build.gradle | 1 - common/build.gradle | 19 +++++++++++++++++++ core/build.gradle | 20 ++++++++++++++++++++ doctest/build.gradle | 19 +++++++++++++++++++ integ-test/build.gradle | 37 +++++++++++++++++++++++++++++++++++++ legacy/build.gradle | 19 +++++++++++++++++++ opensearch/build.gradle | 19 +++++++++++++++++++ plugin/build.gradle | 19 +++++++++++++++++++ ppl/build.gradle | 19 +++++++++++++++++++ protocol/build.gradle | 21 +++++++++++++++++++++ sql/build.gradle | 19 +++++++++++++++++++ 11 files changed, 211 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index fb8f77d63a..ebe9291e23 100644 --- a/build.gradle +++ b/build.gradle @@ -79,7 +79,6 @@ repositories { maven { url 'https://jitpack.io' } } -// Spotless checks will be added as PRs are applied to resolve each style issue is approved. spotless { java { target fileTree('.') { diff --git a/common/build.gradle b/common/build.gradle index 904181726d..a01a3fa13f 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -25,6 +25,7 @@ plugins { id 'java-library' id "io.freefair.lombok" + id 'com.diffplug.spotless' version '6.19.0' } repositories { @@ -63,3 +64,21 @@ configurations.all { resolutionStrategy.force "joda-time:joda-time:2.10.12" resolutionStrategy.force "org.slf4j:slf4j-api:1.7.36" } + +spotless { + java { + target fileTree('.') { + include '**/*.java' + exclude '**/build/**', '**/build-*/**' + } + importOrder() +// licenseHeader("/*\n" + +// " * Copyright OpenSearch Contributors\n" + +// " * SPDX-License-Identifier: Apache-2.0\n" + +// " */\n\n") + removeUnusedImports() + trimTrailingWhitespace() + endWithNewline() + googleJavaFormat('1.17.0').reflowLongStrings().groupArtifact('com.google.googlejavaformat:google-java-format') + } +} diff --git a/core/build.gradle b/core/build.gradle index 8205638138..675e73ba32 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -28,6 +28,8 @@ plugins { id 'jacoco' id 'info.solidsoft.pitest' version '1.9.0' id 'java-test-fixtures' + id 'com.diffplug.spotless' version '6.19.0' + } repositories { @@ -61,6 +63,24 @@ dependencies { testImplementation group: 'org.mockito', name: 'mockito-junit-jupiter', version: '3.12.4' } +spotless { + java { + target fileTree('.') { + include '**/*.java' + exclude '**/build/**', '**/build-*/**' + } + importOrder() +// licenseHeader("/*\n" + +// " * Copyright OpenSearch Contributors\n" + +// " * SPDX-License-Identifier: Apache-2.0\n" + +// " */\n\n") + removeUnusedImports() + trimTrailingWhitespace() + endWithNewline() + googleJavaFormat('1.17.0').reflowLongStrings().groupArtifact('com.google.googlejavaformat:google-java-format') + } +} + test { useJUnitPlatform() testLogging { diff --git a/doctest/build.gradle b/doctest/build.gradle index c3a177f900..5cab1060e2 100644 --- a/doctest/build.gradle +++ b/doctest/build.gradle @@ -9,6 +9,7 @@ plugins { id 'base' id 'com.wiredforcode.spawn' id "de.undercouch.download" version "5.3.0" + id 'com.diffplug.spotless' version '6.19.0' } apply plugin: 'opensearch.testclusters' @@ -140,3 +141,21 @@ tasks.register("runRestTestCluster", RunTask) { description = 'Runs OpenSearch SQL plugin' useCluster testClusters.docTestCluster; } + +spotless { + java { + target fileTree('.') { + include '**/*.java' + exclude '**/build/**', '**/build-*/**' + } + importOrder() +// licenseHeader("/*\n" + +// " * Copyright OpenSearch Contributors\n" + +// " * SPDX-License-Identifier: Apache-2.0\n" + +// " */\n\n") + removeUnusedImports() + trimTrailingWhitespace() + endWithNewline() + googleJavaFormat('1.17.0').reflowLongStrings().groupArtifact('com.google.googlejavaformat:google-java-format') + } +} diff --git a/integ-test/build.gradle b/integ-test/build.gradle index b843a0380d..d9fa62e655 100644 --- a/integ-test/build.gradle +++ b/integ-test/build.gradle @@ -33,6 +33,7 @@ import java.util.stream.Collectors plugins { id "de.undercouch.download" version "5.3.0" + id 'com.diffplug.spotless' version '6.19.0' } apply plugin: 'opensearch.build' @@ -523,6 +524,24 @@ List> plugins = [ }) ] +spotless { + java { + target fileTree('.') { + include '**/*.java' + exclude '**/build/**', '**/build-*/**' + } + importOrder() +// licenseHeader("/*\n" + +// " * Copyright OpenSearch Contributors\n" + +// " * SPDX-License-Identifier: Apache-2.0\n" + +// " */\n\n") + removeUnusedImports() + trimTrailingWhitespace() + endWithNewline() + googleJavaFormat('1.17.0').reflowLongStrings().groupArtifact('com.google.googlejavaformat:google-java-format') + } +} + // Creates 2 test clusters with 3 nodes of the old version. 2.times { i -> task "${baseName}#oldVersionClusterTask$i"(type: StandaloneRestIntegTestTask) { @@ -628,6 +647,24 @@ task bwcTestSuite(type: StandaloneRestIntegTestTask) { def opensearch_tmp_dir = rootProject.file('build/private/es_tmp').absoluteFile opensearch_tmp_dir.mkdirs() +spotless { + java { + target fileTree('.') { + include '**/*.java' + exclude '**/build/**', '**/build-*/**' + } + importOrder() +// licenseHeader("/*\n" + +// " * Copyright OpenSearch Contributors\n" + +// " * SPDX-License-Identifier: Apache-2.0\n" + +// " */\n\n") + removeUnusedImports() + trimTrailingWhitespace() + endWithNewline() + googleJavaFormat('1.17.0').reflowLongStrings().groupArtifact('com.google.googlejavaformat:google-java-format') + } +} + task integTestRemote(type: RestIntegTestTask) { testLogging { events "passed", "skipped", "failed" diff --git a/legacy/build.gradle b/legacy/build.gradle index d89f7affe7..fc985989e5 100644 --- a/legacy/build.gradle +++ b/legacy/build.gradle @@ -26,6 +26,7 @@ plugins { id 'java' id 'io.freefair.lombok' id 'antlr' + id 'com.diffplug.spotless' version '6.19.0' } generateGrammarSource { @@ -53,6 +54,24 @@ compileJava { } } +spotless { + java { + target fileTree('.') { + include '**/*.java' + exclude '**/build/**', '**/build-*/**' + } + importOrder() +// licenseHeader("/*\n" + +// " * Copyright OpenSearch Contributors\n" + +// " * SPDX-License-Identifier: Apache-2.0\n" + +// " */\n\n") + removeUnusedImports() + trimTrailingWhitespace() + endWithNewline() + googleJavaFormat('1.17.0').reflowLongStrings().groupArtifact('com.google.googlejavaformat:google-java-format') + } +} + // TODO: Similarly, need to fix compiling errors in test source code compileTestJava.options.warnings = false compileTestJava { diff --git a/opensearch/build.gradle b/opensearch/build.gradle index 4095d519cb..34b5c3f452 100644 --- a/opensearch/build.gradle +++ b/opensearch/build.gradle @@ -27,6 +27,7 @@ plugins { id "io.freefair.lombok" id 'jacoco' id 'info.solidsoft.pitest' version '1.9.0' + id 'com.diffplug.spotless' version '6.19.0' } dependencies { @@ -48,6 +49,24 @@ dependencies { testImplementation group: 'org.opensearch.test', name: 'framework', version: "${opensearch_version}" } +spotless { + java { + target fileTree('.') { + include '**/*.java' + exclude '**/build/**', '**/build-*/**' + } + importOrder() +// licenseHeader("/*\n" + +// " * Copyright OpenSearch Contributors\n" + +// " * SPDX-License-Identifier: Apache-2.0\n" + +// " */\n\n") + removeUnusedImports() + trimTrailingWhitespace() + endWithNewline() + googleJavaFormat('1.17.0').reflowLongStrings().groupArtifact('com.google.googlejavaformat:google-java-format') + } +} + pitest { targetClasses = ['org.opensearch.sql.*'] pitestVersion = '1.9.0' diff --git a/plugin/build.gradle b/plugin/build.gradle index 11f97ea857..7291f78ba4 100644 --- a/plugin/build.gradle +++ b/plugin/build.gradle @@ -27,6 +27,7 @@ plugins { id "io.freefair.lombok" id 'jacoco' id 'opensearch.opensearchplugin' + id 'com.diffplug.spotless' version '6.19.0' } apply plugin: 'opensearch.pluginzip' @@ -116,6 +117,24 @@ compileTestJava { options.compilerArgs.addAll(["-processor", 'lombok.launch.AnnotationProcessorHider$AnnotationProcessor']) } +spotless { + java { + target fileTree('.') { + include '**/*.java' + exclude '**/build/**', '**/build-*/**' + } + importOrder() +// licenseHeader("/*\n" + +// " * Copyright OpenSearch Contributors\n" + +// " * SPDX-License-Identifier: Apache-2.0\n" + +// " */\n\n") + removeUnusedImports() + trimTrailingWhitespace() + endWithNewline() + googleJavaFormat('1.17.0').reflowLongStrings().groupArtifact('com.google.googlejavaformat:google-java-format') + } +} + dependencies { api "com.fasterxml.jackson.core:jackson-core:${versions.jackson}" api "com.fasterxml.jackson.core:jackson-databind:${versions.jackson_databind}" diff --git a/ppl/build.gradle b/ppl/build.gradle index 484934ddc3..a798b3f4b0 100644 --- a/ppl/build.gradle +++ b/ppl/build.gradle @@ -27,6 +27,7 @@ plugins { id "io.freefair.lombok" id 'jacoco' id 'antlr' + id 'com.diffplug.spotless' version '6.19.0' } generateGrammarSource { @@ -60,6 +61,24 @@ dependencies { testImplementation(testFixtures(project(":core"))) } +spotless { + java { + target fileTree('.') { + include '**/*.java' + exclude '**/build/**', '**/build-*/**' + } + importOrder() +// licenseHeader("/*\n" + +// " * Copyright OpenSearch Contributors\n" + +// " * SPDX-License-Identifier: Apache-2.0\n" + +// " */\n\n") + removeUnusedImports() + trimTrailingWhitespace() + endWithNewline() + googleJavaFormat('1.17.0').reflowLongStrings().groupArtifact('com.google.googlejavaformat:google-java-format') + } +} + test { testLogging { events "passed", "skipped", "failed" diff --git a/protocol/build.gradle b/protocol/build.gradle index 92a1aa0917..212f746b1d 100644 --- a/protocol/build.gradle +++ b/protocol/build.gradle @@ -26,6 +26,7 @@ plugins { id 'java' id "io.freefair.lombok" id 'jacoco' + id 'com.diffplug.spotless' version '6.19.0' } dependencies { @@ -55,6 +56,8 @@ test { } } + + jacocoTestReport { reports { html.enabled true @@ -68,6 +71,24 @@ jacocoTestReport { } test.finalizedBy(project.tasks.jacocoTestReport) +spotless { + java { + target fileTree('.') { + include '**/*.java' + exclude '**/build/**', '**/build-*/**' + } + importOrder() +// licenseHeader("/*\n" + +// " * Copyright OpenSearch Contributors\n" + +// " * SPDX-License-Identifier: Apache-2.0\n" + +// " */\n\n") + removeUnusedImports() + trimTrailingWhitespace() + endWithNewline() + googleJavaFormat('1.17.0').reflowLongStrings().groupArtifact('com.google.googlejavaformat:google-java-format') + } +} + jacocoTestCoverageVerification { violationRules { rule { diff --git a/sql/build.gradle b/sql/build.gradle index 44dc37cf0f..2984158e57 100644 --- a/sql/build.gradle +++ b/sql/build.gradle @@ -27,6 +27,7 @@ plugins { id "io.freefair.lombok" id 'jacoco' id 'antlr' + id 'com.diffplug.spotless' version '6.19.0' } generateGrammarSource { @@ -58,6 +59,24 @@ dependencies { testImplementation(testFixtures(project(":core"))) } +spotless { + java { + target fileTree('.') { + include '**/*.java' + exclude '**/build/**', '**/build-*/**' + } + importOrder() +// licenseHeader("/*\n" + +// " * Copyright OpenSearch Contributors\n" + +// " * SPDX-License-Identifier: Apache-2.0\n" + +// " */\n\n") + removeUnusedImports() + trimTrailingWhitespace() + endWithNewline() + googleJavaFormat('1.17.0').reflowLongStrings().groupArtifact('com.google.googlejavaformat:google-java-format') + } +} + test { useJUnitPlatform() testLogging {