https://github.com/hazer/morphine
Kodein companion for a Dagger-like experience
https://github.com/hazer/morphine
kodein kodein-di kotlin kotlin-android
Last synced: about 1 year ago
JSON representation
Kodein companion for a Dagger-like experience
- Host: GitHub
- URL: https://github.com/hazer/morphine
- Owner: Hazer
- Created: 2019-08-15T22:01:25.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-02-18T14:23:36.000Z (over 4 years ago)
- Last Synced: 2025-02-14T10:55:54.900Z (over 1 year ago)
- Topics: kodein, kodein-di, kotlin, kotlin-android
- Language: Kotlin
- Homepage:
- Size: 214 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Morphine
Kotlin Kodein Module's generator
## Why?
We where Dagger users, for a couple of reasons, we decided to migrate to [Kodein](https://github.com/Kodein-Framework/Kodein-DI) as our DI, but manually migrating and creating all injection binds for a big project was a total no-go. To make our lifes easier we created Morphine, it does code generation of classes and constructors annotated with `javax.inject` annotations, its a Kodein companion for a Dagger-like experience.
## Configuring Morphine in Gradle for each Gradle Module do:
```gradle
dependencies {
implementation("io.vithor.libs:morphine-api:$morphineVersion")
// There are 2 version of the codegen, one for each Kodein counterpart
kapt("io.vithor.libs:morphine-generic-codegen:$morphineVersion")
// or
kapt("io.vithor.libs:morphine-erased-codegen:$morphineVersion")
}
kapt {
arguments {
arg("MAIN_PACKAGE", "your.module.package.sample")
}
}
```
## Acessing generated modules in code:
```kotlin
import your.module.package.sample.allModules // Your sample module package defined earlier
// in each module's "MAIN_PACKAGE"
import org.kodein.di.Kodein
val sampleModule = Kodein.Module("My Sample Module") {
import(allModules)
}
```