
Enhances developer experience by enabling fast and intuitive declaration of dependency injection definitions, automatically generating underlying code, and integrating seamlessly with existing APIs.
The goal of Koin Annotations project is to help declare Koin definition in a very fast and intuitive way, and generate all underlying Koin DSL for you. The goal is to help developer experience to scale and go fast π, thanks to Kotlin Compilers.
Here below is the current version:
koin_annotations_version = "1.0.3"Koin 3.2+ is required
First, setup KSP plugin like this, in your root build.gradle:
plugins {
id "com.google.devtools.ksp" version "1.6.21-1.0.6"
}Use the following dependencies in your Gradle dependencies section:
// Koin Annotations
implementation "io.insert-koin:koin-annotations:$koin_annotations_version"
// Koin Annotations - Ksp Compiler
ksp "io.insert-koin:koin-ksp-compiler:$koin_annotations_version"On your app add the following to see generated source code:
sourceSets.main {
java.srcDirs("build/generated/ksp/main/kotlin")
}android {
applicationVariants.all { variant ->
variant.sourceSets.java.each {
it.srcDirs += "build/generated/ksp/${variant.name}/kotlin"
}
}
}Not familiar with Koin? First take a look at Koin Getting Started
Tag your components with definition & module annotations, and use the regular Koin API.
// Tag your component to declare a definition
@Single
class MyComponent// Declare a module and scan for annotations
@Module
@ComponentScan
class MyModuleUse the org.koin.ksp.generated.* import as follow to be able to use generated code:
// Use Koin Generation
import org.koin.ksp.generated.*
fun main() {
val koin = startKoin {
printLogger()
modules(
// use your modules here, with generated ".module" extension on Module classes
MyModule().module
)
}
// Just use your Koin API as regular
koin.get<MyComponent>()
}That's it, you can use your new definitions in Koin with the regular Koin API
Below some quickstart apps:
The goal of Koin Annotations project is to help declare Koin definition in a very fast and intuitive way, and generate all underlying Koin DSL for you. The goal is to help developer experience to scale and go fast π, thanks to Kotlin Compilers.
Here below is the current version:
koin_annotations_version = "1.0.3"Koin 3.2+ is required
First, setup KSP plugin like this, in your root build.gradle:
plugins {
id "com.google.devtools.ksp" version "1.6.21-1.0.6"
}Use the following dependencies in your Gradle dependencies section:
// Koin Annotations
implementation "io.insert-koin:koin-annotations:$koin_annotations_version"
// Koin Annotations - Ksp Compiler
ksp "io.insert-koin:koin-ksp-compiler:$koin_annotations_version"On your app add the following to see generated source code:
sourceSets.main {
java.srcDirs("build/generated/ksp/main/kotlin")
}android {
applicationVariants.all { variant ->
variant.sourceSets.java.each {
it.srcDirs += "build/generated/ksp/${variant.name}/kotlin"
}
}
}Not familiar with Koin? First take a look at Koin Getting Started
Tag your components with definition & module annotations, and use the regular Koin API.
// Tag your component to declare a definition
@Single
class MyComponent// Declare a module and scan for annotations
@Module
@ComponentScan
class MyModuleUse the org.koin.ksp.generated.* import as follow to be able to use generated code:
// Use Koin Generation
import org.koin.ksp.generated.*
fun main() {
val koin = startKoin {
printLogger()
modules(
// use your modules here, with generated ".module" extension on Module classes
MyModule().module
)
}
// Just use your Koin API as regular
koin.get<MyComponent>()
}That's it, you can use your new definitions in Koin with the regular Koin API
Below some quickstart apps: