Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java: Shadow protobuf dependency #2931

Merged
merged 12 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how come shadowing java bindings has an effect on ORT third party tool?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed IT to use the generated module instead of client sources. Without these changes, ORT tool was failing:

02:36:38.314 [DefaultDispatcher-worker-2] ERROR org.ossreviewtoolkit.plugins.packagemanagers.gradleinspector.GradleInspector - Could not find io.valkey:valkey-glide:255.255.255.
Searched in the following locations:
  - https://repo.maven.apache.org/maven2/io/valkey/valkey-glide/255.255.255/valkey-glide-255.255.255.pom
  - file:/home/runner/.m2/repository/io/valkey/valkey-glide/255.255.255/valkey-glide-255.255.255.pom from project :integTest.
02:36:38.322 [DefaultDispatcher-worker-2] ERROR org.ossreviewtoolkit.plugins.packagemanagers.gradleinspector.GradleInspector - Could not find io.valkey:valkey-glide:255.255.255 from project :integTest.

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
Loading