Install

Kotlin/Multiplatform

Kodein-DB uses the new gradle native dependency model featured in Gradle 5.3 and later.

In your build.gradle.kts file, add the repository:

build.gradle.kts
buildscript {
    repositories {
        mavenCentral()
    }
}

Then add the dependency:

build.gradle
kotlin {
    sourceSets {
        named("commonMain") {
            dependencies {
                implementation("org.kodein.db:kodein-db:0.8.1-beta")
            }
        }
    }
}

Thanks to Gradle Metadata, you don’t need to add any additional dependency to your targets.

If you are developing a library and not an application, use kodein-db-api instead, which only provides the Kodein-DB API, and not its implementation:

implementation("org.kodein.db:kodein-db-api:0.8.1-beta")

Furthermore, you need to add the serializer you are going to use. When targeting Multiplatform, you can only use KotlinX Serialization:

build.gradle
kotlin {
    sourceSets {
        named("commonMain") {
            dependencies {
                implementation("org.kodein.db:kodein-db-serializer-kotlinx:0.8.1-beta")
            }
        }
    }
}

Android only

Add the repository:

build.gradle.kts
buildscript {
    repositories {
        mavenCentral()
    }
}

Then add the dependency:

build.gradle.kts
dependencies {
    debugImplementation("org.kodein.db:kodein-db-android-debug:0.8.1-beta")
    releaseImplementation("org.kodein.db:kodein-db-android:0.8.1-beta")
}

If you are developing a library and not an application, use kodein-db-api-jvm instead, which only provides the Kodein-DB API, and not its implementation:

implementation("org.kodein.db:kodein-db-api-jvm:0.8.1-beta")

Furthermore, you need to add the serializer you are going to use. When targetting Android only, you can use either KotlinX.Serialization:

build.gradle.kts
dependencies {
    implementation("org.kodein.db:kodein-db-serializer-kotlinx:0.8.1-beta")
}

…​or Kryo (which is JVM & Android only):

build.gradle.kts
dependencies {
    implementation("org.kodein.db:kodein-db-serializer-kryo-jvm:0.8.1-beta")
}

Desktop JVM

Add the repository:

build.gradle.kts
buildscript {
    repositories {
        mavenCentral()
    }
}

Then add the dependency:

build.gradle.kts
implementation("org.kodein.db:kodein-db-jvm:0.8.1-beta")

If you are developing a library and not an application, use kodein-db-api-jvm instead, which only provides the Kodein-DB API, and not its implementation:

dependencies {
    implementation("org.kodein.db:kodein-db-api-jvm:0.8.1-beta")
}

Furthermore, you need to add the serializer you are going to use. When targetting JVM only, you can use either KotlinX.Serialization:

build.gradle.kts
dependencies {
    implementation("org.kodein.db:kodein-db-serializer-kotlinx:0.8.1-beta")
}

…​or Kryo (which is JVM & Android only):

build.gradle.kts
dependencies {
    implementation("org.kodein.db:kodein-db-serializer-kryo-jvm:0.8.1-beta")
}

Finally, you must add the OS specific leveldb native build dependency:

build.gradle.kts
dependencies {
    implementation("org.kodein.db:kodein-leveldb-jni-jvm-linux:0.8.1-beta")
    //                                                  -linux, -macos or -windows
}
If you are targeting multiple desktop OS, you can use the kodein-leveldb-jni-jvm dependency, which imports all three (Linux, MacOS & Windows) artifacts.