Skip to content

Commit 0621842

Browse files
authored
Readme update (#183)
* Readme update * Using macos-15 on the CI workflow
1 parent fe9c5b3 commit 0621842

File tree

3 files changed

+61
-117
lines changed

3 files changed

+61
-117
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
strategy:
2323
fail-fast: false
2424
matrix:
25-
os: [ubuntu-latest, macos-latest]
25+
os: [ubuntu-latest, macos-15]
2626

2727
steps:
2828
- uses: actions/checkout@v4

README.md

Lines changed: 60 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ This repository provides a Java compatible Kotlin binding based on the main [Zen
2323

2424
The code relies on the Zenoh JNI native library, which written in Rust and communicates with the Kotlin layer via the Java Native Interface (JNI).
2525

26-
## Documentation
26+
## <img src="doc_icon.png" alt="Zenoh" height="70"> Documentation
2727

2828
The documentation of the API is published at [https://eclipse-zenoh.github.io/zenoh-java/index.html](https://eclipse-zenoh.github.io/zenoh-java/index.html).
2929

@@ -33,60 +33,23 @@ Alternatively, you can build it locally as [explained below](#building-the-docum
3333

3434
# How to import
3535

36-
:warning: Note nº1: **Breaking changes incoming**
36+
## <img src="android-robot.png" alt="Android" height="50"> Android
3737

38-
With the purpose of providing an upgraded API across all the languages supported by the Zenoh ecosystem,
39-
we are currently releasing a series of alpha and beta versions, the latest one being currently the
40-
[1.0.0-beta.1](https://github.com/eclipse-zenoh/zenoh-java/releases/tag/1.0.0-beta.1).
41-
42-
This last release still offers an 'old-fashioned' API, although it's fully
43-
compatible with the other 1.0.0 releases of Zenoh. You must take into consideration when importing this library
44-
that the API is about to be modified with some considerable breaking changes. A migration guide will be provided when
45-
the time comes.
46-
47-
:warning: Note nº2: **About the released packages**
48-
49-
The released packages can be found in the "packages" section of this repository, or in the links below:
50-
51-
- [Android packages](https://github.com/eclipse-zenoh/zenoh-java/packages/2019754/versions)
52-
- [JVM packages](https://github.com/eclipse-zenoh/zenoh-java/packages/2017294/versions)
53-
54-
These are 'nightly' packages that need to be imported as explained in the following sections of this README.
55-
We plan to publish our packages into Maven central for the `1.0.0` stable release.
56-
57-
## <img src="android-robot.png" alt="Android" height="50"> For Android applications
58-
59-
For this first version we have published a [Github package](https://github.com/eclipse-zenoh/zenoh-java/packages/2019754) with the library which can be imported on your projects.
60-
61-
Checkout the [Zenoh demo app](https://github.com/eclipse-zenoh/zenoh-demos/tree/main/zenoh-android/ZenohApp) for an example on how to use the library.
62-
63-
First add the Github packages repository to your `settings.gradle.kts`:
38+
First add the Maven central repository to your `settings.gradle.kts`:
6439

6540
```kotlin
6641
dependencyResolutionManagement {
6742
// ...
6843
repositories {
69-
google()
7044
mavenCentral()
71-
maven {
72-
name = "GitHubPackages"
73-
url = uri("https://maven.pkg.github.com/eclipse-zenoh/zenoh-java")
74-
credentials {
75-
username = providers.gradleProperty("user").get()
76-
password = providers.gradleProperty("token").get()
77-
}
78-
}
7945
}
8046
}
8147
```
8248

83-
where the username and token are your github username and a personal access token you need to generate on github with package read permissions (see the [Github documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)).
84-
This is required by Github in order to import the package, even if it's from a public repository.
85-
8649
After that add to the dependencies in the app's `build.gradle.kts`:
8750

8851
```kotlin
89-
implementation("io.zenoh:zenoh-java-android:0.11.0")
52+
implementation("org.eclipse.zenoh:zenoh-java-android:1.1.1")
9053
```
9154

9255
### Platforms
@@ -111,37 +74,23 @@ Zenoh is a communications protocol, therefore the permissions required are:
11174
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
11275
```
11376

114-
## <img src="jvm.png" alt="Java" height="50"> For JVM-based applications
115-
116-
Similar to Android, we have published a Github package to import on your projects.
77+
## <img src="jvm.png" alt="Java" height="50"> JVM
11778

118-
First add the Github packages repository to your `settings.gradle.kts`:
79+
First add the Maven central repository to your `settings.gradle.kts`:
11980

12081
```kotlin
12182
dependencyResolutionManagement {
12283
// ...
12384
repositories {
124-
google()
12585
mavenCentral()
126-
maven {
127-
name = "GitHubPackages"
128-
url = uri("https://maven.pkg.github.com/eclipse-zenoh/zenoh-java")
129-
credentials {
130-
username = providers.gradleProperty("user").get()
131-
password = providers.gradleProperty("token").get()
132-
}
133-
}
13486
}
13587
}
13688
```
13789

138-
where the username and token are your github username and a personal access token you need to generate on github with package read permissions (see the [Github documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)).
139-
This is required by Github in order to import the package, even if it's from a public repository.
140-
14190
After that add to the dependencies in the app's `build.gradle.kts`:
14291

14392
```kotlin
144-
implementation("io.zenoh:zenoh-java-jvm:0.11.0")
93+
implementation("org.eclipse.zenoh:zenoh-java-jvm:1.1.1")
14594
```
14695

14796
### Platforms
@@ -153,6 +102,7 @@ For the moment, the library targets the following platforms:
153102
- x86_64-apple-darwin
154103
- aarch64-apple-darwin
155104
- x86_64-pc-windows-msvc
105+
- aarch64-pc-windows-msvc
156106

157107
----
158108

@@ -166,7 +116,7 @@ Basically:
166116
- Kotlin ([Installation guide](https://kotlinlang.org/docs/getting-started.html#backend))
167117
- Gradle ([Installation guide](https://gradle.org/install/))
168118

169-
and in case of targetting Android you'll also need:
119+
and in case of targeting Android you'll also need:
170120

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

@@ -175,18 +125,18 @@ and in case of targetting Android you'll also need:
175125
To publish a library for a JVM project into Maven local, run
176126

177127
```bash
178-
gradle -Prelease=true publishJvmPublicationToMavenLocal
128+
gradle publishJvmPublicationToMavenLocal
179129
```
180130

181-
This will first, trigger the compilation of Zenoh-JNI in release (if you want debug, specify `-Prelease=false`), and second publish the library into maven local, containing the native library
131+
This will first, trigger the compilation of Zenoh-JNI in release, and second publish the library into maven local, containing the native library
182132
as a resource that will be loaded during runtime.
183133

184134
:warning: The native library will be compiled against the default rustup target on your machine, so although it may work fine
185135
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.
186136

187-
Once we have published the package, we should be able to find it under `~/.m2/repository/io/zenoh/zenoh-java-jvm/0.11.0`.
137+
Once we have published the package, we should be able to find it under `~/.m2/repository/org/eclipse/zenoh/zenoh-java-jvm/1.1.1`.
188138

189-
Finally, in the `build.gradle.kts` file of the project where you intend to use this library, add mavenLocal to the list of repositories and add zenoh-java as a dependency:
139+
Finally, in the gradle file of the project where you intend to use this library, add mavenLocal to the list of repositories and add zenoh-java as a dependency:
190140

191141
```kotlin
192142
repositories {
@@ -195,8 +145,7 @@ repositories {
195145
}
196146

197147
dependencies {
198-
testImplementation(kotlin("test"))
199-
implementation("io.zenoh:zenoh-java-jvm:0.11.0")
148+
implementation("org.eclipse.zenoh:zenoh-java-jvm:1.1.1")
200149
}
201150
```
202151

@@ -237,52 +186,36 @@ gradle -Pandroid=true publishAndroidReleasePublicationToMavenLocal
237186
This will first trigger the compilation of the Zenoh-JNI for the previously mentioned targets, and secondly will
238187
publish the library, containing the native binaries.
239188

240-
You should now be able to see the package under `~/.m2/repository/io/zenoh/zenoh-java-android/0.11.0`
241-
with the following files:
189+
You should now be able to see the package under `~/.m2/repository/org/eclipse/zenoh/zenoh-java-android/1.1.1`.
242190

243-
```raw
244-
zenoh-java-android-0.11.0-sources.jar
245-
zenoh-java-android-0.11.0.aar
246-
zenoh-java-android-0.11.0.module
247-
zenoh-java-android-0.11.0.pom
248-
```
249-
250-
Now the library is published on maven local, let's now see how to import it into an Android project.
251-
252-
First, we need to indicate we want to look into mavenLocal for our library, so in your top level `build.gradle.kts` you need to specify
253-
the `mavenLocal` repository:
191+
Finally, in the gradle file of the project where you intend to use this library, add mavenLocal to the list of repositories and add zenoh-java-android as a dependency:
254192

255193
```kotlin
256194
repositories {
257195
mavenCentral()
258-
...
259-
mavenLocal() // We add this line
196+
mavenLocal()
260197
}
261-
```
262198

263-
Then in your app's `build.gradle.kts` filen add the dependency:
264-
265-
```kotlin
266-
implementation("io.zenoh:zenoh-java-android:0.11.0")
199+
dependencies {
200+
implementation("org.eclipse.zenoh:zenoh-kotlin-android:1.1.1")
201+
}
267202
```
268203

269-
And finally, do not forget to add the required internet permissions on your manifest!
204+
Reminder that in order to work during runtime, the following permissions must be enabled in the app's manifest:
270205

271206
```xml
272207
<uses-permission android:name="android.permission.INTERNET" />
273208
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
274209
```
275210

276-
And that was it! You can now import the code from the `io.zenoh` package and use it at your will.
277-
278211
## Building the documentation
279212

280213
Because it's a Kotlin project, we use [Dokka](https://kotlinlang.org/docs/dokka-introduction.html) to generate the documentation.
281214

282215
In order to build it, run:
283216

284217
```bash
285-
gradle zenoh-java:dokkaHtml
218+
gradle dokkaGenerate
286219
```
287220

288221
## Running the tests
@@ -294,55 +227,66 @@ gradle jvmTest
294227
```
295228

296229
This will compile the native library on debug mode (if not already available) and run the tests afterward against the JVM target.
297-
Running the tests against the Android target (by using `gradle testDebugUnitTest`) is equivalent to running them against the JVM one, since they are common
298-
tests executed locally as Unit tests.
299230

300231
## Logging
301232

302-
Rust logs are propagated when setting the property `zenoh.logger=debug` (using RUST_LOG=debug will result in nothing)
233+
Rust logs are propagated when setting the `RUST_LOG` environment variable.
303234

304235
For instance running the ZPub test as follows:
305236

306237
```bash
307-
gradle -Pzenoh.logger=debug ZPub
238+
RUST_LOG=debug gradle ZPub
308239
```
309240

310241
causes the logs to appear in standard output.
311242

312-
The log levels are the ones from Rust: `trace`, `info`, `debug`, `error` and `warn`.
243+
The log levels are the ones from Rust, typically `trace`, `info`, `debug`, `error` and `warn` (though other log filtering options are available, see <https://docs.rs/env_logger/latest/env_logger/#enabling-logging>).
313244

314-
----
315-
316-
# Examples
245+
Alternatively, the logs can be enabled programmatically through `Zenoh.initLogFromEnvOr(logfilter)`, for instance:
317246

318-
You can find some examples located under the [`/examples` folder](examples).
319-
Once we've built the project, to run them, simply run `./gradlew <EXAMPLE_NAME>`.
247+
```kotlin
248+
Zenoh.initLogFromEnvOr("debug")
249+
```
320250

321-
For instance in order to run the [ZPub](examples/src/main/java/io.zenoh/ZPub.java) example, type:
251+
----
322252

323-
```bash
324-
./gradlew ZPub
325-
```
253+
# Examples
326254

327-
You can find more info about these examples on the [examples README file](/examples/README.md).
255+
You can find some examples located under the [`/examples` folder](examples). Checkout the [examples README file](/examples/README.md).
328256

329257
----
330258

331-
# :warning: Considerations & Future work
332-
333-
## Packaging
259+
# Old packages
334260

335-
We intend to publish this code on Maven in the short term in order to ease the installation, but for the moment, until we
336-
add some extra functionalities and test this library a bit further, we will only publish packages to Github packages.
261+
Old released versions were published into Github packages.
337262

338-
## Potential API changes
263+
In case you want to use one of the versions published into github packages, add the Github packages repository to your `settings.gradle.kts` as follows:
339264

340-
When using this library, keep in mind the api is not fully stable. Changes are to be expected, especially for version 1.0.0.
265+
```kotlin
266+
dependencyResolutionManagement {
267+
// ...
268+
repositories {
269+
google()
270+
mavenCentral()
271+
maven {
272+
name = "GitHubPackages"
273+
url = uri("https://maven.pkg.github.com/eclipse-zenoh/zenoh-java")
274+
credentials {
275+
username = providers.gradleProperty("user").get()
276+
password = providers.gradleProperty("token").get()
277+
}
278+
}
279+
}
280+
}
281+
```
341282

342-
## Performance
283+
where the username and token are your github username and a personal access token you need to generate on github with package read permissions (see the [Github documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)).
284+
This is required by Github in order to import the package, even if it's from a public repository.
343285

344-
The communication between the Kotlin code and the Rust code through the java native interface (JNI) has its toll on performance.
286+
Then after that, add the dependency as usual:
345287

346-
Some preliminary performance evaluations done on an M2 Mac indicate around a 50% performance drop regarding the publication throughput
347-
(compared to Rust-Rust communication), and for subscription throughput the performance is similar to that of zenoh-python, with around 500K messages per second
348-
for an 8 bytes payload messages.
288+
```kotlin
289+
dependencies {
290+
implementation("org.eclipse.zenoh:zenoh-java-jvm:<version>")
291+
}
292+
```

doc_icon.png

9.7 KB
Loading

0 commit comments

Comments
 (0)