Skip to content

Commit

Permalink
Java: Shadow protobuf dependency (#2931)
Browse files Browse the repository at this point in the history
* Shadow protobuf

Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
  • Loading branch information
Yury-Fridlyand authored Jan 17, 2025
1 parent 1dbe4c1 commit 65667f4
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 19 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/ort.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
11 changes: 4 additions & 7 deletions java/benchmarks/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ subprojects {
// finalizedBy jacocoTestReport, jacocoTestCoverageVerification
}

ext.failedTests = []
ext {
defaultReleaseVersion = "255.255.255"
failedTests = []
}

tasks.withType(Test) {
afterTest { TestDescriptor descriptor, TestResult result ->
Expand Down
43 changes: 34 additions & 9 deletions java/client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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')
Expand All @@ -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'
Expand Down Expand Up @@ -193,6 +209,10 @@ publishing {
}
}

tasks.withType(GenerateModuleMetadata) {
dependsOn jar, shadowJar
}

java {
modularity.inferModulePath = true
withSourcesJar()
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions java/integTest/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 65667f4

Please sign in to comment.