Skip to content

Commit

Permalink
Update Gradle to 8.9
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
  • Loading branch information
Xtansia authored and reta committed Jul 12, 2024
1 parent f383197 commit f5185b9
Show file tree
Hide file tree
Showing 9 changed files with 1,140 additions and 955 deletions.
64 changes: 59 additions & 5 deletions .github/workflows/code-generation.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
name: Code Generation

on: [pull_request]
on:
pull_request:
workflow_dispatch:
schedule:
- cron: '0 0 * * 1' # 00:00 UTC Weekly on Mondays

jobs:
up_to_date:
name: Ensure Generated Code Up To Date
name: Ensure Generated Code Is Up To Date
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout Java Client
Expand All @@ -18,9 +23,9 @@ jobs:
cache: 'gradle'

- name: Run Code Generator
run: ./gradlew clean :java-codegen:run
run: ./gradlew :java-codegen:run

- name: Check Has No Changes
- name: Check For Uncommitted Changes
shell: bash -eo pipefail {0}
run: |
output=$(git status --porcelain)
Expand All @@ -31,4 +36,53 @@ jobs:
echo "Dirty working directory"
echo "$output"
exit 1
fi
fi
update_spec:
name: Update Specification and Re-generate Code
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'schedule' && github.repository == 'opensearch-project/opensearch-java')
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout Java Client
uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'temurin'
cache: 'gradle'

- name: Download Latest Spec && Run Code Generator
run: ./gradlew :java-codegen:downloadLatestSpec :java-codegen:run

- name: Get Current Date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT

- name: Generate GitHub App Token
if: github.repository == 'opensearch-project/opensearch-java'
id: github_app_token
uses: tibdex/github-app-token@v1.5.0
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
installation_id: 22958780

- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
token: ${{ steps.github_app_token.outputs.token || secrets.GITHUB_TOKEN }}
commit-message: Re-generate client code using latest OpenSearch API specification (${{ steps.date.outputs.date }})
title: Re-generated client code using latest OpenSearch API specification
body: |
Re-generated client code using latest OpenSearch API specification.
Date: ${{ steps.date.outputs.date }}
branch: code-gen/${{ github.ref_name }}/update
signoff: true
labels: |
autocut
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionSha256Sum=544c35d6bd849ae8a5ed0bcea39ba677dc40f49df7d1835561582da2009b961d
distributionSha256Sum=d725d707bfabd4dfdc958c624003b3c80accc03f7037b5122c4b1d0ef15cecab
7 changes: 5 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
22 changes: 12 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down Expand Up @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
11 changes: 10 additions & 1 deletion java-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import com.github.jk1.license.ProjectData
import com.github.jk1.license.render.ReportRenderer
import de.undercouch.gradle.tasks.download.Download
import java.io.FileWriter

buildscript {
Expand All @@ -32,6 +33,7 @@ plugins {
id("com.github.jk1.dependency-license-report") version "2.8"
id("org.owasp.dependencycheck") version "10.0.2"
id("com.diffplug.spotless") version "6.25.0"
id("de.undercouch.download") version "5.6.0"
}
apply(plugin = "opensearch.repositories")
apply(plugin = "org.owasp.dependencycheck")
Expand Down Expand Up @@ -66,9 +68,16 @@ application {
)
}

val localSpecification = "$projectDir/opensearch-openapi.yaml"

tasks.create<Download>("downloadLatestSpec") {
src("https://github.com/opensearch-project/opensearch-api-specification/releases/download/main-latest/opensearch-openapi.yaml")
dest(localSpecification)
}

tasks.named<JavaExec>("run") {
args = listOf(
"--input", "$projectDir/opensearch-openapi.yaml",
"--input", localSpecification,
"--eclipse-config", "$rootDir/buildSrc/formatterConfig-generated.xml",
"--output", "${project(":java-client").projectDir}/src/generated/java/"
)
Expand Down
Loading

0 comments on commit f5185b9

Please sign in to comment.