Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Coming from Gradle

Status: 🟡 The manual translations below work for the implemented feature set. ⚪ kargo migrate is planned.

If you know Gradle, the mapping is mostly mechanical. The mental shift is that a build is now data, not code.

Concepts

GradleKargo
build.gradle.ktsKargo.toml
settings.gradle.kts[workspace] in the root manifest
gradle/libs.versions.toml[catalog]
gradle.properties[build-config] and .kargo.env
gradlewNothing — Kargo is one binary
buildSrc, convention pluginsHooks and plugins
Task graphFixed build lifecycle
productFlavors[flavors], on every target
buildTypes[profile.*]
Gradle daemonNone

Commands

GradleKargo
./gradlew buildkargo build
./gradlew assembleReleasekargo build --release
./gradlew testkargo test
./gradlew test --tests "*MyTest*"kargo test --filter MyTest
./gradlew cleankargo clean
./gradlew dependencieskargo tree
./gradlew dependencyInsight --dependency xkargo tree --why x
./gradlew publishToMavenLocalkargo publish --repository local
./gradlew runkargo run
./gradlew :app:buildkargo build -p app
./gradlew --offline buildkargo build --offline
./gradlew build --scankargo build --timings

A JVM project

// build.gradle.kts
plugins {
    kotlin("jvm") version "2.4.21"
    application
}

group = "com.example"
version = "1.0.0"

repositories { mavenCentral() }

dependencies {
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0")
    testImplementation(kotlin("test"))
}

kotlin { jvmToolchain(25) }
application { mainClass.set("com.example.MainKt") }

becomes

[package]
name = "my-app"
group = "com.example"
version = "1.0.0"
kotlin = "2.4.21"
main-class = "com.example.MainKt"

[targets.jvm]
java-target = "25"

[dependencies]
kotlinx-coroutines-core = "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0"

[dev-dependencies]
kotlin-test = "org.jetbrains.kotlin:kotlin-test:2.4.21"

Three things disappeared: the plugin block (targets are declared, not applied), the repository block (Maven Central is the default), and the toolchain call (the compiler version is a field).

A multiplatform project

kotlin {
    jvm()
    iosArm64()
    iosSimulatorArm64()

    sourceSets {
        val commonMain by getting {
            dependencies { implementation("io.ktor:ktor-client-core:2.3.0") }
        }
        val jvmMain by getting {
            dependencies { implementation("io.ktor:ktor-client-okhttp:2.3.0") }
        }
    }
}

becomes

[targets]
jvm = { java-target = "25" }
ios-arm64 = {}
ios-simulator-arm64 = {}

[dependencies]
ktor-client-core = "io.ktor:ktor-client-core:2.3.0"

[target.jvm.dependencies]
ktor-client-okhttp = "io.ktor:ktor-client-okhttp:2.3.0"

Source sets are not configured at all — the directories already say what they are. See Project Layout.

Dependency configurations

GradleKargo
implementation[dependencies]
api[dependencies] — no separate concept
compileOnlyscope = "provided"
runtimeOnlyscope = "runtime"
testImplementation[dev-dependencies]
ksp[ksp]
kapt[kapt]
platform(...)scope = "import"

There is no api/implementation split. Gradle uses it to shrink consumers' compile classpaths; Kargo publishes compile-scoped POMs and relies on Kotlin's visibility modifiers. If a consumer should not see a type, make it internal.

Version catalogs

# gradle/libs.versions.toml
[versions]
ktor = "2.3.0"

[libraries]
ktor-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
# Kargo.toml
[catalog.versions]
ktor = "2.3.0"

[catalog.libraries]
ktor-core = { group = "io.ktor", artifact = "ktor-client-core", version.ref = "ktor" }

Same idea, module split into group and artifact. See Version Catalogs.

Automated migration

Status: ⚪ Planned.

kargo migrate

Reads build.gradle.kts, settings.gradle.kts, and gradle/libs.versions.toml, and writes a Kargo.toml plus a report of what it could not translate.

The limits are inherent, not incidental: a Gradle build script is a program, and anything computed at configuration time — a version read from a properties file, a dependency added inside a conditional, a custom task — cannot be expressed as data. Expect the manifest and dependencies to translate, and anything imperative to need a decision.

What does not translate

Gradle featureIn Kargo
Custom tasksHooks or subcommand plugins
doFirst / doLastHooks on the nearest lifecycle phase
Configuration-time logicNot supported, by design
Dynamic dependency versionsNot supported — versions are exact
Composite buildsWorkspaces
Third-party Gradle pluginsA Kargo plugin, or a hook calling the same tool

That last row is the real cost of migrating. A build leaning on several Gradle-ecosystem plugins has no drop-in equivalent, and that is a reason to stay on Gradle for that project rather than something to work around.

Running both during a transition

Nothing stops you. Gradle and Kargo read different manifests and write to different output directories. A pragmatic path: kargo init, get kargo build and kargo test green, run both in CI for a while, then delete the Gradle files once nothing depends on them.

Next