Skip to content

Commit

Permalink
Added spotless to plugins: common, core, doctest, integ-test, legacy,…
Browse files Browse the repository at this point in the history
… opensearch, plugin, ppl, protocol, sql

Signed-off-by: Mitchell Gale <[email protected]>
  • Loading branch information
MitchellGale committed Aug 22, 2023
1 parent eaa56d3 commit 4fd84ce
Show file tree
Hide file tree
Showing 11 changed files with 211 additions and 1 deletion.
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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('.') {
Expand Down
19 changes: 19 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
plugins {
id 'java-library'
id "io.freefair.lombok"
id 'com.diffplug.spotless' version '6.19.0'
}

repositories {
Expand Down Expand Up @@ -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')
}
}
20 changes: 20 additions & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
19 changes: 19 additions & 0 deletions doctest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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')
}
}
37 changes: 37 additions & 0 deletions integ-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -523,6 +524,24 @@ List<Provider<RegularFile>> 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) {
Expand Down Expand Up @@ -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"
Expand Down
19 changes: 19 additions & 0 deletions legacy/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ plugins {
id 'java'
id 'io.freefair.lombok'
id 'antlr'
id 'com.diffplug.spotless' version '6.19.0'
}

generateGrammarSource {
Expand Down Expand Up @@ -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 {
Expand Down
19 changes: 19 additions & 0 deletions opensearch/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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'
Expand Down
19 changes: 19 additions & 0 deletions plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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}"
Expand Down
19 changes: 19 additions & 0 deletions ppl/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ plugins {
id "io.freefair.lombok"
id 'jacoco'
id 'antlr'
id 'com.diffplug.spotless' version '6.19.0'
}

generateGrammarSource {
Expand Down Expand Up @@ -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"
Expand Down
21 changes: 21 additions & 0 deletions protocol/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ plugins {
id 'java'
id "io.freefair.lombok"
id 'jacoco'
id 'com.diffplug.spotless' version '6.19.0'
}

dependencies {
Expand Down Expand Up @@ -55,6 +56,8 @@ test {
}
}



jacocoTestReport {
reports {
html.enabled true
Expand All @@ -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 {
Expand Down
19 changes: 19 additions & 0 deletions sql/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ plugins {
id "io.freefair.lombok"
id 'jacoco'
id 'antlr'
id 'com.diffplug.spotless' version '6.19.0'
}

generateGrammarSource {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 4fd84ce

Please sign in to comment.