Skip to content

Commit

Permalink
fix: zenoh-jni not loaded locally & publish jvm workflow (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
DariusIMP authored Dec 19, 2023
1 parent 6c89fdf commit 60d364c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish_android.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish
name: Publish Android

on:
release:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_jvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ jobs:
esac
- name: "Upload packages"
uses: actions/upload-artifact@master
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.job.target }}
path: |
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,24 @@ jobs:
override: true
components: rustfmt, clippy

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Cargo Format
working-directory: zenoh-jni
run: cargo fmt --all --check

- name: Clippy Check
working-directory: zenoh-jni
run: cargo clippy --all-targets --all-features -- -D warnings

- name: Cargo Format
- name: Check for feature leaks
working-directory: zenoh-jni
run: cargo fmt --all --check
run: cargo test --no-default-features

- name: Build Zenoh-JNI
working-directory: zenoh-jni
run: cargo build

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Gradle Test
run: gradle jvmTest --info
31 changes: 2 additions & 29 deletions zenoh-java/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ kotlin {
}
}
val jvmMain by getting {
resources.srcDir("../zenoh-jni/target/release").include(arrayListOf("*.dylib", "*.so", "*.dll"))

// The line below is intended to load the native libraries that are crosscompiled on GitHub actions when publishing a JVM package.
resources.srcDir("../jni-libs").include("*/**")
}
Expand Down Expand Up @@ -146,32 +148,3 @@ tasks.whenObjectAdded {
this.inputs.dir(buildDir.resolve("rustJniLibs/android"))
}
}

fun buildZenohJNI(mode: BuildMode = BuildMode.DEBUG) {
val cargoCommand = mutableListOf("cargo", "build")

if (mode == BuildMode.RELEASE) {
cargoCommand.add("--release")
}

val result = project.exec {
commandLine(*(cargoCommand.toTypedArray()), "--manifest-path", "../zenoh-jni/Cargo.toml")
}

if (result.exitValue != 0) {
throw GradleException("Failed to build Zenoh-JNI.")
}
}

enum class BuildMode {
DEBUG {
override fun toString(): String {
return "debug"
}
},
RELEASE {
override fun toString(): String {
return "release"
}
}
}

0 comments on commit 60d364c

Please sign in to comment.