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: Modularize wrapper #81

Merged
merged 10 commits into from
Apr 5, 2024
2 changes: 1 addition & 1 deletion .github/workflows/install-shared-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ runs:
- name: Install protoc (protobuf)
uses: arduino/setup-protoc@v3
with:
version: "25.1"
version: "26.1"
repo-token: ${{ inputs.github-token }}
27 changes: 26 additions & 1 deletion java/client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repositories {
}

dependencies {
implementation group: 'com.google.protobuf', name: 'protobuf-java', version: '3.24.3'
implementation group: 'com.google.protobuf', name: 'protobuf-java', version: '4.26.1'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.13.0'

implementation group: 'io.netty', name: 'netty-handler', version: '4.1.100.Final'
Expand All @@ -31,8 +31,29 @@ dependencies {
testImplementation group: 'org.mockito', name: 'mockito-junit-jupiter', version: '3.12.4'
}

ext {
checkProtocVersion = { String output ->
// Line in format like: libprotoc 26.1
int majorVersion = java.lang.Integer.parseInt(output.split(" ")[1].split("\\.")[0].trim());
int minorVersion = java.lang.Integer.parseInt(output.split(" ")[1].split("\\.")[1].trim());
jonathanl-bq marked this conversation as resolved.
Show resolved Hide resolved
if (majorVersion < 26 || (majorVersion == 26 && minorVersion < 1)) {

Choose a reason for hiding this comment

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

Is it possible to get numbers from the dependency instead of hardcoded ones?

throw new GradleException("Use Protoc version 26.1 or later");
}
return output.split(" ")[1]
}
}

tasks.register('protobuf', Exec) {
doFirst {
new ByteArrayOutputStream().withStream { os ->
exec {
commandLine 'protoc', '--version'
workingDir Paths.get(project.rootDir.path, '..').toFile()
standardOutput = os
}
checkProtocVersion(os.toString())
}

project.mkdir(Paths.get(project.projectDir.path, 'src/main/java/glide/models/protobuf').toString())
}
commandLine 'protoc',
Expand Down Expand Up @@ -127,3 +148,7 @@ tasks.withType(Test) {
}
jvmArgs "-Djava.library.path=${projectDir}/../target/debug"
}

jar {
archiveBaseName = "glide-client"
}
12 changes: 12 additions & 0 deletions java/client/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module glide.api {
exports glide.api;
exports glide.api.commands;
exports glide.api.models;
exports glide.api.models.commands;
exports glide.api.models.configuration;
exports glide.api.models.exceptions;

requires com.google.protobuf;
requires io.netty.transport;
requires lombok;
}
Loading