Skip to content

docs(native-cpu): document JVM-only consumption + shadow-jar caveat#579

Merged
michalharakal merged 1 commit intodevelopfrom
feature/native-cpu-jvm-only-doc
Apr 30, 2026
Merged

docs(native-cpu): document JVM-only consumption + shadow-jar caveat#579
michalharakal merged 1 commit intodevelopfrom
feature/native-cpu-jvm-only-doc

Conversation

@michalharakal
Copy link
Copy Markdown
Contributor

Summary

Adds a "Consuming this module" section to NativeKernelProvider's class kdoc capturing two gotchas a downstream consumer hits when wiring skainet-backend-native-cpu into a KMP project for the first time. Pure documentation — no code changes, tests still green (:skainet-backends:skainet-backend-native-cpu:jvmTest 27/27).

Two gotchas covered

  1. JVM-only: the module ships only a jvm() target — no klib variants. KMP consumers must put the dep in jvmMain.dependencies, never in commonMain (the wrong placement triggers "Couldn't resolve dependency 'sk.ainet.core:skainet-backend-native-cpu' in 'commonMain' for all target platforms" on every non-JVM target). Plain kotlin("jvm") modules use the normal dependencies block.

  2. Shadow-jar mergeServiceFiles() bug: on com.gradleup.shadow:9.4.x the merged META-INF/services/sk.ainet.backend.api.kernel.KernelProvider silently loses the NativeKernelProviderFactory entry when both skainet-backend-cpu and skainet-backend-native-cpu are on the classpath. Fat JAR runs Panama priority-50 even though native classes + .so are bundled. Cross-references the working doLast workaround in kllama-cli (SKaiNET-transformers PR Bump com.android.library from 8.12.1 to 8.12.2 #88).

Also fixed

The staged-rollout cursor in the kdoc previously said "PR 5 (this commit)" — accurate when first written but stale now that all 5 PRs have shipped. Re-worded.

Test plan

  • :skainet-backends:skainet-backend-native-cpu:jvmTest — 27/27 (no behavior change)
  • CI green

🤖 Generated with Claude Code

Adds a "Consuming this module" section to NativeKernelProvider's
class kdoc covering the two gotchas a downstream consumer hits
when wiring skainet-backend-native-cpu into a KMP project for
the first time:

1. The module ships only a `jvm()` Kotlin target — no klib
   variants for Native / JS / Wasm. KMP consumers MUST put the
   dep in `jvmMain.dependencies`, never in `commonMain`. The
   wrong placement triggers "Couldn't resolve dependency
   'sk.ainet.core:skainet-backend-native-cpu' in 'commonMain'
   for all target platforms" warnings on every non-JVM target.
   Plain `kotlin("jvm")` modules use the regular `dependencies`
   block.

2. Shadow-jar consumers using `mergeServiceFiles()` on
   com.gradleup.shadow:9.4.x silently lose the
   NativeKernelProviderFactory entry from the merged
   META-INF/services/...KernelProvider file. The fat JAR ends up
   running the priority-50 Panama path even though the native
   classes + .so live in the JAR. Cross-references the doLast
   workaround in `kllama-cli` (SKaiNET-transformers) that
   rebuilds the union.

Also re-words the staged-rollout cursor: previously called PR 5
"this commit" — accurate when first written, but stale now that
all 5 rollout PRs have shipped.

Pure documentation; no code changes; tests still 27/27 green
on jvmTest.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@michalharakal michalharakal merged commit 38fceca into develop Apr 30, 2026
8 of 9 checks passed
@michalharakal michalharakal mentioned this pull request Apr 30, 2026
@michalharakal michalharakal deleted the feature/native-cpu-jvm-only-doc branch May 2, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant