Skip to content
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
32 changes: 32 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,38 @@ env:
CARGO_TERM_COLOR: always

jobs:
kotlin:
name: Kotlin/JVM artifact
runs-on: ubuntu-latest
concurrency:
group: kotlin-jvm-${{ github.event.pull_request.number }}
cancel-in-progress: true

steps:
- uses: actions/checkout@v7
- uses: actions/setup-java@v6.0.1
with:
distribution: temurin
java-version: "17"
- uses: cachix/install-nix-action@v31.11.1
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: gradle/actions/setup-gradle@v6
- uses: Swatinem/rust-cache@v2
with:
key: kotlin-jvm
- name: Exercise packaged Kotlin/JVM binding
run: nix develop --command just test-kotlin
- name: Upload JVM test results
if: always()
uses: actions/upload-artifact@v7
with:
name: kotlin-jvm-test-results
path: |
kt/web-transport/build/reports/tests/jvmTest/
kt/web-transport/build/test-results/jvmTest/
if-no-files-found: ignore

build:
runs-on: ubuntu-latest

Expand Down
4 changes: 4 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ build-ffi:
build-ffi-target target:
./rs/web-transport-ffi/build.sh --target {{target}} --output rs/web-transport-ffi/dist

# Build and exercise the Linux Kotlin/JVM JAR, including its packaged native library.
test-kotlin:
./kt/scripts/check.sh

# Delete build artifacts and caches to reclaim disk space. web-transport keeps
# a single root justfile (unlike moq's per-language modules), so the per-language
# cleanups are inlined here. Sweeps the shared caches, then recurses into any
Expand Down
1 change: 1 addition & 0 deletions kt/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.gradle/
.kotlin/
build/
local.properties
**/jniLibs/
Expand Down
42 changes: 37 additions & 5 deletions kt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,46 @@ dependencies {
## Build

```sh
# Build host cdylib, regenerate UniFFI bindings, run :web-transport:jvmTest.
just kt check
# Build host cdylib, regenerate UniFFI bindings, and test the packaged JVM JAR.
# Requires JDK 17 via JAVA_HOME or PATH; Nix supplies Rust, Just, and OpenSSL.
nix develop --command just test-kotlin

# Equivalent without Nix, with Rust, Just, OpenSSL, and JDK 17 installed:
just test-kotlin

# Assemble the KMP artifacts for publishing (requires per-target libs).
gradle -p kt :web-transport:assemble
./kt/gradlew -p kt :web-transport:assemble
```

`kt/scripts/check.sh` builds `web-transport-ffi` for the host, regenerates the UniFFI Kotlin bindings, drops the host cdylib into the JNA-resource layout, and runs `gradle :web-transport:jvmTest`. Skips cleanly without a JDK or `cargo`.
`kt/scripts/check.sh` uses the checksum-pinned Gradle 8.10.2 wrapper, builds
`web-transport-ffi` in release mode for the host, regenerates UniFFI Kotlin
bindings, and stages the host library in the JNA resource layout. Missing tools
or an unsupported host fail the command. This focused smoke supports Linux GNU
x86_64 and aarch64. Other desktop platforms remain in the release packaging
matrix.

`check.sh` enables the smoke source set with `-PartifactSmoke=true`. Ordinary
Gradle `build`/`check` does not compile or run these externally staged tests.
The opted-in `:web-transport:jvmTest` loads main classes and native resources
from `jvmJar`,
with loose build outputs removed from its runtime classpath. The smoke test
checks JNA extraction, connects a loopback client/server on an ephemeral port,
exchanges a bidirectional stream, and closes sessions and endpoints. Fresh test
credentials live under `.tmp/` and are removed on exit; the loopback client
disables certificate verification. No publishing or Android SDK is required.
The independent Kotlin/JVM PR job runs this same command on Linux and uploads
JUnit XML and HTML results. Other staged platform libraries are preserved. The
release matrix and packaging remain separate.

After staging with `just test-kotlin`, rerun through that command so test
credentials are regenerated. Results are in
`kt/web-transport/build/reports/tests/jvmTest/index.html`.

Keep each generated `Session` handle alive while using its streams. To close a
session or endpoint, supply code and reason explicitly, for example
`session.close(0u, "done")` or `client.close(0uL, "done")`. Parameterless `close()`
is UniFFI's `AutoCloseable` handle destruction; `use { ... }` releases handles
after explicit lifecycle cleanup.

The Android target is opt-in via `-Pandroid.enabled=true`. Local dev without the Android SDK still builds the JVM variant.

Expand All @@ -37,12 +69,12 @@ kt/
gradle.properties Defaults: version, android.useAndroidX, etc.
web-transport/
build.gradle.kts KMP plugin, jvm() always, androidTarget() conditional
android.gradle.kts Applied only when -Pandroid.enabled=true
src/
commonMain/ Public Kotlin facade (reserved for future K/N)
jvmAndAndroidMain/ UniFFI-generated kotlin (populated, gitignored)
jvmMain/resources/ Native libs at JNA paths (populated, gitignored)
androidMain/jniLibs/ JNI .so per ABI (populated, gitignored)
jvmArtifactTest/ Opt-in packaged-artifact lifecycle smoke
scripts/ check.sh, package.sh
```

Expand Down
Binary file added kt/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
8 changes: 8 additions & 0 deletions kt/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionSha256Sum=31c55713e40233a8303827ceb42ca48a47267a0ad4bab9177123121e71524c26
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
252 changes: 252 additions & 0 deletions kt/gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading