Skip to content

Commit cda8eff

Browse files
author
Vincent Potucek
committed
[rewrite] Add GradleBestPractices
Signed-off-by: Vincent Potucek <vpotucek@me.com>
1 parent 6b5c08a commit cda8eff

File tree

18 files changed

+137
-35
lines changed

18 files changed

+137
-35
lines changed

.github/workflows/precommit.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Gradle Precommit
1+
name: Gradle PreCommit
22
on: [pull_request]
33

44
jobs:
@@ -21,8 +21,11 @@ jobs:
2121
java-version: ${{ matrix.java }}
2222
distribution: temurin
2323
cache: gradle
24-
- name: Run Gradle (precommit)
24+
- name: Run Gradle (pre-commit)
2525
continue-on-error: ${{ matrix.experimental }}
2626
shell: bash
27-
run: |
28-
./gradlew javadoc precommit --parallel
27+
run: ./gradlew javadoc precommit --parallel
28+
- name: Run Gradle (sanity-check)
29+
continue-on-error: ${{ matrix.experimental }}
30+
shell: bash
31+
run: ./gradlew rewriteDryRun -Dorg.gradle.jvmargs=-Xmx8G

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
2020
- Add build-tooling to run in FIPS environment ([#18921](https://github.com/opensearch-project/OpenSearch/pull/18921))
2121
- Add SMILE/CBOR/YAML document format support to Bulk GRPC endpoint ([#19744](https://github.com/opensearch-project/OpenSearch/pull/19744))
2222
- Implement GRPC ConstantScoreQuery, FuzzyQuery, MatchBoolPrefixQuery, MatchPhrasePrefix, PrefixQuery, MatchQuery ([#19854](https://github.com/opensearch-project/OpenSearch/pull/19854))
23+
- [rewrite] Add `GradleBestPractices` ([#19885](https://github.com/opensearch-project/OpenSearch/pull/19885))
2324

2425
### Changed
2526
- Faster `terms` query creation for `keyword` field with index and docValues enabled ([#19350](https://github.com/opensearch-project/OpenSearch/pull/19350))

build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ plugins {
5959
id "org.gradle.test-retry" version "1.6.2" apply false
6060
id "test-report-aggregation"
6161
id 'jacoco-report-aggregation'
62+
id 'org.openrewrite.rewrite' version '7.19.0' apply false
6263
}
6364

6465
apply from: 'gradle/build-complete.gradle'
@@ -70,6 +71,7 @@ apply from: 'gradle/local-distribution.gradle'
7071
apply from: 'gradle/run.gradle'
7172
apply from: 'gradle/missing-javadoc.gradle'
7273
apply from: 'gradle/code-coverage.gradle'
74+
apply from: 'gradle/rewrite.gradle'
7375

7476
// Apply FIPS configuration to all projects
7577
allprojects {

distribution/archives/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* under the License.
2929
*/
3030

31-
import org.opensearch.gradle.JavaPackageType
31+
import org.opensearch.gradle.JavaPackageType
3232

3333
apply plugin: 'opensearch.internal-distribution-archive-setup'
3434

@@ -193,7 +193,7 @@ distribution_archives {
193193
}
194194
}
195195

196-
196+
197197
linuxPpc64leTar {
198198
archiveClassifier = 'linux-ppc64le'
199199
content {

gradle/rewrite.gradle

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
project.apply plugin: 'org.openrewrite.rewrite'
10+
11+
rewrite {
12+
activeRecipe('org.opensearch.openrewrite.SanityCheck')
13+
exclusion('**ActionListener.java')
14+
exclusion('**SearchAfterIT.java')
15+
exclusion('**StarTreeMapper.java')
16+
exclusion('**package-info.java')
17+
setExportDatatables(true)
18+
setFailOnDryRunResults(true)
19+
}
20+
21+
dependencies {
22+
rewrite(platform('org.openrewrite.recipe:rewrite-recipe-bom:3.17.0'))
23+
rewrite('org.openrewrite.recipe:rewrite-migrate-java:3.20.0')
24+
rewrite('org.openrewrite.recipe:rewrite-java-security:3.19.2')
25+
rewrite('org.openrewrite.recipe:rewrite-rewrite:0.14.1')
26+
rewrite('org.openrewrite.recipe:rewrite-static-analysis:2.20.0')
27+
rewrite('org.openrewrite.recipe:rewrite-third-party:0.30.0')
28+
}

gradle/wrapper/gradle-wrapper.jar

1.83 KB
Binary file not shown.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME
77
zipStorePath=wrapper/dists
8-
distributionSha256Sum=16f2b95838c1ddcf7242b1c39e7bbbb43c842f1f1a1a0dc4959b6d4d68abcac3
8+
distributionSha256Sum=df67a32e86e3276d011735facb1535f64d0d88df84fa87521e90becc2d735444

gradlew

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
#
4-
# Copyright © 2015-2021 the original authors.
4+
# Copyright © 2015 the original authors.
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.
@@ -202,7 +202,7 @@ fi
202202

203203

204204
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
205-
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
205+
DEFAULT_JVM_OPTS=
206206

207207
# Collect all arguments for the java command:
208208
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,

gradlew.bat

100644100755
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ set APP_HOME=%DIRNAME%
3636
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
3737

3838
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39-
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
39+
set DEFAULT_JVM_OPTS=
4040

4141
@rem Find java.exe
4242
if defined JAVA_HOME goto findJavaFromJavaHome
@@ -70,11 +70,10 @@ goto fail
7070
:execute
7171
@rem Setup the command line
7272

73-
set CLASSPATH=
7473

7574

7675
@rem Execute Gradle
77-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
76+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
7877

7978
:end
8079
@rem End local scope for the variables with windows NT shell

modules/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ configure(subprojects.findAll { it.parent.path == project.path }) {
3232
group = 'org.opensearch.plugin' // for modules which publish client jars
3333
apply plugin: 'opensearch.testclusters'
3434
apply plugin: 'opensearch.opensearchplugin'
35-
35+
3636
opensearchplugin {
3737
// for local OpenSearch plugins, the name of the plugin is the same as the directory
3838
name = project.name

0 commit comments

Comments
 (0)