Installation

Kotlin Multiplatform

For shared models, Native targets and version-catalog configuration, see 📚Kotlin Multiplatform.

Runtime and compiler plugin

Add kronos-core for the ORM runtime and the Kronos compiler plugin for compile-time DSL support.

Use 0.4.0 for copyable dependency examples. Use the snapshot version only when you are testing unreleased source changes.

build.gradle.kts

plugins {
    kotlin("jvm") version "2.4.21"
    id("com.kotlinorm.kronos-gradle-plugin") version "0.4.0"
}

kotlin {
    compilerOptions {
        freeCompilerArgs.addAll("-Xcollection-literals", "-Xcontext-sensitive-resolution")
    }
}

dependencies {
    implementation("com.kotlinorm:kronos-core:0.4.0")
}

build.gradle

plugins {
    id 'org.jetbrains.kotlin.jvm' version '2.4.21'
    id 'com.kotlinorm.kronos-gradle-plugin' version '0.4.0'
}

kotlin {
    compilerOptions {
        freeCompilerArgs.addAll("-Xcollection-literals", "-Xcontext-sensitive-resolution")
    }
}

dependencies {
    implementation 'com.kotlinorm:kronos-core:0.4.0'
}

pom.xml

<project>
    <properties>
        <kotlin.version>2.4.21</kotlin.version>
        <kronos.version>0.4.0</kronos.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.kotlinorm</groupId>
            <artifactId>kronos-core</artifactId>
            <version>${kronos.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-maven-plugin</artifactId>
                <version>${kotlin.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <args>
                        <arg>-Xcollection-literals</arg>
                        <arg>-Xcontext-sensitive-resolution</arg>
                    </args>
                    <compilerPlugins>
                        <plugin>kronos-maven-plugin</plugin>
                    </compilerPlugins>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>com.kotlinorm</groupId>
                        <artifactId>kronos-maven-plugin</artifactId>
                        <version>${kronos.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
</project>

JDBC wrapper

Add kronos-jdbc-wrapper when the application uses JDBC DataSource objects directly. The wrapper executes generated SQL and maps rows back to KPojo objects.

Gradle

dependencies {
    implementation("com.kotlinorm:kronos-jdbc-wrapper:0.4.0")
}

Maven

<dependency>
    <groupId>com.kotlinorm</groupId>
    <artifactId>kronos-jdbc-wrapper</artifactId>
    <version>${kronos.version}</version>
</dependency>

For connection setup, see 📚Connect to DB. For Spring JDBC or other frameworks, see 📚Custom Wrapper.

Android SQLite

For Android/JVM and Android SQLiteDatabase setup, use the dedicated 📚Android SQLite chapter. It covers dependencies, the wrapper, transactions, logging, and the complete example.

Database driver and pool

Choose JDBC driver and connection-pool versions that match your database server and JDK. The <latest-stable> placeholders below represent the current stable third-party versions for your runtime environment.

MySQL example

dependencies {
    implementation("org.apache.commons:commons-dbcp2:<latest-stable>")
    implementation("com.mysql:mysql-connector-j:<latest-stable>")
}

Minimum environment

Make sure the Kotlin plugin used by your IDE supports Kotlin 2.4.21 or later.

Next, follow 📚First Query for the smallest model, table creation, insert, and select flow.