DEPRECATED
Kinzhal is deprecated in favor of kotlin-inject
Kinzhal
Kinzhal is a Kotlin Multiplatform library for compile-time dependency injection. The goal is to emulate basic features of Dagger to achieve similar experience in Kotlin Multiplatform projects
Kinzhal is based on Kotlin Symbol Processing (KSP) — the API for lightweight compiler plugins. You'll need to set up KSP in your project to use Kinzhal
Setup
Add KSP to your plugins section:
plugins {
id("com.google.devtools.ksp") version "$kspVersion"
kotlin("multiplatform")
}
Apply Kinzhal KSP processor:
dependencies {
ksp("com.daugeldauge.kinzhal:kinzhal-processor:$kinzhalVersion")
}
Add compile-only kinzhal-annotations dependency to your common source set:
kotlin {
sourceSets {
getByName("commonMain") {
dependencies {
compileOnly("com.daugeldauge.kinzhal:kinzhal-annotations:$kinzhalVersion")
}
}
if (System.getProperty("idea.sync.active") != null) {
kotlin.srcDir("$buildDir/generated/ksp/jvmMain/kotlin")
}
}
}
FAQ
What targets are supported?
JVM and most of Kotlin/Native targets. Kotlin/JS is not supported for now (see #4). Please file an issue if you don't find a target you need
Examples
See more in the source code
Dagger2 compatibility table