Skip to content
/ Morphine Public

Kodein companion for a Dagger-like experience

Notifications You must be signed in to change notification settings

Hazer/Morphine

Repository files navigation

Morphine

Kotlin Kodein Module's generator

Why?

We where Dagger users, for a couple of reasons, we decided to migrate to Kodein 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:

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:

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)
}

About

Kodein companion for a Dagger-like experience

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published