From ccf9192eb41ba82a47867674fe7d77a584999010 Mon Sep 17 00:00:00 2001 From: Yury-Fridlyand Date: Wed, 17 Jul 2024 10:13:26 -0700 Subject: [PATCH] Signed-off-by: Yury-Fridlyand --- .github/workflows/java-cd.yml | 19 ++++--------------- .github/workflows/java.yml | 14 +++++--------- java/client/build.gradle | 35 ++++++++++++++++++++++++++++------- java/examples/build.gradle | 3 ++- 4 files changed, 39 insertions(+), 32 deletions(-) diff --git a/.github/workflows/java-cd.yml b/.github/workflows/java-cd.yml index 5faad09b85..0859892b45 100644 --- a/.github/workflows/java-cd.yml +++ b/.github/workflows/java-cd.yml @@ -56,26 +56,21 @@ jobs: OS: ubuntu, RUNNER: ubuntu-latest, TARGET: x86_64-unknown-linux-gnu, - CLASSIFIER: linux-x86_64 } - { OS: ubuntu, RUNNER: ["self-hosted", "Linux", "ARM64"], TARGET: aarch64-unknown-linux-gnu, - CLASSIFIER: linux-aarch_64, - CONTAINER: "2_28" } - { OS: macos, RUNNER: macos-12, TARGET: x86_64-apple-darwin, - CLASSIFIER: osx-x86_64 } - { OS: macos, RUNNER: macos-latest, TARGET: aarch64-apple-darwin, - CLASSIFIER: osx-aarch_64 } runs-on: ${{ matrix.host.RUNNER }} @@ -139,18 +134,12 @@ jobs: env: SECRING_GPG: ${{ secrets.SECRING_GPG }} - - name: Replace placeholders and version in build.gradle - shell: bash - working-directory: ./java/client - run: | - SED_FOR_MACOS=`if [[ "${{ matrix.host.os }}" =~ .*"macos".* ]]; then echo "''"; fi` - sed -i $SED_FOR_MACOS 's/placeholder/${{ matrix.host.CLASSIFIER }}/g' build.gradle - sed -i $SED_FOR_MACOS "s/255.255.255/${{ env.RELEASE_VERSION }}/g" build.gradle - - name: Build java client working-directory: java run: | ./gradlew :client:publishToMavenLocal -Psigning.secretKeyRingFile=secring.gpg -Psigning.password="${{ secrets.GPG_PASSWORD }}" -Psigning.keyId=${{ secrets.GPG_KEY_ID }} + env: + GLIDE_RELEASE_VERSION: ${{ env.RELEASE_VERSION }} - name: Bundle JAR working-directory: java @@ -160,7 +149,7 @@ jobs: jar -cvf bundle.jar * ls -ltr cd - - cp $src_folder/bundle.jar . + cp $src_folder/bundle.jar bundle-${{ matrix.host.TARGET }}.jar - name: Upload artifacts to publish continue-on-error: true @@ -168,4 +157,4 @@ jobs: with: name: java-${{ matrix.host.TARGET }} path: | - java/bundle.jar + java/bundle*.jar diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml index dd8a7fc4af..c2ee5a56b3 100644 --- a/.github/workflows/java.yml +++ b/.github/workflows/java.yml @@ -95,7 +95,7 @@ jobs: - name: Build java client working-directory: java - run: ./gradlew --continue build + run: ./gradlew --continue build -x javadoc - name: Ensure no skipped files by linter working-directory: java @@ -163,22 +163,18 @@ jobs: - name: Install Java run: | - yum install -y java-${{ matrix.java }} + yum install -y java-${{ matrix.java }}-amazon-corretto-devel.x86_64 - - name: Build rust part + - name: Build java wrapper working-directory: java - run: cargo build --release - - - name: Build java part - working-directory: java - run: ./gradlew --continue build + run: ./gradlew --continue build -x javadoc - name: Upload test & spotbugs reports if: always() continue-on-error: true uses: actions/upload-artifact@v4 with: - name: test-reports-${{ matrix.java }} + name: test-reports-${{ matrix.java }}-amazon-linux path: | java/client/build/reports/** java/integTest/build/reports/** diff --git a/java/client/build.gradle b/java/client/build.gradle index 526dff0b06..0178f311ea 100644 --- a/java/client/build.gradle +++ b/java/client/build.gradle @@ -4,7 +4,9 @@ plugins { id 'java-library' id 'maven-publish' id 'signing' - id ("com.github.spotbugs") version "6.0.18" + id 'io.freefair.lombok' version '8.6' + id 'com.github.spotbugs' version '6.0.18' + id 'com.google.osdetector' version '1.7.3' } repositories { @@ -156,7 +158,11 @@ tasks.register('copyNativeLib', Copy) { into sourceSets.main.output.resourcesDir } +def defaultReleaseVersion = "255.255.255"; + +delombok.dependsOn('compileJava') jar.dependsOn('copyNativeLib') +javadoc.dependsOn('copyNativeLib') copyNativeLib.dependsOn('buildRustRelease') compileTestJava.dependsOn('copyNativeLib') test.dependsOn('buildRust') @@ -183,8 +189,7 @@ publishing { from components.java groupId = 'io.valkey' artifactId = 'valkey-glide' - // version is replaced during released workflow java-cd.yml - version = "255.255.255" + version = System.getenv("GLIDE_RELEASE_VERSION") ?: defaultReleaseVersion; pom { name = 'valkey-glide' description = 'General Language Independent Driver for the Enterprise (GLIDE) for Valkey' @@ -217,8 +222,15 @@ publishing { } java { + modularity.inferModulePath = true withSourcesJar() -// withJavadocJar() + withJavadocJar() +} + +tasks.withType(Sign) { + def releaseVersion = System.getenv("GLIDE_RELEASE_VERSION") ?: defaultReleaseVersion; + def isReleaseVersion = !releaseVersion.endsWith("SNAPSHOT") && releaseVersion != defaultReleaseVersion; + onlyIf("isReleaseVersion is set") { isReleaseVersion } } signing { @@ -236,9 +248,7 @@ tasks.withType(Test) { } jar { - archiveBaseName = "valkey-glide" - // placeholder will be renamed by platform+arch on the release workflow java-cd.yml - archiveClassifier = "placeholder" + archiveClassifier = osdetector.classifier } sourcesJar { @@ -247,6 +257,17 @@ sourcesJar { duplicatesStrategy = DuplicatesStrategy.EXCLUDE } +delombok { + modulePath = classpath +} + +javadoc { + dependsOn delombok + source = delombok.outputs + options.tags = [ "example:a:Example:" ] + failOnError = false // TODO fix all javadoc errors and warnings and remove that +} + spotbugsMain { reports { html { diff --git a/java/examples/build.gradle b/java/examples/build.gradle index 71e358a7a4..ac8f60f547 100644 --- a/java/examples/build.gradle +++ b/java/examples/build.gradle @@ -11,7 +11,8 @@ repositories { } dependencies { - implementation project(':client') + implementation "io.valkey:valkey-glide:1.0.1:${osdetector.classifier}" + implementation 'redis.clients:jedis:4.4.3' implementation 'io.lettuce:lettuce-core:6.2.6.RELEASE' implementation 'commons-cli:commons-cli:1.5.0'