From 9c789886dc48d96cb5973d96ff6c6427dc7514c7 Mon Sep 17 00:00:00 2001 From: Mitchell Gale Date: Mon, 24 Jul 2023 11:54:12 -0700 Subject: [PATCH] Adding Spotless support framework (#1888) * Adding spotless plugin to project build.gradle. Signed-off-by: Mitchell Gale Remove commented out spotless changes. Signed-off-by: Mitchell Gale Adding Spotless to DEVELOPER_GUIDE.rst Signed-off-by: Mitchell Gale Added Google Java format to spotless. Signed-off-by: Mitchell Gale Update DEVELOPER_GUIDE.rst Co-authored-by: Yury-Fridlyand * Added apply false for spotless Signed-off-by: Mitchell Gale * Adding ratchetFrom to build.gradle Signed-off-by: Mitchell Gale * Adding license header to build.gradle for spotless. Signed-off-by: Mitchell Gale * Uncommenting all changes to build.gradle for spotless. Signed-off-by: Mitchell Gale * Commented out spotless checks. Signed-off-by: Mitchell Gale * Add specific version for java format spotless (1.17.0) Signed-off-by: Mitchell Gale --------- Signed-off-by: Mitchell Gale Co-authored-by: Yury-Fridlyand Signed-off-by: Mitchell Gale --- DEVELOPER_GUIDE.rst | 8 ++++++-- build.gradle | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/DEVELOPER_GUIDE.rst b/DEVELOPER_GUIDE.rst index 923cb459f9..257e3bb8f9 100644 --- a/DEVELOPER_GUIDE.rst +++ b/DEVELOPER_GUIDE.rst @@ -113,8 +113,8 @@ Note that missing license header will be detected by Gradle license plugin and f Making Code Changes =================== -Project Strucure ----------------- +Project Structure +----------------- The plugin codebase is in standard layout of Gradle project:: @@ -226,6 +226,10 @@ Most of the time you just need to run ./gradlew build which will make sure you p - Build plugin by run all tasks above (this takes time). * - ./gradlew pitest - Run PiTest mutation testing (see more info in `#1204 `_) + * - ./gradlew spotlessCheck + - Runs Spotless to check for code style. + * - ./gradlew spotlessApply + - Automatically apply spotless code style changes. For integration test, you can use ``-Dtests.class`` “UT full path” to run a task individually. For example ``./gradlew :integ-test:integTest -Dtests.class="*QueryIT"``. diff --git a/build.gradle b/build.gradle index d7458f722f..ff29eb7687 100644 --- a/build.gradle +++ b/build.gradle @@ -65,6 +65,7 @@ plugins { id 'checkstyle' id "io.freefair.lombok" version "6.4.0" id 'jacoco' + id 'com.diffplug.spotless' version '6.19.0' } // import versions defined in https://github.com/opensearch-project/OpenSearch/blob/main/buildSrc/src/main/java/org/opensearch/gradle/OpenSearchJavaPlugin.java#L94 @@ -79,6 +80,25 @@ 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('.') { +// include '**/*.java', 'src/*/java/**/*.java' +// exclude '**/build/**', '**/build-*/**' +// } +// importOrder() +// licenseHeader("/*\n" + +// " * Copyright OpenSearch Contributors\n" + +// " * SPDX-License-Identifier: Apache-2.0\n" + +// " */\n\n\n") +// removeUnusedImports() +// trimTrailingWhitespace() +// endWithNewline() +// googleJavaFormat('1.17.0').reflowLongStrings().groupArtifact('com.google.googlejavaformat:google-java-format') + } +} + allprojects { version = opensearch_version.tokenize('-')[0] + '.0' if (buildVersionQualifier) {