Goal
Carve out Kotlin Multiplatform (KMP) emission from the JVM-focused alef-backend-kotlin crate into a standalone alef-backend-kotlin-mpp crate, parallel to the newly-introduced alef-backend-kotlin-android crate (v0.16.0).
Background
alef-backend-kotlin historically dispatched between three Kotlin flavors via two overlapping axes — KotlinConfig.mode = "jvm"|"kmp"|"android" and KotlinTarget::{Jvm,Native,Multiplatform}. v0.16.0 cleaned this up for Android by:
- Adding
Language::KotlinAndroid as a first-class slug ("kotlin_android").
- Moving Android emission into the dedicated
alef-backend-kotlin-android crate.
- Removing the in-band
mode = "android" path from alef-backend-kotlin.
KMP deserves the same treatment but was deferred until concrete demand surfaced.
Approach
- New crate:
crates/alef-backend-kotlin-mpp/ carved from the current alef-backend-kotlin/src/gen_mpp.rs module. Self-contained — emits build.gradle.kts (multiplatform plugin), settings.gradle.kts with proper pluginManagement, commonMain/jvmMain/androidNativeArm64Main/linuxX64Main/macosArm64Main source sets, .def files for cinterop where applicable.
- New
Language::KotlinMpp variant in alef-core::config::extras::Language (slug "kotlin_mpp").
- Remove old paths: drop
KotlinTarget::Multiplatform enum variant from alef-backend-kotlin and the mode = "kmp" branch in gen_bindings/mod.rs (deprecate-and-bail!, same pattern as mode = "android").
- Snapshot tests: insta-based, covering each emitted file for a representative API surface (struct, enum, error, sync fn, async fn, streaming fn).
- Publish lane: add to
.github/workflows/publish.yaml cargo publish ordering (after alef-backend-java since the JVM side imports the Java facade — same pattern as alef-backend-kotlin-android). Wire crates.io trusted publisher.
Reference implementation
crates/alef-backend-kotlin-android/ (v0.16.0) — closest template; same crate-carve-out pattern, same alef-backend-java re-emission for the JVM source set.
crates/alef-backend-kotlin/src/gen_mpp.rs — existing emission to port.
crates/alef-scaffold/src/languages/kotlin.rs::scaffold_kotlin_multiplatform — existing scaffold artifacts to consolidate into the new crate.
Suggested scope
- Stage A: New crate skeleton +
Language::KotlinMpp plumbing in alef-core (extras.rs, languages.rs, output.rs).
- Stage B: Port
gen_mpp.rs emission into the new crate; ensure settings.gradle.kts ships with pluginManagement { repositories { google(); mavenCentral(); gradlePluginPortal() } } so KMP-Android targets resolve.
- Stage C: Snapshot tests; delete scaffold
scaffold_kotlin_multiplatform after parity.
- Stage D: Hard-error fallback in
alef-backend-kotlin/src/gen_bindings/mod.rs for mode = "kmp" and KotlinTarget::Multiplatform.
- Stage E: Update
.github/workflows/publish.yaml and CHANGELOG; bump alef minor version.
Effort estimate
M (~2–4 days). The trickiest piece is the KMP gradle scaffolding — getting the targets list (jvm(), androidNativeArm64(), linuxX64(), macosArm64()) right and ensuring cinterop .def files match the cbindgen header surface.
Status
Deferred pending concrete user demand. The current single-Kotlin-flavor-per-workspace constraint is fine for kreuzberg (Android-only). Open this issue for community contribution and as a tracking point if a consumer requests KMP.
Goal
Carve out Kotlin Multiplatform (KMP) emission from the JVM-focused
alef-backend-kotlincrate into a standalonealef-backend-kotlin-mppcrate, parallel to the newly-introducedalef-backend-kotlin-androidcrate (v0.16.0).Background
alef-backend-kotlinhistorically dispatched between three Kotlin flavors via two overlapping axes —KotlinConfig.mode = "jvm"|"kmp"|"android"andKotlinTarget::{Jvm,Native,Multiplatform}. v0.16.0 cleaned this up for Android by:Language::KotlinAndroidas a first-class slug ("kotlin_android").alef-backend-kotlin-androidcrate.mode = "android"path fromalef-backend-kotlin.KMP deserves the same treatment but was deferred until concrete demand surfaced.
Approach
crates/alef-backend-kotlin-mpp/carved from the currentalef-backend-kotlin/src/gen_mpp.rsmodule. Self-contained — emitsbuild.gradle.kts(multiplatform plugin),settings.gradle.ktswith properpluginManagement,commonMain/jvmMain/androidNativeArm64Main/linuxX64Main/macosArm64Mainsource sets,.deffiles for cinterop where applicable.Language::KotlinMppvariant inalef-core::config::extras::Language(slug"kotlin_mpp").KotlinTarget::Multiplatformenum variant fromalef-backend-kotlinand themode = "kmp"branch ingen_bindings/mod.rs(deprecate-and-bail!, same pattern asmode = "android")..github/workflows/publish.yamlcargo publish ordering (afteralef-backend-javasince the JVM side imports the Java facade — same pattern asalef-backend-kotlin-android). Wire crates.io trusted publisher.Reference implementation
crates/alef-backend-kotlin-android/(v0.16.0) — closest template; same crate-carve-out pattern, samealef-backend-javare-emission for the JVM source set.crates/alef-backend-kotlin/src/gen_mpp.rs— existing emission to port.crates/alef-scaffold/src/languages/kotlin.rs::scaffold_kotlin_multiplatform— existing scaffold artifacts to consolidate into the new crate.Suggested scope
Language::KotlinMppplumbing in alef-core (extras.rs,languages.rs,output.rs).gen_mpp.rsemission into the new crate; ensuresettings.gradle.ktsships withpluginManagement { repositories { google(); mavenCentral(); gradlePluginPortal() } }so KMP-Android targets resolve.scaffold_kotlin_multiplatformafter parity.alef-backend-kotlin/src/gen_bindings/mod.rsformode = "kmp"andKotlinTarget::Multiplatform..github/workflows/publish.yamland CHANGELOG; bump alef minor version.Effort estimate
M (~2–4 days). The trickiest piece is the KMP gradle scaffolding — getting the targets list (
jvm(),androidNativeArm64(),linuxX64(),macosArm64()) right and ensuring cinterop.deffiles match the cbindgen header surface.Status
Deferred pending concrete user demand. The current single-Kotlin-flavor-per-workspace constraint is fine for kreuzberg (Android-only). Open this issue for community contribution and as a tracking point if a consumer requests KMP.