Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
56b3beb
chore: add branch placeholder zbobr_fix-72-make-zenoh-kotlin-depend-o…
milyin Apr 18, 2026
b7b01de
chore: add zenoh-java as git submodule on common-jni branch
milyin Apr 19, 2026
967dea1
build: update Gradle build to depend on zenoh-jni-runtime, remove Rus…
milyin Apr 19, 2026
d5a476f
refactor: move ZSerialize/ZDeserialize to jvmAndAndroidMain source set
milyin Apr 19, 2026
6156300
refactor: delete zenoh-kotlin JNI adapter layer and duplicate shared …
milyin Apr 19, 2026
b98ffda
refactor: adapt Zenoh.kt, Config.kt, KeyExpr.kt, ZenohId.kt, Logger.k…
milyin Apr 19, 2026
4986cd6
chore: remove zenoh-jni Rust crate and rust-toolchain.toml
milyin Apr 19, 2026
4d8ea8a
build: remove CompileZenohJNI task and cargo wiring from examples
milyin Apr 19, 2026
63114eb
ci: remove Rust build steps, simplify workflows to use zenoh-jni-runtime
milyin Apr 19, 2026
c8b20e9
fix: correct ntpValue call, ReplyKeyExpr ordinal, and KeyExpr undeclare
milyin Apr 19, 2026
282130a
fix: remove zenoh-jni references from bump-and-tag script and README
milyin Apr 19, 2026
b24b319
fix: decouple publish from local submodule, add separate runtime vers…
milyin Apr 19, 2026
c5d4716
docs: update README to distinguish Maven vs local submodule test modes
milyin Apr 19, 2026
e290c7b
fix: use runtime acceptReplies value in Query and fail-fast on select…
milyin Apr 19, 2026
8aa6930
fix: fail fast when useLocalJniRuntime=true but submodule is absent
milyin Apr 19, 2026
d71cce2
fix: remove stale publish-crates-github job from release workflow
milyin Apr 19, 2026
b4a9fac
Update zenoh-java submodule reference
milyin Apr 19, 2026
55a5cda
Merge pull request #651 from milyin-zenoh-zbobr/zbobr_fix-72-make-zen…
milyin Apr 19, 2026
fae1866
Update zenoh-java submodule to eclipse-zenoh/zenoh-java:common-jni HEAD
milyin Apr 19, 2026
9df0ffd
test fix attempt
milyin Apr 19, 2026
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
31 changes: 3 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ on:
- cron: "0 6 * * 1-5"
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

jobs:
build:
name: Build on ${{ matrix.os }}
Expand All @@ -23,43 +20,21 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11

- name: Install Rust toolchain
run: |
rustup show
rustup component add rustfmt clippy

- name: Cargo Format
working-directory: zenoh-jni
run: cargo fmt --all --check

- name: Clippy Check without Cargo.lock
working-directory: zenoh-jni
run: |
rm Cargo.lock
cargo clippy --all-targets --all-features -- -D warnings
git restore Cargo.lock

- name: Check for feature leaks
working-directory: zenoh-jni
run: cargo test --no-default-features

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

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: 8.12.1

- name: Gradle Test
run: gradle jvmTest --info
run: gradle jvmTest --info -Pzenoh.useLocalJniRuntime=true

markdown_lint:
runs-on: ubuntu-latest
Expand Down
22 changes: 0 additions & 22 deletions .github/workflows/publish-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ on:
required: false
default: true

env:
CARGO_TERM_COLOR: always

jobs:
publish_android_package:
name: Publish Android package
Expand All @@ -37,25 +34,6 @@ jobs:
distribution: temurin
java-version: 11

- uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r26
add-to-path: false
link-to-sdk: true

- name: Install Rust toolchain
run: |
rustup show
rustup component add rustfmt clippy

- name: Setup Rust toolchains
run: |
rustup target add armv7-linux-androideabi
rustup target add i686-linux-android
rustup target add aarch64-linux-android
rustup target add x86_64-linux-android

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
Expand Down
126 changes: 0 additions & 126 deletions .github/workflows/publish-jvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,127 +17,9 @@ on:
required: false
default: true

env:
CARGO_TERM_COLOR: always
JNI_LIB_PATHS: jni-libs # Edit on the inner build.gradle.kts file as well.

jobs:
builds:
name: Build for ${{ matrix.job.target }} on ${{ matrix.job.os }}
if: ${{ !(github.event.inputs.build == 'false') }}
runs-on: ${{ matrix.job.os }}
strategy:
fail-fast: false
matrix:
job:
# In order to load any added target at runtime, editing the Zenoh class under jvmMain is required.
- {
target: x86_64-unknown-linux-gnu,
arch: amd64,
os: ubuntu-latest,
build-cmd: "cargo",
}
- {
target: aarch64-unknown-linux-gnu,
arch: arm64,
os: ubuntu-latest,
build-cmd: "cross",
}
- {
target: x86_64-apple-darwin,
arch: darwin,
os: macos-latest,
build-cmd: "cargo",
}
- {
target: aarch64-apple-darwin,
arch: darwin,
os: macos-latest,
build-cmd: "cargo",
}
- {
target: x86_64-pc-windows-msvc,
arch: win64,
os: windows-latest,
build-cmd: "cargo",
}
- {
target: aarch64-pc-windows-msvc,
arch: arm64,
os: windows-latest,
build-cmd: "cargo",
}
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}

- name: Install prerequisites
shell: bash
run: |
case ${{ matrix.job.target }} in
*-linux-gnu*) cargo +stable install cargo-deb --locked ;;
esac

case ${{ matrix.job.target }} in
aarch64-unknown-linux-gnu)
sudo apt-get -y update
sudo apt-get -y install gcc-aarch64-linux-gnu
;;
esac

cargo +stable install cross --locked

- name: Install Rust toolchain
run: |
rustup show
rustup target add ${{ matrix.job.target }}

- name: Build
run: ${{ matrix.job.build-cmd }} build --release --bins --lib --features=${{ github.event.inputs.features}} --target=${{ matrix.job.target }} --manifest-path zenoh-jni/Cargo.toml

- name: Packaging
id: package
shell: bash
run: |
TARGET=${{ matrix.job.target }}
MAIN_PKG_NAME="${GITHUB_WORKSPACE}/${TARGET}.zip"

case ${TARGET} in
*linux*)
cd "zenoh-jni/target/${TARGET}/release/"
echo "Packaging ${MAIN_PKG_NAME}:"
zip ${MAIN_PKG_NAME} libzenoh_jni.so
cd -
echo "MAIN_PKG_NAME=${MAIN_PKG_NAME}" >> $GITHUB_OUTPUT
;;
*apple*)
cd "zenoh-jni/target/${TARGET}/release/"
echo "Packaging ${MAIN_PKG_NAME}:"
zip ${MAIN_PKG_NAME} libzenoh_jni.dylib
cd -
echo "MAIN_PKG_NAME=${MAIN_PKG_NAME}" >> $GITHUB_OUTPUT
;;
*windows*)
cd "zenoh-jni/target/${TARGET}/release/"
echo "Packaging ${MAIN_PKG_NAME}:"
7z -y a "${MAIN_PKG_NAME}" zenoh_jni.dll
cd -
echo "MAIN_PKG_NAME=${MAIN_PKG_NAME}" >> $GITHUB_OUTPUT
;;
esac

- name: "Upload packages"
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.job.target }}
path: |
${{ steps.package.outputs.MAIN_PKG_NAME }}

publish_jvm_package:
name: Publish JVM package
needs: builds
permissions:
contents: read
packages: write
Expand All @@ -148,14 +30,6 @@ jobs:
with:
ref: ${{ inputs.branch }}

- name: Create resources destination
run: mkdir ${{env.JNI_LIB_PATHS}}

- name: Download result of previous builds
uses: actions/download-artifact@v4
with:
path: ${{env.JNI_LIB_PATHS}}

- uses: actions/setup-java@v4
with:
distribution: temurin
Expand Down
12 changes: 0 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,3 @@ jobs:
with:
live-run: ${{ inputs.live-run || false }}
branch: ${{ needs.tag.outputs.branch }}

publish-github:
needs: [tag, publish-android, publish-jvm]
runs-on: macos-latest
steps:
- uses: eclipse-zenoh/ci/publish-crates-github@main
with:
repo: ${{ github.repository }}
live-run: ${{ inputs.live-run || false }}
version: ${{ needs.tag.outputs.version }}
branch: ${{ needs.tag.outputs.branch }}
github-token: ${{ secrets.BOT_TOKEN_WORKFLOW }}
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "zenoh-java"]
path = zenoh-java
url = https://github.com/eclipse-zenoh/zenoh-java.git
branch = common-jni
56 changes: 19 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,15 @@ For the moment, the library targets the following platforms:

Basically:

- Rust ([Installation guide](https://doc.rust-lang.org/cargo/getting-started/installation.html))
- Kotlin ([Installation guide](https://kotlinlang.org/docs/getting-started.html#backend))
- Gradle ([Installation guide](https://gradle.org/install/))

and in case of targetting Android you'll also need:

- Android SDK ([Installation guide](https://developer.android.com/about/versions/11/setup-sdk))

> **Note:** zenoh-kotlin no longer builds its own native JNI library. The native runtime is provided by [zenoh-jni-runtime](https://github.com/eclipse-zenoh/zenoh-java), which is a published Maven artifact that zenoh-kotlin depends on automatically. No Rust toolchain is required to build or publish zenoh-kotlin using the default (Maven) path. A Rust toolchain is only needed when using the [local submodule path](#running-the-tests) with `-Pzenoh.useLocalJniRuntime=true`.

## <img src="jvm.png" alt="JVM" height="50"> JVM

To publish a library for a JVM project into Maven local, run
Expand All @@ -134,11 +135,7 @@ To publish a library for a JVM project into Maven local, run
gradle publishJvmPublicationToMavenLocal
```

This will first, trigger the compilation of Zenoh-JNI, and second publish the library into maven local, containing the native library
as a resource that will be loaded during runtime.

:warning: The native library will be compiled against the default rustup target on your machine, so although it may work fine
for you on your desktop, the generated publication may not be working on another computer with a different operating system and/or a different cpu architecture.
This publishes the zenoh-kotlin library to Maven local. The published artifact declares a dependency on `zenoh-jni-runtime`, which provides the native JNI binaries and is published separately by the [zenoh-java](https://github.com/eclipse-zenoh/zenoh-java) project.

Once we have published the package, we should be able to find it under `~/.m2/repository/org/eclipse/zenoh/zenoh-kotlin-jvm/1.1.1`.

Expand All @@ -157,40 +154,13 @@ dependencies {

## <img src="android-robot.png" alt="Android" height="50"> Android

In order to use these bindings in a native Android project, what we will do is to build them as an Android NDK Library,
publishing it into Maven local for us to be able to easily import it in our project.

It is required to have the [NDK (native development kit)](https://developer.android.com/ndk) installed, since we are going to compile Zenoh JNI for multiple
android native targets. The currently used NDK version is **26.0.10792818**.
It can be set up by using Android Studio (go to `Preferences > Languages & Frameworks > Android SDK > SDK Tools`, tick `Show Package Details` and pick the right NDK version),
or alternatively it can be found [here](https://developer.android.com/ndk/downloads).

The native platforms we are going to target are the following ones:

- x86
- x86_64
- arm
- arm64

Therefore, if they are not yet already added to the Rust toolchain, run:

```bash
rustup target add armv7-linux-androideabi; \
rustup target add i686-linux-android; \
rustup target add aarch64-linux-android; \
rustup target add x86_64-linux-android
```

to install them.

So, in order to publish the library onto Maven Local, run:
In order to use these bindings in a native Android project, publish them into Maven local:

```bash
gradle -Pandroid=true publishAndroidReleasePublicationToMavenLocal
```

This will first trigger the compilation of the Zenoh-JNI for the previously mentioned targets, and secondly will
publish the library, containing the native binaries.
This publishes the zenoh-kotlin-android artifact to Maven local. The published artifact declares a dependency on `zenoh-jni-runtime`, which provides the prebuilt native JNI binaries for Android ABIs (x86, x86_64, arm, arm64). The native binaries are published separately by the [zenoh-java](https://github.com/eclipse-zenoh/zenoh-java) project — no Rust toolchain or NDK cross-compilation is required.

You should now be able to see the package under `~/.m2/repository/org/eclipse/zenoh/zenoh-kotlin-android/1.1.1`.

Expand Down Expand Up @@ -226,13 +196,25 @@ gradle dokkaGenerate

## Running the tests

To run the tests, run:
zenoh-kotlin supports two modes for providing the native JNI runtime during tests:

### Default mode (published Maven artifact)

By default, tests resolve `zenoh-jni-runtime` from Maven Central. No local submodule or Rust toolchain is needed:

```bash
gradle jvmTest
```

This will compile the native library on debug mode (if not already available) and run the tests afterward against the JVM target.
### Local submodule mode (opt-in)

For local integration testing against the `zenoh-java` submodule (included under `zenoh-java/`), pass the `zenoh.useLocalJniRuntime` property. This substitutes the Maven dependency with a local composite build of the submodule:

```bash
gradle jvmTest -Pzenoh.useLocalJniRuntime=true
```

> **Note:** The local submodule path builds `zenoh-jni-runtime` from source and requires a Rust toolchain (see [rustup.rs](https://rustup.rs)) as well as the Cargo toolchain configured for the target platform. The submodule's Gradle build handles the Rust compilation step automatically once the toolchain is installed.

## Logging

Expand Down
6 changes: 2 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ buildscript {
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0")
classpath("org.mozilla.rust-android-gradle:plugin:0.9.6")
classpath("com.android.tools.build:gradle:7.4.2")
classpath("com.android.tools.build:gradle:7.4.2")
classpath("com.gradleup.shadow:shadow-gradle-plugin:9.0.0-beta6")
}
}
Expand All @@ -28,8 +27,7 @@ plugins {
id("com.android.library") version "7.4.2" apply false
id("org.jetbrains.kotlin.android") version "1.9.10" apply false
id("org.jetbrains.kotlin.multiplatform") version "1.9.0" apply false
id("org.mozilla.rust-android-gradle.rust-android") version "0.9.6" apply false
id("org.jetbrains.dokka") version "2.0.0" apply false
id("org.jetbrains.dokka") version "2.0.0" apply false
id("com.adarshr.test-logger") version "3.2.0" apply false
kotlin("plugin.serialization") version "1.9.0" apply false
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
Expand Down
Loading
Loading