diff --git a/.github/workflows/ort.yml b/.github/workflows/ort.yml index 403560286d..d88f2287fd 100644 --- a/.github/workflows/ort.yml +++ b/.github/workflows/ort.yml @@ -158,6 +158,17 @@ jobs: distribution: "temurin" java-version: 11 + - name: Install protoc (protobuf) + uses: arduino/setup-protoc@v3 + with: + version: "29.1" + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Build java artifact + working-directory: ./java + run: | + ./gradlew publishToMavenLocal -x buildRust -x javadoc + - name: Run ORT tools for Java uses: ./.github/workflows/run-ort-tools with: diff --git a/CHANGELOG.md b/CHANGELOG.md index 98a99a17aa..299180a2a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ * Go: Add `ZCARD` ([#2838](https://github.com/valkey-io/valkey-glide/pull/2838)) * Java, Node, Python: Update documentation for CONFIG SET and CONFIG GET ([#2919](https://github.com/valkey-io/valkey-glide/pull/2919)) * Go: Add `BZPopMin` ([#2849](https://github.com/valkey-io/valkey-glide/pull/2849)) +* Java: Shadow `protobuf` dependency ([#2931](https://github.com/valkey-io/valkey-glide/pull/2931)) * Java: Add `RESP2` support ([#2383](https://github.com/valkey-io/valkey-glide/pull/2383)) * Node: Add `IFEQ` option ([#2909](https://github.com/valkey-io/valkey-glide/pull/2909)) diff --git a/java/benchmarks/build.gradle b/java/benchmarks/build.gradle index b4777ee410..f8e62ab6d7 100644 --- a/java/benchmarks/build.gradle +++ b/java/benchmarks/build.gradle @@ -7,16 +7,13 @@ plugins { repositories { // Use Maven Central for resolving dependencies. mavenCentral() + mavenLocal() } dependencies { - def releaseVersion = System.getenv("GLIDE_RELEASE_VERSION"); + version = System.getenv("GLIDE_RELEASE_VERSION") ?: project.ext.defaultReleaseVersion - if (releaseVersion) { - implementation "io.valkey:valkey-glide:" + releaseVersion + ":${osdetector.classifier}" - } else { - implementation project(':client') - } + implementation "io.valkey:valkey-glide:${version}:${osdetector.classifier}" // This dependency is used internally, and not exposed to consumers on their own compile classpath. implementation 'com.google.guava:guava:32.1.1-jre' @@ -28,7 +25,7 @@ dependencies { implementation group: 'com.google.code.gson', name: 'gson', version: '2.10.1' } -run.dependsOn ':client:buildRust' +compileJava.dependsOn ':client:publishToMavenLocal' application { // Define the main class for the application. diff --git a/java/build.gradle b/java/build.gradle index 1db21c0404..31acdb0902 100644 --- a/java/build.gradle +++ b/java/build.gradle @@ -41,7 +41,10 @@ subprojects { // finalizedBy jacocoTestReport, jacocoTestCoverageVerification } - ext.failedTests = [] + ext { + defaultReleaseVersion = "255.255.255" + failedTests = [] + } tasks.withType(Test) { afterTest { TestDescriptor descriptor, TestResult result -> diff --git a/java/client/build.gradle b/java/client/build.gradle index 7ae0d7c429..efdbd6b7f8 100644 --- a/java/client/build.gradle +++ b/java/client/build.gradle @@ -7,22 +7,27 @@ plugins { id 'io.freefair.lombok' version '8.6' id 'com.github.spotbugs' version '6.0.18' id 'com.google.osdetector' version '1.7.3' + id 'com.gradleup.shadow' version '8.3.5' } repositories { mavenCentral() } +configurations { + testImplementation { extendsFrom shadow } +} + dependencies { implementation group: 'com.google.protobuf', name: 'protobuf-java', version: '4.29.1' - implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.13.0' + shadow group: 'org.apache.commons', name: 'commons-lang3', version: '3.13.0' - implementation group: 'io.netty', name: 'netty-handler', version: '4.1.115.Final' + shadow group: 'io.netty', name: 'netty-handler', version: '4.1.115.Final' // https://github.com/netty/netty/wiki/Native-transports // At the moment, Windows is not supported - implementation group: 'io.netty', name: 'netty-transport-native-epoll', version: '4.1.115.Final', classifier: 'linux-x86_64' - implementation group: 'io.netty', name: 'netty-transport-native-epoll', version: '4.1.115.Final', classifier: 'linux-aarch_64' - implementation group: 'io.netty', name: 'netty-transport-native-kqueue', version: '4.1.115.Final', classifier: 'osx-aarch_64' + shadow group: 'io.netty', name: 'netty-transport-native-epoll', version: '4.1.115.Final', classifier: 'linux-x86_64' + shadow group: 'io.netty', name: 'netty-transport-native-epoll', version: '4.1.115.Final', classifier: 'linux-aarch_64' + shadow group: 'io.netty', name: 'netty-transport-native-kqueue', version: '4.1.115.Final', classifier: 'osx-aarch_64' // junit testImplementation group: 'org.mockito', name: 'mockito-inline', version: '3.12.4' @@ -130,8 +135,6 @@ tasks.register('copyNativeLib', Copy) { into sourceSets.main.output.resourcesDir } -def defaultReleaseVersion = "255.255.255"; - delombok.dependsOn('compileJava') jar.dependsOn('copyNativeLib') javadoc.dependsOn('copyNativeLib') @@ -155,13 +158,26 @@ sourceSets { } } +task javadocJar(type: Jar, dependsOn: javadoc) { + archiveClassifier = 'javadoc' + from javadoc.destinationDir +} + +task sourcesJar(type: Jar, dependsOn: classes) { + archiveClassifier = 'sources' + from sourceSets.main.allSource + exclude 'glide/models' // exclude protobuf files +} + publishing { publications { mavenJava(MavenPublication) { - from components.java + from components.shadow + artifact javadocJar + artifact sourcesJar groupId = 'io.valkey' artifactId = 'valkey-glide' - version = System.getenv("GLIDE_RELEASE_VERSION") ?: defaultReleaseVersion; + version = System.getenv("GLIDE_RELEASE_VERSION") ?: project.ext.defaultReleaseVersion pom { name = 'valkey-glide' description = 'General Language Independent Driver for the Enterprise (GLIDE) for Valkey' @@ -193,6 +209,10 @@ publishing { } } +tasks.withType(GenerateModuleMetadata) { + dependsOn jar, shadowJar +} + java { modularity.inferModulePath = true withSourcesJar() @@ -223,6 +243,11 @@ jar { archiveClassifier = osdetector.classifier } +shadowJar { + dependsOn('copyNativeLib') + archiveClassifier = osdetector.classifier +} + sourcesJar { // suppress following error // Entry glide/api/BaseClient.java is a duplicate but no duplicate handling strategy has been set diff --git a/java/integTest/build.gradle b/java/integTest/build.gradle index 8ebd7f272e..ebe42ce072 100644 --- a/java/integTest/build.gradle +++ b/java/integTest/build.gradle @@ -1,14 +1,16 @@ plugins { id 'java-library' + id "com.google.osdetector" version "1.7.3" } repositories { mavenCentral() + mavenLocal() } dependencies { // client - implementation project(':client') + implementation group: 'io.valkey', name: 'valkey-glide', version: project.ext.defaultReleaseVersion, classifier: osdetector.classifier implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.13.0' implementation 'com.google.code.gson:gson:2.10.1' @@ -129,7 +131,7 @@ clearDirs.finalizedBy 'startStandalone' clearDirs.finalizedBy 'startCluster' clearDirs.finalizedBy 'startClusterForAz' test.finalizedBy 'stopAllAfterTests' -test.dependsOn ':client:buildRust' +compileTestJava.dependsOn ':client:publishToMavenLocal' tasks.withType(Test) { doFirst {