Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] Adding Spotless support framework #1888 #1898

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions DEVELOPER_GUIDE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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::

Expand Down Expand Up @@ -222,6 +222,12 @@ Most of the time you just need to run ./gradlew build which will make sure you p
- Run all integration test (this takes time).
* - ./gradlew build
- Build plugin by run all tasks above (this takes time).
* - ./gradlew pitest
- Run PiTest mutation testing (see more info in `#1204 <https://github.com/opensearch-project/sql/pull/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"``.

Expand Down
20 changes: 20 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down
Loading