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

Pre-1.0 · Phase 5 in progress

Kargo

A build and dependency management tool for Kotlin, written in Rust. One declarative Kargo.toml describes your whole project, and a single native binary builds it.

If you have used Cargo, you already know how Kargo feels:

kargo new my-app
cd my-app
kargo add org.jetbrains.kotlinx:kotlinx-coroutines-core
kargo run

No wrapper script, no configuration phase, no build script language to learn.

Why Kargo

Kotlin's tooling is powerful but heavy. A new Kotlin project starts with a Gradle wrapper, two or three build scripts in a DSL that is itself a Kotlin program, a settings file, a version catalog, and a plugin block — before a single line of application code. Changing a dependency means editing a program, and understanding a build means reading one.

Kargo takes the opposite position: a build is configuration, not a program.

GradleKargo
ConfigurationKotlin/Groovy DSL scriptsDeclarative TOML
StartupJVM boot + script compilationNative binary, no configuration phase
DependenciesMaven repos via custom resolutionMaven repos via standard protocol
ToolchainYou install Kotlin and the JDKAuto-downloaded and pinned per project
MultiplatformFirst-class, plugin-configuredFirst-class, declared in the manifest
ComposePluginBuilt in
FlavorsAndroid-only (productFlavors)Every target
Lint and formatThird-party pluginsBuilt in
ExtensibilityFull programmatic powerSubcommands, scripts, hooks

What Kargo deliberately does not try to be is a general-purpose task runner. Gradle lets you express anything because a build script is code. Kargo covers the Kotlin build lifecycle declaratively and hands off the unusual cases to plugins and hooks. If your build genuinely needs arbitrary programmable task graphs, Gradle is the right tool and Kargo will not replace it.

Who this is for

  • Kotlin/JVM application and library authors who want a build file they can read.
  • Kotlin Multiplatform teams tired of configuring source-set hierarchies by hand.
  • Compose Multiplatform developers who want one target list, not one plugin per target.
  • Android-adjacent projects that need build flavors without the whole Android Gradle Plugin.

How these docs are organized

  • Getting Started — install Kargo, create a project, understand the layout it generates.
  • Using Kargo — task-oriented guides. Start here for "how do I…" questions: add a dependency, build a variant, publish, wire up CI.
  • Reference — the exhaustive detail. Every command, every manifest key, every environment variable.
  • How Kargo Works — what happens between kargo build and a JAR. Useful when something surprises you; not required reading.
  • Contributing — for people working on Kargo itself.

A note on status

Kargo is pre-1.0 and under active development. These docs describe the tool Kargo is being built to be — it is the specification the implementation works toward, not a report on what compiled this morning. Features that do not fully exist yet are marked, so you can tell the difference at a glance:

MarkerMeaning
🟢 ImplementedWorks today. Behaves as documented, bugs aside.
🟡 PartialPartly working. The page says exactly which part.
⚪ PlannedSpecified and designed, not yet built.

Every page opens with its status. The Implementation Status page collects all of them in one table alongside the roadmap, and is the single source of truth when a page and your terminal disagree.

Getting help

License

Kargo is dual-licensed under MIT or Apache-2.0, at your option.

Implementation Status

These docs describe Kargo as designed. This page tracks how much of it runs today.

When a page and your terminal disagree, this table is right.

MarkerMeaning
🟢 ImplementedWorks today. Behaves as documented, bugs aside.
🟡 PartialPartly working. The notes say which part.
⚪ PlannedSpecified and designed, not yet built. Commands exit with "not yet implemented".

Last reviewed against the source tree at version 0.2.0.

Project setup

FeatureStatusNotes
kargo new / kargo init🟢All five templates generate and build.
Templates jvm, lib, kmp, cmp, android🟢Embedded in the binary; no network needed.
Manifest parsing🟢The full Kargo.toml schema parses, including sections not yet acted on.
${env:…} interpolation🟢Resolved at manifest load.
.kargo.env loading🟢
kargo env🟢Masked by default, --reveal to show.

Dependencies

FeatureStatusNotes
kargo add / remove🟢Format-preserving manifest edits.
kargo fetch / lock / update🟢
kargo tree🟢Including --why, --conflicts, --licenses, --duplicates, --inverted.
kargo outdated🟢
kargo audit🟢Live queries against the OSV database.
Maven resolution🟢POM inheritance, BOM imports, nearest-wins mediation, scopes, exclusions.
Lockfile🟢Deterministic and checksummed.
Version catalogs🟡[catalog] parses; { catalog = … } references are not resolved yet.
Gradle Module Metadata🟡Parsed where present; not yet used for variant-aware selection.
Offline mode🟢--offline on build and fetch.

Building

FeatureStatusNotes
kargo build🟢One target per invocation.
kargo run🟢JVM targets.
kargo check🟢
kargo clean🟢
kargo watch🟢
Incremental compilation🟢Fingerprint-based unit skipping.
Parallel compilation⚪Single-threaded. One unit per build, and -Xbackend-threads is unsafe in the supported Kotlin versions, so [build] jobs bounds nothing.
Local build cache🟢kargo cache stats / clean / push.
Remote build cache⚪[cache] keys parse; no transport yet.
Build profiles🟢dev and release, plus custom profiles.
KSP annotation processing🟢Processor toolchain is fetched and run before the main compile; generated sources are fed back in.
KAPT annotation processing🟢Stubs, [kapt-options], and processor-named errors all work, and KAPT runs alongside KSP in one build. Every pass is a full pass — no incremental processing — and javac options have no manifest key.
--timings🟢Text output. The HTML timeline is planned.
JVM target🟢
Android JVM target🟡Compiles against android.jar and .aar dependencies; no resource or manifest merging.
JS target🟡Compiler backend exists; not reachable from a multi-target build yet.
Native targets🟡Compiler backend exists; not reachable from a multi-target build yet.
WebAssembly targets⚪
Multi-target builds🟡Targets build one at a time via --target; no single-pass KMP build.
Source-set hierarchy inference🟢Intermediate sets are inferred from the target list, a build compiles the chain for its own target, and resources merge along it.
Explicit [source-sets.*]🟢Declared directories, parents and target groupings replace what the conventions infer.
expect/actual validation⚪
CInterop⚪[target.*.cinterop] parses.
Compose Multiplatform⚪[compose] parses and source-set discovery knows about Compose resources, but the compiler-plugin module is a stub.
Flavors and variants🟡[flavors] parses and BuildConfig generation exists, but --flavor, --variant, and --all-variants are accepted and ignored.

Testing and quality

FeatureStatusNotes
kargo test🟡Runs JVM tests with --target and --filter. --coverage, --report, --parallel, --flavor, --repeat, and --fail-fast are not implemented.
Coverage⚪[test.coverage] parses.
kargo bench⚪
kargo lint⚪The kargo-lint crate is scaffolded; the rule modules are stubs.
kargo fmt⚪The formatter module is a stub.
kargo fix⚪

Toolchains

FeatureStatusNotes
Kotlin auto-download🟢From JetBrains releases or a configured mirror.
kargo toolchain …🟢install, list, remove, use, path.
JDK discovery🟢JAVA_HOME, .kargo.env, common install paths.
JDK installation🟢kargo toolchain install --jdk [version].
Android SDK discovery🟢ANDROID_HOME / ANDROID_SDK_ROOT / .kargo.env.
Apple SDK discovery🟢Via xcrun.
Android SDK installation🟢kargo toolchain install --android [level].
Kotlin compile daemon🟢Reused across builds; kargo cache stop-daemon stops it.
kargo self update🟢

Distribution

FeatureStatusNotes
kargo publish⚪kargo-maven has the module in place but it returns "not yet implemented".
kargo login⚪
kargo package⚪
Docker packaging⚪
XCFramework packaging⚪
Artifact signing⚪[signing] parses.
Prebuilt binary releases🟢Five targets plus sha256sums.txt, published with every release.

Extensibility and tooling

FeatureStatusNotes
Hooks⚪[hooks] parses; the kargo-plugin crate is scaffolded with stub modules.
Subcommand plugins⚪
Script plugins⚪Loader and sandbox modules are scaffolded stubs.
WASM plugins⚪Design only.
kargo metadata⚪
kargo lsp⚪
kargo doctor⚪
kargo migrate⚪
kargo doc⚪
kargo repl / kargo script⚪
kargo completions🟢bash, zsh, fish, powershell, elvish. Static scripts; plugin subcommands are not completed.
Workspaces🟡[workspace] parses; member builds are not orchestrated.

Roadmap

Phases are delivery order, not dates.

PhaseScopeStatus
1. FoundationCore types, manifest parsing, templates, new / init / clean / env🟢 Done
2. ToolchainKotlin auto-download, JDK and SDK discovery, toolchain commands🟢 Done
3. Maven and resolutionPOM parsing, resolution, lockfile, add / tree / outdated / audit🟢 Done
4. Compilationkotlinc invocation, incremental builds, build cache, build / run / test / check🟢 Done
5. KMP, Compose, flavorsMulti-target builds, source-set hierarchy, Compose plugin, variants🟡 In progress
6. Code qualityLinter, formatter, coverage, benchmarks⚪ Planned
7. Plugins and hooksHook lifecycle, subcommand discovery, script plugins⚪ Planned
8. PackagingFat JAR, Docker, XCFramework, signing, publishing⚪ Planned
9. Security and insightOffline hardening, dependency insights, audit policy⚪ Planned
10. IDE and DXmetadata, LSP, doctor, migrate, completions🟡 In progress

Keeping this honest

If a feature marked 🟢 here does not work, that is a bug worth filing — either in the code or in this table. Both are mistakes.

Installation

Status: 🟢 Implemented. See Implementation Status.

Kargo is a single native binary. It brings its own Kotlin compiler, so Kotlin is the one thing you do not need to install first.

Prerequisites

RequirementWhy
A JDK (17 or newer)Needed to run the Kotlin compiler and JVM builds. Kargo discovers one, or installs it on request.

That is the whole list. Everything else — the Kotlin compiler, and the Compose compiler plugin when you enable it — Kargo downloads on demand. Rust is needed only if you choose to build from source.

Download a prebuilt binary

Five platforms are published with every release, each as a single-file archive:

PlatformAsset
Linux, x86-64kargo-x86_64-unknown-linux-gnu.tar.gz
Linux, ARM64kargo-aarch64-unknown-linux-gnu.tar.gz
macOS, Apple siliconkargo-aarch64-apple-darwin.tar.gz
macOS, Intelkargo-x86_64-apple-darwin.tar.gz
Windows, x86-64kargo-x86_64-pc-windows-msvc.zip

Every release also publishes sha256sums.txt, covering all five. The commands below verify against it before installing — one extra line, for a binary you are about to put on your PATH.

Linux (swap x86_64 for aarch64 on ARM):

base=https://github.com/dejanradmanovic/kargo/releases/latest/download
asset=kargo-x86_64-unknown-linux-gnu.tar.gz

curl -fsSLO "$base/$asset"
curl -fsSLO "$base/sha256sums.txt"
sha256sum --ignore-missing --check sha256sums.txt   # must print: OK

tar xzf "$asset"
install -Dm755 kargo ~/.local/bin/kargo

macOS (swap aarch64 for x86_64 on Intel):

base=https://github.com/dejanradmanovic/kargo/releases/latest/download
asset=kargo-aarch64-apple-darwin.tar.gz

curl -fsSLO "$base/$asset"
curl -fsSLO "$base/sha256sums.txt"
shasum -a 256 --ignore-missing --check sha256sums.txt   # must print: OK

tar xzf "$asset"
sudo install -m 755 kargo /usr/local/bin/kargo

The binaries are not notarized, so the first run may be blocked by Gatekeeper. Clear it with xattr -d com.apple.quarantine /usr/local/bin/kargo.

Windows (PowerShell):

$base  = "https://github.com/dejanradmanovic/kargo/releases/latest/download"
$asset = "kargo-x86_64-pc-windows-msvc.zip"

Invoke-WebRequest "$base/$asset" -OutFile $asset
Invoke-WebRequest "$base/sha256sums.txt" -OutFile sha256sums.txt

# Compare the archive's hash with its row in sha256sums.txt.
$want = (Select-String -Path sha256sums.txt -SimpleMatch $asset).Line.Split()[0]
$got  = (Get-FileHash $asset -Algorithm SHA256).Hash.ToLower()
if ($want -ne $got) { throw "checksum mismatch for $asset" }

Expand-Archive $asset -DestinationPath "$env:LOCALAPPDATA\Kargo" -Force

Then add %LOCALAPPDATA%\Kargo to your PATH.

To pin a version rather than take the newest, replace latest/download with download/v0.2.0.

Confirm it works:

kargo --version

Install from source

For a platform with no published binary, or to run an unreleased main. This path needs Rust 1.91 or newer (rustup) and Git. The Rust floor tracks [workspace.package].rust-version in the repository, so if cargo install reports an unsupported edition or a missing feature, run rustup update stable first.

git clone https://github.com/dejanradmanovic/kargo.git
cd kargo
cargo install --path crates/kargo-cli

This builds in release mode and drops the kargo binary in ~/.cargo/bin.

Make sure that directory is on your PATH:

# bash / zsh
export PATH="$HOME/.cargo/bin:$PATH"
# PowerShell
$env:PATH = "$HOME\.cargo\bin;$env:PATH"

Install a specific revision from source

To pin a commit or tag rather than tracking main:

cargo install --git https://github.com/dejanradmanovic/kargo \
  --tag v0.2.0 \
  kargo-cli

What Kargo writes to disk

Kargo keeps everything it downloads under one directory, so uninstalling is a single rm -rf.

PathContents
~/.kargo/toolchains/Downloaded Kotlin compilers, one directory per version
~/.kargo/cache/Maven artifact cache, mirroring the Maven repository layout
~/.kargo/build-cache/Content-addressed compiled outputs
~/.kargo/config.tomlYour global configuration

On Windows these live under %USERPROFILE%\.kargo\.

Nothing is written outside that directory and your project's build/ folder.

Updating

kargo self update

self update also regenerates the completion scripts it installed, so they describe the binary you now have. Re-running the download or rebuilding from source does not — run kargo completions <shell> --install again after either.

Or re-run the download above: latest/download always resolves to the newest release. From a source checkout:

git pull && cargo install --path crates/kargo-cli --force

Uninstalling

Remove the binary, then the one directory Kargo writes to:

rm -f ~/.local/bin/kargo       # or /usr/local/bin/kargo
rm -rf ~/.kargo

Installed from source instead? cargo uninstall kargo-cli removes the binary.

Platform notes

Linux — No extra setup. For Android targets, set ANDROID_HOME or add ANDROID_SDK=/path/to/sdk to your project's .kargo.env.

macOS — Install the Xcode command line tools (xcode-select --install) before building Apple targets. Kargo locates SDKs through xcrun.

Windows — Builds and runs natively; no WSL required. Paths in Kargo.toml use forward slashes and are normalized for you. Native Kotlin targets are not supported on Windows hosts.

Shell completions

Status: 🟢 Implemented.

--install writes the script where your shell reads it and prints anything left to do. bash, zsh, fish, powershell and elvish are accepted:

kargo completions bash --install

That is the whole setup for bash and fish: both load the directory the script lands in. Start a new shell and press Tab.

zsh installs to ~/.zfunc/_kargo, which zsh reads only if the directory is on $fpath. Add this to ~/.zshrc above its compinit line — compinit builds the completion table, so a line below it comes too late:

fpath=(~/.zfunc $fpath)

powershell and elvish have no completions directory, so their scripts go under ~/.kargo/completions/ and the install output prints the one line to add — a dot-source line for $PROFILE, an eval line for ~/.config/elvish/rc.elv. For PowerShell, $PROFILE may not exist yet; New-Item -Type File -Force $PROFILE creates it.

Installing again replaces the script, and kargo self update does that for every shell you installed this way, so an upgrade never leaves you completing commands the binary no longer has.

Without --install the script goes to stdout, which is what you want for a system-wide install or a path of your own:

kargo completions bash | sudo tee /etc/bash_completion.d/kargo > /dev/null
kargo completions powershell | Out-String | Invoke-Expression   # this session only

Scripts installed by hand are not refreshed on upgrade; regenerate them yourself. Completions cover kargo's own commands and flags — subcommands provided by plugins are not completed yet.

Next steps

Create something: Your First Project.

Your First Project

Status: 🟢 Implemented — everything on this page works today.

This is a ten-minute tour: scaffold a JVM application, run it, add a dependency, run its tests, and build a release. By the end you will have touched most of the commands you use daily.

Create the project

kargo new hello-kargo
cd hello-kargo

You get a complete, buildable project — source, test, and manifest:

hello-kargo/
├── Kargo.toml                                   # the manifest — the only file you configure
├── Kargo.lock                                   # resolved dependency versions
├── .gitignore
├── .kargo.env                                   # machine-local secrets (gitignored)
└── src/
    ├── main/kotlin/com/example/Main.kt
    ├── main/resources/application.properties
    └── test/kotlin/com/example/MainTest.kt

No wrapper scripts, no settings file, no buildSrc.

Read the manifest

[package]
name = "hello-kargo"
group = "com.example"
version = "0.1.0"
kotlin = "2.4.21"
main-class = "com.example.MainKt"

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

[dependencies]

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

Five facts: what the package is called, where it publishes to, which Kotlin compiler to use, what it compiles to, and what it depends on. That is the whole build.

The kotlin field is binding. Kargo downloads that exact compiler version the first time you build and caches it under ~/.kargo/toolchains/ — so every machine and CI runner builds with the same compiler, with nothing to install.

main-class is the JVM entry point. A top-level fun main() in Main.kt with package com.example compiles to the class com.example.MainKt.

Run it

kargo run

The generated Main.kt prints a greeting:

package com.example

fun greet(name: String = "World"): String = "Hello, $name!"

fun main() {
    println(greet("hello-kargo"))
}
  Downloading Kotlin 2.4.21 (first run only)
    Resolving dependencies
     Compiling hello-kargo v0.1.0 (jvm, dev)
      Finished dev profile in 2.41s
       Running `hello-kargo`
Hello, hello-kargo!

The first run downloads a compiler, so it is the slow one. Run it again and nothing recompiles:

      Finished dev profile in 0.08s
       Running `hello-kargo`
Hello, hello-kargo!

See Incremental Compilation for how that decision gets made.

Run the tests

The template ships tests, so there is nothing to wire up:

kargo test
     Compiling hello-kargo v0.1.0 (jvm, dev)
       Running 3 tests
test com.example.GreetTest.greet with default name ... ok
test com.example.GreetTest.greet with custom name ... ok
test com.example.GreetTest.greet with empty name ... ok

test result: ok. 3 passed; 0 failed; 0 skipped; finished in 0.04s

kotlin-test is already in [dev-dependencies]. Add your own case to src/test/kotlin/com/example/MainTest.kt:

@Test
fun `greet trims nothing`() {
    assertEquals("Hello,  !", greet(" "))
}

Narrow a run with --filter:

kargo test --filter GreetTest

Add a dependency

kargo add org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0
      Adding kotlinx-coroutines-core v1.8.0 to dependencies
    Resolving dependencies
       Locked 4 packages

Your manifest gains one line. Comments and formatting elsewhere are preserved, because Kargo edits the TOML tree rather than rewriting the file:

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

The key is the artifact id. It is a local alias — rename it to anything you like and the coordinate on the right is what resolves.

Now use it:

package com.example

import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking

fun greet(name: String = "World"): String = "Hello, $name!"

fun main() = runBlocking {
    println("Starting...")
    delay(100)
    println(greet("coroutine"))
}
kargo run

Note what you did not do: no plugin block, no repository declaration, no implementation versus api decision. Maven Central is configured by default and the coordinate is the whole story.

See where it came from

kargo tree
hello-kargo v0.1.0
├── org.jetbrains.kotlinx:kotlinx-coroutines-core v1.8.0
│   └── org.jetbrains.kotlin:kotlin-stdlib v1.9.21
└── [dev] org.jetbrains.kotlin:kotlin-test v2.4.21

When a transitive version surprises you, ask why:

kargo tree --why kotlin-stdlib

And before you ship, check the graph for known vulnerabilities:

kargo audit

Build a release

kargo build --release

Output is keyed by target and profile, so switching profiles never invalidates the other:

build/
├── jvm/dev/
│   └── output/hello-kargo-0.1.0.jar
└── jvm/release/
    └── output/hello-kargo-0.1.0.jar

Two more commands you will reach for constantly:

kargo check     # type-check only, no artifacts — the fast feedback loop
kargo clean     # delete build/ and cached fingerprints

kargo clean --variant jvm/dev clears just one target-and-profile pair.

Keep it building while you work

kargo watch

Recompiles on every save. Add --build-only to skip the run step.

If you want to…Go to
Understand every manifest keyThe Manifest
Manage dependencies properlyDependencies
Start a library instead of an appProject Templates
Target iOS, JS, or Android tooKotlin Multiplatform
Build a Compose UICompose Multiplatform
Know what each directory is forProject Layout

Project Templates

Status: 🟢 Implemented — all seven templates work. They are embedded in the binary, so scaffolding needs no network.

kargo new and kargo init both take a --template (short -t) flag:

kargo new my-app                       # jvm (default)
kargo new my-lib     --template lib
kargo new my-shared  --template kmp
kargo new my-ui      --template cmp
kargo new my-droid   --template android
kargo new my-api     --template ktor
kargo new my-service --template spring

Run kargo new with no arguments and it asks instead: a prompt for the project name, then a list to pick the template from. Give it a name and it scaffolds without asking, so scripts and CI are unaffected — and with no terminal to ask, a missing name is an error.

TemplateProducesTargets
jvmJVM application with an entry pointjvm
libJVM library, no entry pointjvm
kmpKotlin Multiplatform libraryjvm, ios-arm64, ios-simulator-arm64
cmpCompose Multiplatform appjvm, android, ios-arm64, ios-simulator-arm64
androidAndroid applicationandroid
ktorKtor HTTP service, JSON over kotlinx.serializationjvm
springSpring Boot web service, Spring MVC and Tomcatjvm

Every template pins the same defaults: Kotlin 2.4.21, java-target 25, Android min-sdk 24 and compile-sdk/target-sdk 36. These track the current stable Kotlin release and the current Java LTS; the Android floor is deliberately conservative for device coverage.

new versus init

kargo new <name>kargo init
Creates a directoryYes, named <name>No, uses the current one
Writes source filesYesNo
Overwrites existing filesN/ANever

kargo init is the one to use on an existing codebase: it writes Kargo.toml, Kargo.lock, .gitignore, and .kargo.env, and leaves your sources alone. Point the manifest at your existing layout afterward if it does not match the conventional one.

cd existing-kotlin-project
kargo init --template kmp

jvm (default)

A runnable application with a working test suite.

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

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

[dependencies]

[dev-dependencies]
kotlin-test = "org.jetbrains.kotlin:kotlin-test:2.4.21"
src/
├── main/kotlin/com/example/Main.kt          # greet() + main()
├── main/resources/application.properties
└── test/kotlin/com/example/MainTest.kt      # three passing tests

Start here for CLIs, servers, and anything with a main.

lib

The same shape without an entry point: no main-class, no main(), no resources. src/main/kotlin/Lib.kt holds a single exported function to replace.

Use it for code you intend to publish. Libraries should commit Kargo.toml but think twice about committing Kargo.lock — see Dependencies.

kmp

A Kotlin Multiplatform library targeting the JVM and iOS:

[targets]
jvm = { java-target = "25" }
ios-arm64 = {}
ios-simulator-arm64 = {}
src/
├── commonMain/kotlin/Greeting.kt     # shared code
├── commonMain/resources/
├── commonTest/kotlin/
├── jvmMain/kotlin/
├── jvmTest/kotlin/
├── iosMain/kotlin/
└── iosTest/kotlin/

Shared code goes in commonMain. Platform code goes in jvmMain or iosMain and fills in expect declarations. Add more targets with a line in [targets] and a matching directory — see Kotlin Multiplatform.

cmp

Compose Multiplatform across JVM, Android, iOS, and desktop, with [compose] enabled = true already set:

[targets]
jvm = { java-target = "25" }
android = { min-sdk = 24, target-sdk = 36, compile-sdk = 36 }
ios-arm64 = {}
ios-simulator-arm64 = {}

[compose]
enabled = true

src/commonMain/kotlin/App.kt contains a centered Text composable to build on, and per-platform source sets (jvmMain, androidMain, iosMain, desktopMain) are scaffolded for the entry points each platform needs.

Kargo fetches the Compose compiler plugin itself — there is no plugin block to declare. See Compose Multiplatform.

android

An Android-only application: AndroidManifest.xml, a MainActivity, and a res/ directory.

[targets.android]
min-sdk = 24
target-sdk = 36
compile-sdk = 36
src/
├── main/AndroidManifest.xml
├── main/kotlin/MainActivity.kt
├── main/res/
└── test/kotlin/

The template declares androidx.appcompat:appcompat and Google's Maven repository, which is where AndroidX is published.

Kargo locates your Android SDK through ANDROID_HOME, ANDROID_SDK_ROOT, or ANDROID_SDK in .kargo.env, and installs the platform for compile-sdk if it is missing.

Status: 🟡 The Android target compiles Kotlin against the Android SDK and .aar dependencies. Resource compilation, manifest merging, and APK or AAB packaging are planned.

ktor

An HTTP service with JSON content negotiation and a test that drives the real module through testApplication, so nothing is stubbed and no port is bound.

[build-config]
DEFAULT_HOST = "0.0.0.0"
DEFAULT_PORT = "8080"

[build-config] becomes a generated BuildConfig object the code reads, and the environment overrides it at startup:

val host = System.getenv("HOST") ?: BuildConfig.DEFAULT_HOST
val port = System.getenv("PORT")?.toIntOrNull() ?: BuildConfig.DEFAULT_PORT.toInt()

The same build then runs locally and in a container without a rebuild: HOST=127.0.0.1 PORT=9090 kargo run is the whole of it.

The jar kargo build writes holds this project's classes and resources, not Ktor or the Kotlin runtime, so deploying it means launching it with the dependency classpath alongside — kargo run assembles that for you. A self-contained archive is planned.

spring

Spring Boot with Spring MVC, embedded Tomcat, and a @SpringBootTest that boots the context and drives the pipeline through MockMvc.

Two things differ from a Gradle-generated Spring project, both of them visible in what is scaffolded:

  • open class Application. Spring proxies configuration classes with CGLIB, which cannot subclass a final class, and a Kotlin class is final by default. Gradle projects get this from the kotlin-spring compiler plugin; Kargo has no equivalent yet, so the class says open itself.
  • kotlin-reflect is declared. Spring reads Kotlin constructors and nullability through it, and Kargo puts nothing on the classpath that the manifest does not ask for.

HOST and PORT reach Spring as its lowest-precedence defaults, so a property file, an environment variable or a command-line argument all still win:

runApplication<Application>(*args) {
    setDefaultProperties(
        mapOf(
            "server.address" to (System.getenv("HOST") ?: BuildConfig.DEFAULT_HOST),
            "server.port" to (System.getenv("PORT") ?: BuildConfig.DEFAULT_PORT)
        )
    )
}

Choosing between them

You are buildingTemplate
A CLI or serverjvm
A library for other JVM projectslib
Logic shared between an iOS and an Android appkmp
An app with one UI across platformscmp
An Android-only appandroid
An HTTP service on a coroutine-native stackktor
An HTTP service on the Spring ecosystemspring

Nothing is locked in. Templates only write the first version of your manifest — adding a target later is one line in [targets].

Custom templates

Status: ⚪ Planned.

Project templates are TOML documents describing a manifest, directories, and files with {{placeholder}} substitution. Loading them from a path or a Git repository is planned:

kargo new my-app --template ./company-template.toml
kargo new my-app --template github:acme/kargo-templates#service

Project Layout

Status: 🟢 Implemented for JVM and single-target layouts. 🟡 Multiplatform and flavor source sets are discovered but not yet fully composed — see Implementation Status.

Kargo discovers sources by convention. There is no sourceSets { } block to write: put a file in the right directory and it compiles.

JVM projects

my-project/
├── Kargo.toml              # manifest (required)
├── Kargo.lock              # resolved versions
├── .kargo.env              # machine-local secrets (gitignored)
├── .gitignore
├── src/
│   ├── main/kotlin/        # production code
│   ├── main/resources/     # bundled resources
│   ├── test/kotlin/        # tests
│   └── test/resources/     # test fixtures
└── build/                  # output (gitignored)

This is the Maven and Gradle layout, so an existing JVM project usually needs nothing moved.

Multiplatform projects

Targets get one source set each, plus commonMain for shared code:

my-kmp-project/
├── Kargo.toml
├── src/
│   ├── commonMain/kotlin/        # compiled into every target
│   ├── commonMain/resources/
│   ├── commonTest/kotlin/
│   ├── jvmMain/kotlin/
│   ├── jvmTest/kotlin/
│   ├── iosMain/kotlin/
│   ├── iosTest/kotlin/
│   ├── jsMain/kotlin/
│   └── composeResources/         # Compose Multiplatform assets
│       ├── drawable/
│       ├── font/
│       └── values/strings.xml
└── build/

The directory name is the contract: src/<sourceSetName>/kotlin, where the source set name is the target name in camelCase plus Main or Test. ios-arm64 contributes to iosArm64Main, and also to the shared iosMain through the source-set hierarchy.

Build output

Output is keyed by target and profile so the two never collide:

build/
├── jvm/
│   ├── dev/
│   │   ├── classes/                       # compiled .class files
│   │   └── output/my-app-0.1.0.jar
│   └── release/
│       ├── classes/
│       └── output/my-app-0.1.0.jar
└── ios-arm64/
    └── dev/

What incremental builds need lives under .kargo/ — fingerprints in fingerprints/, the compiler's own caches in incremental/ — so that build/ holds output alone. kargo clean removes both, and a variant clean removes that variant's share of them.

kargo clean                      # everything
kargo clean --variant jvm/dev    # one target and profile

Flavored projects

Status: 🟡 Flavor source sets are specified and parsed; the build path does not compose them yet.

With flavors, each flavor can contribute its own sources, merged over the common ones:

src/
├── main/kotlin/              # all variants
├── freeMain/kotlin/          # tier=free only
├── freeMain/resources/       # e.g. a different app icon
├── paidMain/kotlin/          # tier=paid only
├── stagingMain/kotlin/       # environment=staging only
├── productionMain/kotlin/
└── freeStagingMain/kotlin/   # one exact combination (rare)

Merge order is common → dimension flavor → exact variant, each layer able to override the one before it. Flavored output goes to build/<variant>/<target>/.

Multiplatform and flavors compose, most specific last:

src/
├── commonMain/kotlin/        # every target, every flavor
├── jvmMain/kotlin/           # JVM, every flavor
├── freeMain/kotlin/          # free, every target
├── freeJvmMain/kotlin/       # free, JVM only
└── paidIosMain/kotlin/       # paid, iOS only

Files Kargo owns

FileCommit it?Notes
Kargo.tomlYesYour project's definition.
Kargo.lockApplications yes, libraries usually notWhy.
.kargo.envNeverSecrets. kargo new gitignores it for you.
build/NoGenerated.
.kargo/NoFingerprints, incremental state, cached dependencies.

The generated .gitignore already covers the last three.

Overriding the conventions

When an existing layout cannot move, declare it instead:

[source-sets.jvmMain]
kotlin = ["legacy/src/java", "generated/kotlin"]
resources = ["legacy/src/resources"]

Paths are relative to the project root, and a key you leave out keeps the convention. Full detail in the Source Sets reference.

The Manifest

Status: 🟢 Implemented — the entire Kargo.toml schema parses and validates today, including sections that later phases will act on. The Manifest Format reference marks which sections affect a build right now.

Kargo.toml is the only file you configure. This page is the guided tour; the reference has every key.

The smallest valid manifest

[package]
name = "my-app"
version = "0.1.0"
kotlin = "2.4.21"

[targets.jvm]

Four lines: an identity, a compiler version, and something to compile for. Every other section is optional.

A realistic one

[package]
name = "my-service"
group = "com.example"
version = "1.2.0"
kotlin = "2.4.21"
description = "Order processing service"
authors = ["Jane Doe <jane@example.com>"]
license = "Apache-2.0"
repository = "https://github.com/example/my-service"
main-class = "com.example.MainKt"

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

[dependencies]
ktor-server-core = "io.ktor:ktor-server-core:2.3.0"
kotlinx-coroutines-core = "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0"

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

[plugins]
serialization = "org.jetbrains.kotlin.plugin.serialization"

[profile.release]
optimization = true

[lint]
rules = ["naming", "style", "complexity"]

Read top to bottom, that is: who I am, what I compile to, what I need, what I need to test, which compiler plugins to apply, how release differs from dev, and how strict to be about style.

Sections at a glance

SectionPurposeGuide
[package]Identity, version, metadata, entry pointbelow
[targets]What to compile forTargets
[dependencies], [dev-dependencies]What you depend onDependencies
[target.<name>.dependencies]Per-target dependenciesMultiplatform
[flavor.<name>.dependencies]Per-flavor dependenciesFlavors
[compose]Enable Compose MultiplatformCompose
[plugins]Kotlin compiler pluginsbelow
[ksp], [kapt]Annotation processorsbelow
[build-config]Compile-time constantsbelow
[flavors]Build flavor dimensionsFlavors
[profile.*]Debug and optimization settingsProfiles
[repositories]Where to fetch artifactsDependencies
[workspace]Multi-module projectsWorkspaces
[catalog]Shared version definitionsVersion Catalogs
[toolchain]JDK and Kotlin overridesToolchains
[test]Coverage thresholdsTesting
[lint], [format]Code quality rulesLint and Format
[hooks]Commands at lifecycle pointsPlugins and Hooks
[signing]Publishing signaturesPublishing
[package.docker]Container image settingsPackaging

[package]

FieldRequiredNotes
nameYesAlphanumeric, -, _. Validated on load.
versionYesMust parse as semver.
kotlinYesExact compiler version; downloaded if absent.
groupFor publishingMaven group id, e.g. com.example.
main-classFor kargo runJVM entry point, e.g. com.example.MainKt.
description, authors, license, repositoryNoMetadata, carried into published POMs.
ksp-versionNoPins the KSP processor API version.

name and version are validated when the manifest loads, not when you build, so a typo fails immediately with a pointed error rather than halfway through a compile.

A top-level fun main() in Foo.kt with package com.example compiles to com.example.FooKt — that is the string main-class wants.

[targets]

One target, as a subtable:

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

Several, as an inline table each:

[targets]
jvm = { java-target = "25" }
android = { min-sdk = 24, target-sdk = 36, compile-sdk = 36 }
ios-arm64 = {}
ios-simulator-arm64 = {}
js = { module-kind = "es" }

{} means "this target, default settings". Target names accept kebab-case or camelCase — ios-arm64 and iosArm64 are the same target. The full list is in the Targets reference.

Dependencies in three forms

[dependencies]
# 1. Coordinate shorthand — what you will use 95% of the time
kotlinx-coroutines-core = "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0"

# 2. Detailed, when you need scope, exclusions, or a classifier
my-lib = { group = "com.example", artifact = "my-lib", version = "1.0.0", scope = "runtime" }

# 3. From a version catalog
ktor-server = { catalog = "ktor-server", bundle = true }

The key on the left is a local alias. It is what kargo remove takes and what appears in kargo tree output; it has no effect on resolution. See Dependencies.

[plugins]

Kotlin compiler plugins, by id:

[plugins]
serialization = "org.jetbrains.kotlin.plugin.serialization"
parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version = "2.4.21" }

Omit the version and the plugin tracks package.kotlin, which is almost always what you want — a compiler plugin built against a different compiler than the one compiling your code is a reliable source of confusing failures.

Compose is not listed here. It has its own section because Kargo manages the plugin for you.

Annotation processing

KSP processors, and KAPT for libraries that have not migrated:

[ksp]
room-compiler = "androidx.room:room-compiler:2.6.1"

[ksp-options]
"room.schemaLocation" = "build/schemas"

[kapt]
dagger-compiler = "com.google.dagger:dagger-compiler:2.59.2"

[kapt-options]
"dagger.fastInit" = "enabled"

Processors run before the main compile, and generated sources are fed back into it. Both tools can run in the same build; each runs only the processors its own section declares.

Prefer KSP. It is faster, it processes only what changed, and it does not need the Java stub-generation pass that KAPT runs over every source in the target. KAPT is here for processors that have not migrated — see [kapt] for what that pass does and what it does not do.

[build-config]

Compile-time constants, available to your Kotlin code as a generated BuildConfig object:

[build-config]
API_VERSION = "v2"
TELEMETRY_ENABLED = "false"
if (BuildConfig.TELEMETRY_ENABLED.toBoolean()) { … }

Values support ${env:VAR} interpolation. Flavors can add to and override these per variant.

This is for configuration you want baked into the binary. Build-time secrets belong in .kargo.env instead — anything in [build-config] is committed and shipped.

Environment interpolation

Any string value can reference an environment variable or a .kargo.env entry:

[repositories]
internal = { url = "https://nexus.example.com/maven", username = "${env:NEXUS_USER}", password = "${env:NEXUS_PASS}" }

Interpolation happens when the manifest loads, before parsing. So you can interpolate anything — a version, a URL, a path — not just credentials.

Design notes

TOML, not a DSL. A manifest is data. It can be read by tools, diffed usefully, and edited by kargo add without reformatting the file, because kargo add rewrites the TOML tree rather than the text.

Deterministic ordering. Every map in the manifest is stored sorted, so serialized output and lockfiles are byte-stable across runs and machines.

Parse everything, act on what exists. Sections for unbuilt features still parse and validate. You can write a complete, forward-looking manifest today; Kargo warns rather than failing on sections it cannot act on yet. Check Implementation Status for which is which.

Next

Dependencies

Status: 🟢 Implemented — add, remove, update, fetch, lock, tree, outdated, and audit all work. 🟡 Version catalog references do not resolve yet; see Version Catalogs.

Kargo speaks Maven. Any artifact you can use from Gradle or Maven, you can use from Kargo — same coordinates, same repositories, same resolution semantics.

Adding

kargo add org.jetbrains.kotlinx:kotlinx-coroutines-core

Leave the version out and Kargo asks the repositories for the current release, then writes the version it found:

       Added org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2 (latest) to [dependencies]

It never picks a snapshot, so the version you get is one a plain kargo build can resolve. Pin a version instead by naming it, in the coordinate or as a flag:

kargo add org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0
kargo add org.jetbrains.kotlinx:kotlinx-coroutines-core --version 1.8.0

Either way Kargo verifies the artifact exists, resolves its transitive graph, updates Kargo.toml and Kargo.lock, and leaves the rest of your manifest formatting untouched. New entries are inserted in alphabetical order, so the section does not drift as you add to it.

kargo add org.jetbrains.kotlin:kotlin-test:2.4.21 --dev     # test-only
kargo add io.ktor:ktor-server-core:2.3.0 --target jvm        # one target
kargo add com.example:ad-sdk:2.0.0 --flavor free             # one flavor

The manifest key comes from the artifact id, which is a mouthful for the platform-suffixed artifacts Kotlin Multiplatform publishes. --rename chooses it:

kargo add io.ktor:ktor-server-core-jvm --rename ktor-server
[dependencies]
ktor-server = "io.ktor:ktor-server-core-jvm:3.6.2"

The key is a label — the coordinate in the value is what gets resolved — so renaming one is safe at any time. Remember that kargo remove takes the key.

With --offline, a coordinate that omits its version is refused rather than guessed at: the cache holds artifacts, not the list of what has been published since. Name the version and the add works offline, because the manifest edit itself needs no repository.

Removing

kargo remove kotlinx-coroutines-core

Takes the manifest key, not the coordinate. Mirror the flags you added with:

kargo remove kotlin-test --dev
kargo remove ktor-server-core --target jvm

The four places dependencies live

[dependencies]                       # every target, every variant
kotlinx-coroutines-core = "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0"

[dev-dependencies]                   # test compilation and test runtime only
kotlin-test = "org.jetbrains.kotlin:kotlin-test:2.4.21"

[target.jvm.dependencies]            # only when building the jvm target
ktor-server-netty = "io.ktor:ktor-server-netty:2.3.0"

[flavor.free.dependencies]           # only in variants including the free flavor
ad-sdk = "com.example:ad-sdk:2.0.0"

A build sees [dependencies] plus the matching [target.*] and [flavor.*] sections, with [dev-dependencies] added for test compilation. There is no api versus implementation distinction: Kargo publishes a POM with compile-scoped dependencies and relies on Kotlin's own visibility rules.

Specifying a dependency

Coordinate shorthand

kotlinx-coroutines-core = "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0"

Detailed form

For anything shorthand cannot express:

[dependencies.my-lib]
group = "com.example"
artifact = "my-lib"
version = "1.0.0"
scope = "runtime"            # compile (default), runtime, provided, test, system, import
optional = true              # not propagated to consumers of your library
classifier = "linux-x86_64"  # for artifacts with platform-specific builds

[[dependencies.my-lib.exclusions]]
group = "org.slf4j"
artifact = "slf4j-log4j12"   # omit to exclude the whole group
ScopeAvailable when
compileCompiling and running, and propagated to consumers. The default.
runtimeRunning only — not on the compile classpath.
providedCompiling only — expected to exist at runtime (servlet APIs, IDE plugins).
testTest compilation and test runtime. Equivalent to [dev-dependencies].
importBOM import: pulls version constraints, no artifact.

Catalog reference

kotlinx-coroutines-core = { catalog = "kotlinx-coroutines" }
ktor-server = { catalog = "ktor-server", bundle = true }

See Version Catalogs.

BOMs

Import a bill of materials to let it dictate versions for a family of artifacts:

[dependencies.ktor-bom]
group = "io.ktor"
artifact = "ktor-bom"
version = "2.3.0"
scope = "import"

[dependencies]
ktor-server-core = { group = "io.ktor", artifact = "ktor-server-core", version = "" }

An empty version means "take it from an imported BOM". If no BOM supplies one, resolution fails with the artifact named.

Repositories

Maven Central is configured by default. Add others by name:

[repositories]
google = "https://maven.google.com"
internal = { url = "https://nexus.example.com/repository/maven-releases", username = "${env:NEXUS_USER}", password = "${env:NEXUS_PASS}" }
sonatype-snapshots = { url = "https://oss.sonatype.org/content/repositories/snapshots" }

Repositories are tried in declaration order, Maven Central last. Credentials should always come from .kargo.env via ${env:…} — never literals in a committed manifest.

Shared credentials can live in global config instead and be referenced by name:

[repositories]
internal = { url = "https://nexus.example.com/maven", auth = "my-nexus" }

The lockfile

Kargo.lock records the exact resolved version, checksum, and source repository of every artifact in the graph — direct and transitive.

[[package]]
name = "kotlinx-coroutines-core"
group = "org.jetbrains.kotlinx"
version = "1.8.0"
checksum = "sha256:…"
source = "https://repo.maven.apache.org/maven2"

A build with a lockfile resolves nothing: it reads versions, verifies checksums, and compiles. That makes builds reproducible and fast, and makes a dependency change visible in your diff.

kargo lock      # regenerate from the manifest
kargo fetch     # download everything in the lockfile without building

Should you commit the lockfile?

Commit itWhy
ApplicationsYesEveryone and every CI run builds the identical graph.
LibrariesUsually notYour consumers resolve their own graph; your lock has no effect on them. Committing it only pins what your CI tests against — useful, but a choice.

Updating

kargo update                      # all deps, within semver-compatible ranges
kargo update kotlinx-coroutines   # one dependency
kargo update --major              # allow major version bumps
kargo update --dry-run            # show what would change

kargo update rewrites Kargo.lock, not Kargo.toml — your declared versions stay put unless --major forces a manifest change.

To see what is available first:

kargo outdated
Package                    Current  Compatible  Latest
kotlinx-coroutines-core    1.8.0    1.8.1       1.9.0
ktor-server-core          2.3.0    2.3.12      3.0.1

--major includes the Latest column's breaking bumps in the update set.

Inspecting the graph

kargo tree
my-service v1.2.0
├── io.ktor:ktor-server-core v2.3.0
│   ├── io.ktor:ktor-http v2.3.0
│   └── org.jetbrains.kotlin:kotlin-stdlib v1.9.21
└── org.jetbrains.kotlinx:kotlinx-coroutines-core v1.8.0
    └── org.jetbrains.kotlin:kotlin-stdlib v1.9.21 (*)

(*) marks a subtree already printed.

QuestionCommand
Why is this in my build at all?kargo tree --why kotlin-stdlib
What pulled in two versions of the same thing?kargo tree --duplicates
Which versions conflicted, and who won?kargo tree --conflicts
What licenses am I shipping?kargo tree --licenses
Who depends on this?kargo tree --inverted
Just the top level, pleasekargo tree --depth 1

--why is the one to remember. It prints the path from your manifest to the artifact, which is the answer to almost every "where did that come from" question.

How conflicts resolve

When two paths require different versions of the same artifact, Kargo uses Maven's nearest-wins rule: the version declared closest to your project wins, ties broken by declaration order. This matches what Maven does — and differs from Gradle, which picks the highest version.

The practical consequence: if a transitive dependency needs a newer version than the one that wins, declare it directly in [dependencies]. Depth zero beats everything.

The Kotlin artifacts are the exception

Every org.jetbrains.kotlin artifact — kotlin-stdlib, -jdk7, -jdk8, -reflect, kotlin-test — resolves to the kotlin version in [package], whatever versions your dependencies ask for. They ship as one release and read each other's internals, so a mix of two releases compiles cleanly and then fails at startup with a ClassNotFoundException. Your compiler's own stdlib is already on the classpath at that version, so this is the version that was going to be used regardless.

org.jetbrains.kotlinx is not aligned: coroutines and serialization are released on their own schedule and keep their own versions.

Being aligned is not the same as being on the classpath. The stdlib is there without being declared, because the toolchain supplies it; kotlin-reflect is not, so code calling into kotlin.reflect.full has to declare it. Match your kotlin version when you do — a direct declaration wins over the alignment above, and reflect from one release against a stdlib from another is the startup failure this section is about.

To use a different version of one of them, declare it directly — a declaration in your manifest still wins:

[dependencies]
kotlin-reflect = "org.jetbrains.kotlin:kotlin-reflect:2.3.21"
kargo tree --conflicts    # see every mediation decision

--conflicts reports an aligned artifact as aligned to package.kotlin, so you can tell it from a lockfile pin or a nearest-wins decision.

Full detail in Dependency Resolution.

Offline builds

kargo fetch              # populate the cache while you have a network
kargo build --offline    # resolve only from ~/.kargo/cache

--offline fails rather than reaching the network, which makes it the honest way to verify that a build is reproducible from cache — useful for air-gapped and hermetic CI.

The cache is machine-wide, so one kargo fetch serves every checkout on the machine: a second clone of the same project builds without downloading anything. KARGO_HOME moves it along with everything else Kargo keeps, and kargo cache stats reports its size.

A project's own .kargo/dependencies/ is still read if it is there, which is how a CI cache restored into the workspace keeps working. Nothing is written there any more.

Because the store is shared, no single project thins it out: a kargo fetch that no longer needs an artifact leaves it where it is, since it is some other checkout's dependency. kargo self clean empties it when you want the space back.

Security

kargo audit

Checks the resolved graph against the OSV database. See Auditing Dependencies.

Next

Building and Running

Status: 🟢 Implemented for one target per invocation, with incremental compilation and the local build cache. 🟡 --flavor, --variant, and --all-variants are accepted but currently ignored. See Implementation Status.

The four commands

kargo build      # compile to artifacts
kargo run        # compile, then execute
kargo check      # type-check only, no artifacts
kargo clean      # delete outputs

kargo check is the one to bind to a keystroke. It skips artifact assembly and discards the classes it produces, so it answers "does this compile" in a fraction of a build.

Building

kargo build
    Resolving dependencies
     Compiling my-service v1.2.0 (jvm, dev)
      Finished dev profile in 3.14s

A build with an up-to-date Kargo.lock does no resolution work: it reads locked versions, verifies cached artifacts, and compiles.

Flags

FlagEffect
-t, --target <name>Build one target. Defaults to the only target, or jvm.
-p, --profile <name>Build with a named profile. Default dev.
--releaseShorthand for --profile release.
--offlineResolve only from the local cache; never touch the network.
--timingsPrint per-phase timing.
-v, --verboseFull compiler command lines and resolution detail.
-q, --quietPrint only warnings and errors.
--flavor <name>🟡 Accepted, not yet applied.
--variant <name>🟡 Accepted, not yet applied.
--all-variants🟡 Accepted, not yet applied.

Where output goes

build/<target>/<profile>/
├── classes/                   # compiled classes or klibs
└── output/
    └── my-service-1.2.0.jar

Each target-and-profile pair owns its directory, so switching between dev and release never invalidates the other's work.

Incremental fingerprints live in .kargo/fingerprints/, outside build/.

Running

kargo run

Requires main-class in [package]:

[package]
main-class = "com.example.MainKt"

Pass arguments to your program after --, so they are not parsed as Kargo flags:

kargo run -- --port 8080 --verbose
kargo run --release           # run the optimized build
kargo run --target jvm        # pick a target explicitly

Your program gets the terminal Kargo was started on. Its output appears as it is written rather than when it exits, it reads the real stdin, and Ctrl-C stops it — so a server logs the port it bound while it is serving, and a program that prompts for input can be answered.

Stopping Kargo stops your program with it, including when a supervisor or a container sends SIGTERM rather than you pressing Ctrl-C. Nothing is left holding the port your next run needs.

Type-checking

kargo check

Runs the compiler front end — resolution, type checking, diagnostics — without writing artifacts. Use it in editors, pre-commit hooks, and the fast lane of CI.

It checks the same sources a build compiles, which means it generates BuildConfig.kt and runs the [ksp] and [kapt] processors first. Those are cached, and so is the type-check itself: a second kargo check over an unchanged tree reports check up-to-date without starting the compiler.

Cleaning

kargo clean                      # all of build/ plus fingerprints
kargo clean --variant jvm/dev    # just one target and profile

A clean build is rarely the fix for a wrong build. If you reach for kargo clean to work around staleness, that is a bug worth filing — incremental compilation is supposed to be correct, not merely fast.

Watching

kargo watch                 # rebuild and re-run on change
kargo watch --build-only    # rebuild only

Watches your source directories and Kargo.toml, debounces bursts of saves, and cancels an in-flight build when a newer change arrives.

      Detected change at 14:03:12, rebuilding...
     Compiling my-service v1.2.0 (jvm dev)
      Finished 14 source file(s) [jvm dev] in 7.86s
      Watching for changes...

A program that is still running is stopped before the rebuild and started again after it, which is what makes watching a server work: the watcher stays live while the program serves, and each change restarts it.

      Stopping com.example.ApplicationKt
      Detected change at 14:03:12, rebuilding...
     Compiling my-service v1.2.0 (jvm dev)
      Finished 14 source file(s) [jvm dev] in 7.86s
      Watching for changes...
       Running com.example.ApplicationKt

A program that ends by itself is reported the moment it does, not at your next save. Nothing else would tell you: watch keeps going rather than exiting with the program's status, so a service that crashed would otherwise look exactly like one still serving.

!       Exited com.example.ApplicationKt: exit code: 1
      Watching for changes...

Ending the session takes the running program with it, the same way kargo run does.

Why it is fast

Three mechanisms, in order of how often they save you time:

1. Fingerprinting. Before compiling a unit, Kargo hashes its inputs: source contents, the resolved dependency set, compiler arguments, compiler version, and target. Unchanged fingerprint, no compile. This is why a no-op build finishes in milliseconds.

2. The build cache. A fingerprint miss checks the content-addressed build cache before compiling. Switching branches back and forth usually hits it.

3. No configuration phase. Kargo is a native binary that reads a TOML file. There is no build script to compile, no plugin graph to configure, and no Gradle daemon to keep warm — so the fixed cost before any real work starts is close to zero.

The Kotlin compiler itself still runs on the JVM, and Kargo reuses the Kotlin compile daemon across invocations so that cost is paid once rather than per build. kargo cache stop-daemon shuts it down when you want a cold measurement.

Details in Incremental Compilation.

Measuring a slow build

kargo build --timings
   Resolving dependencies ....  0.31s
   Fetching artifacts .......  1.20s
   Compiling commonMain .....  2.14s
   Compiling jvmMain ........  1.83s
   Packaging ................  0.42s
   Total ....................  5.90s

Read it as a triage tool:

Dominant phaseLikely cause
ResolvingNo lockfile, or kargo update ran. Commit Kargo.lock.
FetchingCold artifact cache. Run kargo fetch before the timed build.
CompilingGenuine compile cost — or fingerprint misses. Try -v.
PackagingLarge fat JAR or many resources.

Status: ⚪ --timings=html for an interactive timeline is planned.

Building for several targets

Today, one target per invocation:

kargo build --target jvm
kargo build --target ios-arm64

Status: 🟡 A single-pass multi-target build — one command that compiles commonMain once and fans out to every configured target — is the next phase of work. See Kotlin Multiplatform.

Reproducible builds

For a build that produces identical artifacts anywhere:

  1. Commit Kargo.lock.
  2. Pin kotlin to an exact version (no ranges — the field does not accept them).
  3. Build with --offline after a kargo fetch, so the network cannot change the inputs.
  4. Keep [profile.*] settings in the manifest rather than passing ad-hoc compiler flags.

Checksums for every artifact are verified on every build, cached or not, so a tampered or truncated download fails loudly instead of producing a mystery compile error.

Next

Testing

Status: 🟡 Partial — kargo test runs JVM tests and accepts --target and --filter. --coverage, --report, --parallel, --repeat, --fail-fast, and flavor selection are ⚪ planned. See Implementation Status.

Running tests

kargo test
     Compiling my-service v1.2.0 (jvm, dev)
       Running 24 tests
test com.example.OrderTest.rejects_empty_order ... ok
test com.example.OrderTest.applies_discount ... ok
…

test result: ok. 24 passed; 0 failed; 0 skipped; finished in 0.31s

Tests live in src/test/kotlin for JVM projects, or src/commonTest/kotlin and src/<target>Test/kotlin for multiplatform ones. No registration needed — anything in those directories is a test source.

Selecting what to run

kargo test --filter OrderTest                 # one class
kargo test --filter com.example.orders         # a package prefix
kargo test --filter rejects_empty_order        # one test
kargo test --target jvm                        # one target

--filter matches against the fully qualified test name as a substring, so a package prefix, a class name, and a method name all work.

Test dependencies

[dev-dependencies]
kotlin-test = "org.jetbrains.kotlin:kotlin-test:2.4.21"
mockk = "io.mockk:mockk:1.13.9"
assertj = "org.assertj:assertj-core:3.25.1"

[dev-dependencies] are on the test compile and runtime classpath and nowhere else. They are not published and not in your application's runtime graph.

For multiplatform, put common test dependencies in [dev-dependencies] and platform-specific ones under the target:

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

[target.jvm.dependencies]
junit = { group = "org.junit.jupiter", artifact = "junit-jupiter", version = "5.10.1", scope = "test" }

Frameworks

kotlin-test works out of the box and is what the templates use. On the JVM it delegates to JUnit, so JUnit 5 annotations, extensions, and parameterized tests all work:

import kotlin.test.Test
import kotlin.test.assertEquals

class OrderTest {
    @Test
    fun `applies discount to totals over 100`() {
        assertEquals(90.0, Order(total = 100.0).withDiscount(0.1).total)
    }
}

Backtick test names are idiomatic Kotlin and Kargo reports them verbatim.

Coverage

Status: ⚪ Planned. [test.coverage] parses today; --coverage is not implemented.

[test.coverage]
engine = "kover"                 # or "jacoco"
min-line = 80
min-branch = 70
exclude = ["**/generated/**", "**/BuildConfig.*"]
kargo test --coverage
kargo test --coverage --open     # open the HTML report

Reports land in build/reports/coverage/ as HTML plus an XML file in Cobertura/JaCoCo format for CI ingestion. Falling below a threshold fails the command, which is what makes it useful as a gate.

EngineUse when
koverKotlin-native, understands inline functions and multiplatform. The default.
jacocoJVM-only, when existing tooling expects JaCoCo output.

Exclude generated code. Coverage of code you did not write is noise, and BuildConfig in particular will never be covered.

Test reports

Status: ⚪ Planned.

kargo test --report junit,html
FormatOutputFor
consolestdoutHumans. The default.
junitbuild/reports/tests/junit.xmlCI annotations and history.
htmlbuild/reports/tests/index.htmlBrowsing failures locally.

Parallelism and flakiness

Status: ⚪ Planned.

kargo test --parallel          # run test classes concurrently
kargo test --repeat 3          # run each test three times
kargo test --fail-fast         # stop at the first failure

--repeat is the flake detector: a test that passes once and fails once in the same run is flaky, not broken by your change.

Testing flavored projects

Status: ⚪ Planned — depends on flavors reaching the build path.

kargo test --flavor free
kargo test --variant paid-staging

Each variant compiles its own BuildConfig, so tests that assert on configuration run against the right values per variant.

Multiplatform tests

kargo test --target jvm
kargo test --target ios-simulator-arm64

Common tests in src/commonTest/kotlin compile and run against every target; target-specific tests in src/jvmTest/kotlin run only there. Native test execution needs the matching host — iOS simulator tests require macOS.

Benchmarks

Status: ⚪ Planned.

kargo bench
kargo bench --compare main

Runs kotlinx-benchmark benchmarks, writing JSON results to build/reports/benchmarks/. --compare diffs against a stored baseline so a regression shows up as a number rather than a feeling.

In CI

kargo test --report junit --coverage

See Continuous Integration for complete workflow examples.

Next

Linting and Formatting

Status: ⚪ Planned — [lint] and [format] parse today, and the kargo-lint crate is scaffolded, but kargo lint, kargo fmt, and kargo fix are not implemented. This page describes the intended behavior. See Implementation Status.

Linting and formatting are built in. There is no plugin to add, no second tool to version, and no separate configuration file.

kargo lint          # report problems
kargo lint --fix    # fix what can be fixed
kargo fmt           # format
kargo fmt --check   # verify formatting, for CI
kargo fix           # apply every auto-fixable suggestion

Why in the build tool

A linter that ships with the build tool shares the build's parsed sources, dependency graph, and configuration. That means one pass over the code instead of three, and no possibility of your linter and your compiler disagreeing about which Kotlin version they are reading.

It also means one fewer thing to install, pin, and upgrade in lockstep.

Configuring rules

[lint]
rules = ["naming", "style", "complexity", "performance", "correctness"]
severity = "warning"
CategoryCatches
namingClass, function, property, and constant naming conventions
styleBrace placement, spacing, import order, trailing commas
complexityLong functions, deep nesting, high cyclomatic complexity
performanceNeedless allocation, inefficient collection use, deprecated APIs
correctnessUnreachable code, unused values, suspicious comparisons

severity sets the default level: error fails the command, warning reports and succeeds, info is advisory only.

Start with naming and style — they are mechanical and uncontroversial. complexity on an existing codebase produces a large list on day one; introduce it at info, work the list down, then promote it to warning.

The full rule list is in the Lint Rules reference.

Formatting

[format]
style = "official"
indent = 4
max-line-length = 120
KeyValuesDefault
styleofficialofficial
indentspaces per level4
max-line-lengthcolumns120

The default is the Kotlin coding conventions. Formatting is not a place to be creative: pick the standard, run it on save, and stop thinking about it.

kargo fmt           # rewrite files
kargo fmt --check   # exit non-zero if anything is unformatted

--check prints a diff of what it would change, so a CI failure tells you what to run rather than only that something is wrong.

The formatter preserves comment placement and blank-line structure where it can. Reformatting a file should produce a small diff, not a wholesale rewrite — a formatter that churns unrelated lines makes every review harder.

Auto-fixing

kargo lint --fix    # fix lint violations
kargo fix           # everything auto-fixable, lint and format

Only unambiguous fixes are applied: an import order, a redundant qualifier, a missing trailing comma. Anything requiring a judgment call is reported, not changed. A tool that guesses at intent produces diffs you have to review line by line, which defeats the purpose.

Commit before running --fix on a large codebase, so the result is one reviewable diff.

Output formats

kargo lint --format text     # colored terminal output (default)
kargo lint --format json     # machine-readable
kargo lint --format sarif    # for GitHub code scanning and similar

SARIF is what makes findings appear inline on a pull request:

- run: kargo lint --format sarif > results.sarif
- uses: github/codeql-action/upload-sarif@v3
  with:
    sarif_file: results.sarif

In CI

kargo fmt --check
kargo lint

Keep them separate from the build. A formatting failure should not hide a compile error, and a 30-second lint job that fails fast is more useful than a 10-minute build that fails at the end for a missing newline.

See Continuous Integration.

With editors

Status: ⚪ Planned — see Editors and IDEs.

kargo lsp surfaces lint diagnostics inline and offers the auto-fixes as code actions, so problems appear as you type rather than when CI tells you.

Custom rules

Status: ⚪ Planned.

Project-specific rules via script plugins:

[lint.custom]
no-println = "lint-rules/no-println.rhai"

For enforcing conventions a general-purpose linter cannot know about: an internal API that must not be called from a particular module, a logging facade that must be used instead of println.

Next

Build Profiles

Status: 🟢 Implemented — dev and release, plus custom named profiles.

A profile is a named set of compiler settings. dev optimizes for fast feedback, release for the artifact you ship.

kargo build              # dev (default)
kargo build --release    # release
kargo build -p perf      # a custom profile

The two built-in profiles

devrelease
Debug infoYesNo
OptimizationNoYes
Outputbuild/<target>/dev/build/<target>/release/
Use forEverything you do while writing codePublishing, benchmarking, shipping

Both exist without being declared. Override them only where you disagree:

[profile.dev]
debug = true
optimization = false

[profile.release]
debug = false
optimization = true
compiler-args = ["-Xjvm-default=all"]
KeyTypeEffect
debugboolEmit debug symbols and line-number tables.
optimizationboolEnable compiler optimizations.
compiler-argslistExtra flags passed straight to the Kotlin compiler.

Custom profiles

Any [profile.<name>] section defines a profile:

[profile.perf]
debug = true            # keep symbols so profilers can attribute samples
optimization = true

[profile.ci]
debug = false
optimization = false    # fastest possible compile; artifacts are discarded
kargo build --profile perf
kargo test --profile ci

perf is the common case worth knowing: a release-speed binary that a profiler can still read. Without debug info, flame graphs show you addresses instead of function names.

Output isolation

Each profile owns its output directory, so profiles never invalidate one another:

build/jvm/dev/
build/jvm/release/
build/jvm/perf/

Switching back and forth costs nothing after the first build of each. The fingerprint for a compilation unit includes the profile's compiler arguments, so changing compiler-args correctly forces a rebuild of exactly that profile.

compiler-args

An escape hatch for compiler flags Kargo has no manifest key for:

[profile.release]
compiler-args = [
    "-Xjvm-default=all",
    "-opt-in=kotlin.ExperimentalStdlibApi",
    "-Xcontext-receivers",
]

Flags land on the kotlinc command line verbatim. Two cautions: they are not validated, so a typo surfaces as a compiler error; and they are target-specific, so a JVM-only flag in a profile used by a Native build will fail there. Prefer a manifest key when one exists.

Interaction with flavors

Status: 🟡 Flavors do not reach the build path yet — see Flavors and Variants.

A variant is a flavor combination plus a profile, so profiles multiply the variant matrix: two flavor dimensions of two values each, with two profiles, is eight variants.

kargo build --variant free-staging-dev

Next

Flavors and Variants

Status: 🟡 Partial — [flavors] parses and validates, and BuildConfig generation works. The build path does not yet apply flavors: --flavor, --variant, and --all-variants are accepted and ignored. See Implementation Status.

Flavors build several versions of the same application from one codebase: free and paid, staging and production, one white-label build per customer.

Android developers know this as productFlavors. Kargo generalizes it — flavors work on every target, not just Android.

Dimensions, flavors, variants

  • A dimension is an independent axis of variation: tier, environment, brand.
  • A flavor is one value on an axis: free and paid within tier.
  • A variant is one flavor from each dimension, plus a profile.

Two dimensions of two flavors each, with two profiles, gives eight variants:

free-staging-dev        paid-staging-dev
free-staging-release    paid-staging-release
free-production-dev     paid-production-dev
free-production-release paid-production-release

The count multiplies fast. Exclusions exist because of this.

Declaring flavors

[flavors]
dimensions = ["tier", "environment"]
default = { tier = "paid", environment = "staging" }

[flavors.tier.free]
build-config = { IS_PAID = "false", AD_SUPPORTED = "true" }
application-id-suffix = ".free"

[flavors.tier.paid]
build-config = { IS_PAID = "true", AD_SUPPORTED = "false" }

[flavors.environment.staging]
build-config = { API_URL = "https://staging.api.example.com", LOG_LEVEL = "DEBUG" }
application-id-suffix = ".staging"

[flavors.environment.production]
build-config = { API_URL = "https://api.example.com", LOG_LEVEL = "ERROR" }

dimensions is ordered, and that order determines variant names — tier before environment means free-staging, never staging-free.

KeyPurpose
build-configCompile-time constants for this flavor
application-id-suffixAppended to the application id, so variants install side by side
signingPer-flavor signing configuration

BuildConfig

Each variant compiles against a generated BuildConfig object:

// generated — do not edit
object BuildConfig {
    const val IS_PAID: String = "true"
    const val AD_SUPPORTED: String = "false"
    const val API_URL: String = "https://api.example.com"
    const val LOG_LEVEL: String = "ERROR"
    const val BUILD_TYPE: String = "release"   // from the profile
    const val DEBUG: Boolean = false           // from the profile
    const val VERSION_NAME: String = "1.0.0"   // from [package]
}
val client = HttpClient(BuildConfig.API_URL)
if (BuildConfig.IS_PAID.toBoolean()) enablePremium()

Values merge from three sources, later overriding earlier:

  1. the manifest's top-level [build-config]
  2. each matching flavor's build-config
  3. profile-derived values (BUILD_TYPE, DEBUG)

Everything in build-config is a String except the profile-derived DEBUG. That is deliberate — the manifest is TOML and inferring Kotlin types from TOML values produces surprises. Call .toBoolean() or .toInt() at the use site.

The same values are exported to hooks and plugins as KARGO_BUILD_CONFIG_* environment variables.

Flavor-specific sources

src/
├── main/kotlin/              # every variant
├── freeMain/kotlin/          # tier=free
├── paidMain/kotlin/          # tier=paid
├── stagingMain/kotlin/       # environment=staging
├── productionMain/kotlin/
└── freeStagingMain/kotlin/   # exactly free+staging (rare)

Sources merge common → dimension flavor → exact variant. A later layer can replace a file from an earlier one, which is how a flavor swaps an icon, a theme, or a single implementation class.

Prefer build-config for values and source sets for behavior. A flavor that overrides twelve files is usually two products wearing one manifest.

Flavor-specific dependencies

[flavor.free.dependencies]
ad-sdk = "com.example:ad-sdk:2.0.0"

[flavor.paid.dependencies]
premium = "com.example:premium:1.0.0"

[flavor.staging.dependencies]
leak-canary = "com.squareup.leakcanary:leakcanary-android:2.12"

Note the singular [flavor.<name>.dependencies] for dependencies versus plural [flavors.<dimension>.<name>] for definitions.

Each variant resolves its own dependency graph: [dependencies] plus every matching flavor's additions. If two flavors in different dimensions pull incompatible versions of the same artifact, that combination fails resolution with both paths named — rather than silently picking one.

Building a variant

kargo build --variant free-staging-release   # one exact variant
kargo build --flavor paid                    # every variant containing paid
kargo build --all-variants                   # everything
kargo run --variant paid-production-release
kargo test --flavor free
kargo variant list                           # what is defined
kargo variant info paid-staging-release      # sources, deps, build config

Output goes to build/<variant>/<target>/.

With no flavor flags, Kargo builds the default variant. Omit default and you must name one explicitly — a reasonable thing to want when no variant is a safe accident.

Excluding combinations

[flavors]
dimensions = ["tier", "environment"]
exclude = [
    { tier = "free", environment = "production" },
]

Excluded combinations do not exist: they are not built by --all-variants, not listed by kargo variant list, and naming one is an error.

Per-flavor signing

[flavors.tier.paid.signing]
keystore = "release.keystore"
key-alias = "paid-release"
store-password-cmd = "op read 'op://Dev/Keystore/password'"

store-password-cmd runs an external command and reads the password from its stdout, so the secret never lands in a file — neither the manifest nor .kargo.env. Any secret manager with a CLI works.

When not to use flavors

Flavors suit variation in configuration. They suit variation in product badly.

SituationBetter tool
Different API URL per environmentFlavors
Free tier lacks three screensFlavors
Two apps sharing a coreWorkspace with a shared module
Platform differencesTargets and expect/actual
A customer needs a different data modelSeparate projects

The eight-variant matrix above means eight builds and eight test runs. If every variant needs its own test suite, the dimensions are modelling products.

Next

Kotlin Multiplatform

Status: 🟡 Partial — targets are declared in the manifest, and JVM, Android, JS, and Native compiler backends exist. Source sets are discovered, inferred into a hierarchy, and overridable from the manifest. Today each target builds separately via --target; a single-pass multi-target build and expect/actual validation are in progress. See Implementation Status.

Multiplatform in Kargo is a list of targets in the manifest. There is no plugin to apply and no kotlin { } block to configure.

[targets]
jvm = { java-target = "25" }
android = { min-sdk = 24, target-sdk = 36, compile-sdk = 36 }
ios-arm64 = {}
ios-simulator-arm64 = {}
js = { module-kind = "es" }

Start one with kargo new my-shared --template kmp.

Source sets

Each target reads from its own directory, plus commonMain for shared code:

src/
├── commonMain/kotlin/     # compiled into every target
├── commonTest/kotlin/
├── jvmMain/kotlin/
├── jvmTest/kotlin/
├── iosMain/kotlin/        # shared by every iOS target
├── iosArm64Main/kotlin/   # one specific iOS target
└── jsMain/kotlin/

The directory name is the configuration: src/<sourceSet>/kotlin, where the source set is the target name in camelCase plus Main or Test.

expect and actual

Declare the shape in common code, implement it per platform:

// src/commonMain/kotlin/Platform.kt
expect fun platformName(): String
expect class HttpClient() {
    suspend fun get(url: String): String
}
// src/jvmMain/kotlin/Platform.kt
actual fun platformName(): String = "JVM ${System.getProperty("java.version")}"
// src/iosMain/kotlin/Platform.kt
import platform.UIKit.UIDevice

actual fun platformName(): String =
    UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion

expect/actual validation

Status: ⚪ Planned.

Before compiling, Kargo checks that every expect declaration has a matching actual in each configured target, and reports the gaps together:

error: missing actual declarations

  expect fun platformName()  declared in src/commonMain/kotlin/Platform.kt:3
    missing for target js
    missing for target wasm-js

  2 declarations missing actuals across 2 targets

The point is to fail with a list rather than one compiler error per target, which is the normal experience when a target is added late.

The source-set hierarchy

Writing the same iOS code twice — once for iosArm64Main, once for iosSimulatorArm64Main — is the failure mode this prevents. Kargo infers intermediate source sets shared by families of targets:

graph TD
    COMMON["commonMain"] --> NATIVE["nativeMain"]
    COMMON --> JVM["jvmMain"]
    COMMON --> JSWASM["jsAndWasmMain"]
    NATIVE --> APPLE["appleMain"]
    NATIVE --> LINUX["linuxX64Main"]
    APPLE --> IOS["iosMain"]
    APPLE --> MACOS["macosMain"]
    IOS --> IOSARM["iosArm64Main"]
    IOS --> IOSSIM["iosSimulatorArm64Main"]
    JSWASM --> JS["jsMain"]
    JSWASM --> WASM["wasmJsMain"]

So code in iosMain compiles into both iOS targets; code in appleMain reaches macOS, tvOS, and watchOS too. You only create the directories you actually use.

Override the inferred graph when you need something it does not provide — a set shared by the JVM and Android targets and only those two:

[source-sets.jvmAndAndroidMain]
depends-on = ["commonMain"]
targets = ["jvm", "android"]

Full rules in the Source Sets reference.

Target-specific dependencies

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

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

[target.ios.dependencies]
ktor-client-darwin = "io.ktor:ktor-client-darwin:2.3.0"

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

[dependencies] must resolve for every target, so only multiplatform artifacts belong there. Platform-only libraries go under their target.

Kargo reads Gradle Module Metadata where artifacts publish it, which is how a single coordinate such as io.ktor:ktor-client-core resolves to the right platform artifact.

Building

kargo build --target jvm
kargo build --target ios-arm64
kargo test  --target jvm

Status: 🟡 One target per invocation today. A single command that compiles commonMain once and fans out to every target is the current phase of work.

Native targets need a matching host: Apple targets require macOS with Xcode; no host cross-compiles to iOS.

CInterop

Status: ⚪ Planned.

Call C and Objective-C libraries from Kotlin/Native:

[target.ios-arm64.cinterop.mylib]
def-file = "src/nativeInterop/cinterop/mylib.def"
headers = ["include/mylib.h"]
compiler-opts = ["-Iinclude"]
linker-opts = ["-L/usr/local/lib", "-lmylib"]

Kargo runs the cinterop tool to generate bindings before compiling, and adds them to the target's classpath automatically.

Consuming the result

TargetArtifactConsumed by
jvmJARAny JVM project
androidJVM classes (AAR packaging planned)Android apps
ios-*.framework, or an XCFramework via packagingXcode projects
js.js plus .d.tsnpm consumers, bundlers
linux-x64, mingw-x64, macos-*Executable or shared libraryNative consumers

Choosing targets

Every target you add multiplies build time, test surface, and the number of actual implementations you owe. Add them when you need them — the manifest edit is one line, so there is no reason to add a target speculatively.

Next

Compose Multiplatform

Status: ⚪ Planned — [compose] enabled = true parses, and source-set discovery already understands composeResources/, but the Compose compiler plugin is not yet applied during a build. See Implementation Status.

Compose Multiplatform is one manifest key:

[compose]
enabled = true

No plugin block, no compiler-plugin coordinate, no version to keep in step with your Kotlin version. Kargo resolves the Compose compiler plugin matching package.kotlin, downloads it, and passes it to the compiler.

Start a project with kargo new my-ui --template cmp.

A full Compose manifest

[package]
name = "my-ui"
group = "com.example"
version = "0.1.0"
kotlin = "2.4.21"

[targets]
jvm = { java-target = "25" }
android = { min-sdk = 24, target-sdk = 36, compile-sdk = 36 }
ios-arm64 = {}
ios-simulator-arm64 = {}

[compose]
enabled = true

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

The Compose runtime, UI, foundation, and Material artifacts come in with the plugin. You do not declare them.

Shared UI

// src/commonMain/kotlin/App.kt
package com.example

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier

@Composable
fun App() {
    Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
        Text("Hello from my-ui!")
    }
}

Each platform supplies only its entry point:

// src/jvmMain/kotlin/Main.kt — desktop
fun main() = application {
    Window(onCloseRequest = ::exitApplication, title = "my-ui") { App() }
}
// src/androidMain/kotlin/MainActivity.kt
class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent { App() }
    }
}
// src/iosMain/kotlin/MainViewController.kt
fun MainViewController() = ComposeUIViewController { App() }

Resources

Shared images, fonts, and strings live in composeResources/:

src/commonMain/composeResources/
├── drawable/
│   ├── logo.xml
│   └── background.png
├── font/
│   └── Inter-Regular.ttf
└── values/
    └── strings.xml

Kargo generates a typed Res accessor, so a missing resource is a compile error rather than a runtime one:

Image(painterResource(Res.drawable.logo), contentDescription = null)
Text(stringResource(Res.string.app_title))

Platform-specific look and feel

expect/actual covers the places where platforms genuinely differ:

// src/commonMain/kotlin/Theme.kt
@Composable
expect fun PlatformTheme(content: @Composable () -> Unit)
// src/androidMain/kotlin/Theme.kt
@Composable
actual fun PlatformTheme(content: @Composable () -> Unit) {
    MaterialTheme(colorScheme = dynamicColorScheme(LocalContext.current)) { content() }
}

Building and running

kargo run --target jvm                   # desktop window
kargo build --target android
kargo build --target ios-simulator-arm64

For iOS, package a framework and let Xcode consume it:

kargo package --ios-universal

Compose compiler options

Status: ⚪ Planned.

[compose]
enabled = true
strong-skipping = true
metrics = "build/reports/compose"
stability-config = "compose-stability.conf"
KeyPurpose
strong-skippingSkip recomposition more aggressively
metricsEmit recomposition and stability reports
stability-configDeclare third-party classes as stable

The metrics report is the tool for a sluggish UI: it names the composables that recompose when they should not, which is almost always an unstable parameter.

Versions

The Compose compiler plugin is tied to the Kotlin compiler version, and a mismatch produces errors that read like unrelated internal compiler failures. Kargo picks the matching plugin for package.kotlin, so bumping Kotlin bumps Compose with it and there is no second version to forget.

Next

Workspaces

Status: 🟡 Partial — [workspace] parses and validates, including glob members. Building members as one unit is not orchestrated yet; each module builds on its own. See Implementation Status.

A workspace is several Kargo packages that build together, share a dependency graph, and resolve to one consistent set of versions.

Layout

my-workspace/
├── Kargo.toml           # workspace root — [workspace] and [catalog], no [package]
├── Kargo.lock           # one lockfile for every member
├── app/
│   ├── Kargo.toml
│   └── src/main/kotlin/
├── shared/
│   ├── Kargo.toml
│   └── src/commonMain/kotlin/
└── libs/
    ├── http/Kargo.toml
    └── storage/Kargo.toml

Root manifest:

[workspace]
members = ["app", "shared", "libs/*"]
exclude = ["experimental"]

[catalog.versions]
kotlin = "2.4.21"
ktor = "2.3.0"

members accepts globs. exclude removes paths a glob would otherwise pull in — a spike directory you do not want in CI, for instance.

Depending on another member

# app/Kargo.toml
[dependencies]
shared = { path = "../shared" }
http = { path = "../libs/http" }

Path dependencies compile from source. Changing shared rebuilds app; no publishing step and no version to bump while iterating.

One lockfile

The root Kargo.lock covers every member, which is the point: two modules cannot end up on different patch versions of the same library, because there is only one resolution.

kargo lock      # from the root, relocks everything
kargo update    # updates every member together

Building

Status: 🟡 Member orchestration is planned; today, build each module from its own directory.

# planned
kargo build                      # every member, in dependency order
kargo build -p app               # one member and its path dependencies
kargo test -p shared             # one member's tests
kargo build --exclude experimental
# today
cd shared && kargo build
cd ../app && kargo build

Members with no dependency between them are intended to build in parallel; the dependency graph determines the order, so you never declare it.

Shared configuration

Settings that belong to the whole repository live at the root:

[workspace]
members = ["app", "shared"]

[catalog.versions]
kotlin = "2.4.21"

[profile.release]
optimization = true

[lint]
rules = ["naming", "style", "complexity"]

Members inherit and may override locally. Put the Kotlin version in a catalog rather than repeating it in every member — a workspace where modules compile with different compilers is a long afternoon.

When to split a module

ReasonVerdict
Two deliverables share codeSplit. This is what workspaces are for.
A library you also publish separatelySplit.
Platform-specific codeDo not split — use targets and expect/actual.
Build-time variationDo not split — use flavors.
"Modules are good architecture"Do not split. Each one adds a manifest and a boundary to maintain.

A module boundary is a dependency edge you have to keep acyclic forever. Add one when something concrete needs it.

Next

Version Catalogs

Status: 🟡 Partial — [catalog] parses and validates. Resolving a { catalog = … } reference is not implemented yet, so catalogs do not affect builds today. See Implementation Status.

A catalog declares versions once and lets every module reference them. It is the answer to five modules each pinning their own Ktor version and drifting apart.

Declaring one

In the workspace root Kargo.toml:

[workspace]
members = ["app", "shared", "server"]

[catalog.versions]
kotlin = "2.4.21"
coroutines = "1.8.0"
ktor = "2.3.0"

[catalog.libraries]
kotlinx-coroutines = { group = "org.jetbrains.kotlinx", artifact = "kotlinx-coroutines-core", version.ref = "coroutines" }
ktor-server-core = { group = "io.ktor", artifact = "ktor-server-core", version.ref = "ktor" }
ktor-server-netty = { group = "io.ktor", artifact = "ktor-server-netty", version.ref = "ktor" }
ktor-client-core = { group = "io.ktor", artifact = "ktor-client-core", version.ref = "ktor" }

[catalog.bundles]
ktor-server = ["ktor-server-core", "ktor-server-netty"]

[catalog.plugins]
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
SectionHolds
[catalog.versions]Named version strings, referenced by version.ref
[catalog.libraries]Named coordinates
[catalog.bundles]Named groups of libraries added together
[catalog.plugins]Named compiler plugin ids

A library can pin its version inline with version = "2.3.0" instead of version.ref — the right choice for a one-off that no other entry shares.

Using it

# app/Kargo.toml
[dependencies]
kotlinx-coroutines = { catalog = "kotlinx-coroutines" }
ktor-server = { catalog = "ktor-server", bundle = true }

bundle = true says the name refers to a bundle, and pulls in every library it lists.

[plugins]
serialization = { catalog = "serialization" }

Upgrading

Change one line:

[catalog.versions]
ktor = "2.3.12"

Every module using ktor-* moves together. Compare with the alternative — four modules, three Ktor coordinates each, upgraded by search-and-replace and verified by hope.

kargo outdated          # checks catalog versions too
kargo update            # relocks against the new versions

When a catalog earns its keep

Project shapeVerdict
Single moduleSkip it. [dependencies] is already one place.
Two or three modulesOptional.
Four or more modules sharing librariesUse one. Drift is otherwise inevitable.
Any project where version mismatches have bitten youUse one.

A catalog in a single-module project adds indirection and removes nothing. The benefit is strictly about shared versions across modules.

Naming

Catalog names appear at every use site, so they repay a moment's thought.

# Good: a family prefix groups related entries together
ktor-server-core = { … }
ktor-server-netty = { … }
ktor-client-core = { … }

# Avoid: no grouping, and the name says nothing about what it is
server = { … }
netty-thing = { … }

Gradle interoperability

Status: ⚪ Planned.

Gradle's libs.versions.toml uses the same shape under different section names. Importing one directly is planned, so a migrating project can keep a single catalog while both build tools exist side by side:

[catalog]
import = "gradle/libs.versions.toml"

Until then, kargo migrate translating the file is the intended path — see Coming from Gradle.

Next

Toolchains

Status: 🟢 Implemented — Kotlin auto-download, JDK and Android SDK installation, and JDK/Android/Apple SDK discovery all work.

Kargo manages the Kotlin compiler the way rustup manages Rust: you declare a version, and the tool makes it exist.

[package]
kotlin = "2.4.21"

That is the entire setup. The first build downloads Kotlin 2.4.21 if it is not cached, and every build after that uses exactly that compiler.

Why this matters

A Kotlin version in a manifest is a version your CI, your laptop, and a new contributor's machine all agree on. The usual alternative is a README line saying "install Kotlin 2.x" — a documented hope rather than a constraint.

Multiple versions coexist, so switching branches switches compilers with nothing to install:

~/.kargo/toolchains/
├── kotlin-2.1.0/
├── kotlin-2.3.1/
└── kotlin-2.4.21/

Managing toolchains

kargo toolchain list              # what is installed
kargo toolchain install 2.4.21    # fetch a version ahead of time
kargo toolchain remove 2.1.0      # reclaim disk
kargo toolchain use 2.4.21        # default for new projects
kargo toolchain path              # where the active one lives
$ kargo toolchain list
  2.1.0
  2.3.1
* 2.4.21     (default)

toolchain use sets the default that kargo new writes into fresh manifests. It does not override an existing project — package.kotlin always wins, which is what makes a checkout reproducible.

toolchain path is for when an external tool needs the compiler:

"$(kargo toolchain path)/bin/kotlinc" -version

Mirrors and air-gapped builds

# ~/.kargo/config.toml
[toolchain]
kotlin-mirror = "https://mirror.example.com/kotlin/releases"
auto-download = true
# Kargo.toml — per project
[toolchain]
jdk = "25"
auto-download = false

Set auto-download = false where outbound network access is unavailable or not allowed. Builds then fail with a message naming the missing version instead of hanging on a download, and you pre-populate ~/.kargo/toolchains/ out of band.

A mirror only needs to serve the same layout as the JetBrains release archive, so a static file server or an artifact proxy is enough.

JDK discovery

Kargo needs a JDK to run the Kotlin compiler and JVM builds. It looks, in order:

  1. [toolchain] jdk in Kargo.toml
  2. [toolchain] jdk in ~/.kargo/config.toml
  3. JAVA_HOME in .kargo.env
  4. JAVA_HOME in the process environment
  5. Common install locations for the platform
[toolchain]
jdk = "/usr/lib/jvm/java-25-openjdk"   # an explicit path
[toolchain]
jdk = "25"                             # a version, matched among discovered JDKs

If no suitable JDK is found, Kargo can fetch one:

kargo toolchain install --jdk          # a sensible default version
kargo toolchain install --jdk 17       # a specific major version
kargo toolchain remove --jdk 17

java-target in [targets.jvm] is a separate decision — the bytecode level you emit, which can be lower than the JDK you compile with:

[targets.jvm]
java-target = "17"      # runs on Java 17+, even if built with JDK 25

Android SDK

export ANDROID_HOME=/path/to/sdk

or, per project:

# .kargo.env
ANDROID_SDK=/Users/jane/Library/Android/sdk

Kargo checks [toolchain], then ANDROID_SDK in .kargo.env, then ANDROID_HOME, then ANDROID_SDK_ROOT, then the platform default. It validates that the platform for your compile-sdk is present and installs it if not.

You can also install the SDK up front:

kargo toolchain install --android          # default compile-sdk level
kargo toolchain install --android 36       # a specific level
kargo toolchain install 2.4.21 --jdk --android   # all three at once
kargo toolchain remove --android

Apple SDKs

On macOS, Kargo resolves SDK paths through xcrun, so whichever Xcode xcode-select points at is what gets used:

xcode-select --install          # command line tools
xcode-select -p                 # which Xcode is active

Apple targets require a macOS host. No other platform cross-compiles to iOS, and Kargo fails early and explicitly rather than part way through a link step.

Disk usage

kargo self info     # versions, paths, cache sizes
kargo self clean    # remove unused toolchains and stale cache entries
$ kargo self info
kargo 0.2.0
  config      ~/.kargo/config.toml
  toolchains  ~/.kargo/toolchains        3 installed, 1.8 GiB
  artifacts   ~/.kargo/cache             4.2 GiB
  build cache ~/.kargo/build-cache       2.1 GiB

A Kotlin toolchain is a few hundred megabytes. kargo self clean keeps the versions your projects reference and drops the rest.

The Kotlin compile daemon

The Kotlin compiler runs on the JVM, and Kargo reuses its compile daemon between invocations so that startup cost is paid once rather than per build. It is managed for you; the only control you need is a way to stop it:

kargo cache stop-daemon

Useful before timing a cold build, or when a compiler upgrade leaves a stale daemon running.

Next

Secrets and Environment

Status: 🟢 Implemented — .kargo.env loading, ${env:…} interpolation, and kargo env all work.

Builds need secrets: registry credentials, signing passwords, CI tokens. They must not be committed. Kargo gives them one home — .kargo.env — and one way to reference them — ${env:VAR}.

The distinction that matters

Build secretsBuild configuration
ExamplesNexus password, GPG passphrase, CI tokenAPI URL, feature flag, analytics key
Needed byThe build itselfThe shipped application
Lives in.kargo.env (gitignored)[build-config] or flavors
Ends up in the binaryNoYes

Getting this backwards is the common mistake. A registry password in [build-config] is committed and compiled into your artifact. An API URL in .kargo.env is missing on every machine that did not set it up by hand.

Ask: does the build need it, or does the app need it?

.kargo.env

A shell-style KEY=value file beside Kargo.toml:

# Private repository auth
NEXUS_USERNAME=deploy
NEXUS_PASSWORD=s3cret-token
MAVEN_TOKEN=abc123

# Signing
KEYSTORE_PASSWORD=changeit
GPG_PASSPHRASE=hunter2

# Machine-specific paths
ANDROID_SDK=/Users/jane/Library/Android/sdk
JAVA_HOME=/usr/lib/jvm/java-25-openjdk

kargo new and kargo init create the file and add it to .gitignore. Check that it stayed there before your first commit.

Referencing values

Anywhere in Kargo.toml:

[repositories]
internal = { url = "https://nexus.example.com/maven", username = "${env:NEXUS_USERNAME}", password = "${env:NEXUS_PASSWORD}" }

[signing]
gpg-key = "${env:GPG_KEY}"
gpg-password = "${env:GPG_PASSPHRASE}"

[toolchain]
jdk = "${env:JAVA_HOME}"

Interpolation runs when the manifest is read, before TOML parsing, so it works in any string value — a URL, a path, a version — not just credentials.

Resolution order

Later wins:

  1. ~/.kargo/config.toml — global defaults
  2. <project>/.kargo.env — this project on this machine
  3. The process environment

So CI can override a developer's local value by exporting it, with no file to edit:

NEXUS_PASSWORD="$CI_NEXUS_TOKEN" kargo publish

An unresolved ${env:VAR} fails the command and names the variable. It does not silently become an empty string — which is how a build quietly publishes to the wrong place.

Inspecting

kargo env
NEXUS_USERNAME    deploy
NEXUS_PASSWORD    ****
MAVEN_TOKEN       ****
ANDROID_SDK       /Users/jane/Library/Android/sdk

Values that look like secrets are masked. To see them:

kargo env --reveal

--reveal is deliberately explicit, because the common use of kargo env is pasting output into a bug report.

In CI

Do not write .kargo.env in CI. Export secrets from your platform's secret store and let the process environment supply them:

- name: Publish
  env:
    NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
    NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
  run: kargo publish

See Continuous Integration.

Secrets from a manager

For values you would rather not have on disk at all, fetch them with a command:

[flavors.tier.paid.signing]
keystore = "release.keystore"
key-alias = "paid-release"
store-password-cmd = "op read 'op://Dev/Keystore/password'"
# ~/.kargo/config.toml
[credentials.my-nexus]
username = "deploy"
token-cmd = "secret-tool lookup service nexus"

The command runs at build time and its stdout is the value. Nothing is stored, and any manager with a CLI works — 1Password, pass, secret-tool, Vault.

Rules Kargo enforces

  • kargo new and kargo init gitignore .kargo.env.
  • An unresolved ${env:…} is an error, not an empty string.
  • kargo publish refuses to run with unresolved placeholders in the manifest, so a missing credential cannot become a literal ${env:NEXUS_PASSWORD} in a published POM.
  • kargo env masks by default.
  • kargo lint warns on values that look like hardcoded secrets in Kargo.toml. ⚪ Planned.

If a secret gets committed

Rotate it. Removing the file in a later commit does not help — the value is in the repository's history and in every clone. Treat a committed secret as a leaked secret and replace it at the source.

Next

The Build Cache

Status: 🟢 Implemented for the local cache. ⚪ The remote cache is planned; [cache] keys parse but there is no transport yet.

Kargo caches compiled output by content. When the inputs to a compilation have been seen before, the result is restored instead of recompiled.

Two layers that look similar but are not

Artifact cacheBuild cache
Location~/.kargo/cache/~/.kargo/build-cache/
HoldsDownloaded JARs and POMs from MavenYour own compiled classes
Keyed byMaven coordinateHash of all compilation inputs
Cleared bykargo self cleankargo cache clean

This page is about the second one.

How a cache key is computed

A compilation unit's key hashes everything that could change its output:

  • the content of every source file in the unit
  • the resolved dependency set, by coordinate and checksum
  • the full compiler argument list, including profile compiler-args
  • the compiler version
  • the target
  • generated inputs such as BuildConfig and annotation-processor output

Change any one of them and you get a different key. Change none of them and the cached output is, by construction, the output you would have compiled.

Inspecting it

kargo cache stats
Build cache
  Location      ~/.kargo/build-cache
  Entries       1,284
  Size          2.1 GiB
  Hit rate      87% (last 30 days)
kargo cache clean     # drop everything
kargo cache push      # upload current outputs to the remote cache (planned)

Where it pays off

SituationEffect
Switching branches back and forthNear-total hit rate — the old branch's output is still cached
git bisectEvery revisited commit is a hit
Rebuilding after kargo cleanHits, because cleaning does not clear the cache
Editing one file in a large moduleOnly that unit misses
Bumping a dependencyMisses for everything that depends on it, hits elsewhere

Eviction

The cache is LRU-bounded:

# ~/.kargo/config.toml
[cache]
dir = "~/.kargo/build-cache"
max-size = "10GB"

The default is 10 GB. Lower it on a small disk; raise it on a CI machine that builds many branches. Eviction never considers a currently running build's entries.

dir moves the whole cache, which is the setting for a small system disk. kargo cache stats and kargo cache clean read it too, so they report on and clear the directory the build actually writes to. KARGO_HOME moves the default along with everything else Kargo keeps globally.

Remote cache

Status: ⚪ Planned.

A remote cache shares compiled output across machines — most usefully, CI populates it and developers read from it.

# ~/.kargo/config.toml or Kargo.toml
[cache]
local = true
local-dir = "~/.kargo/build-cache"
local-max-size = "10GB"
remote = "https://cache.example.com/kargo"
remote-auth = "${env:KARGO_CACHE_TOKEN}"
remote-push = false     # developers pull; CI pushes

The protocol is deliberately plain: GET /<key> and PUT /<key> against a content-addressable store, so any object store with an HTTP front end works — S3, GCS, a reverse proxy, or a few lines of your own.

Set remote-push = true only on trusted builders. A cache that untrusted clients can write to is a supply-chain hole: whoever can push an entry can choose what your next build compiles to.

kargo cache push        # explicit upload
kargo build --offline   # never consults the remote

When to distrust the cache

Almost never — a correct key makes a stale hit impossible, and a stale hit is a bug rather than something to work around. If a cached build misbehaves and a clean one does not, that is worth filing with the two builds' -v output attached.

To rule the cache out while diagnosing something else:

kargo cache clean && kargo clean && kargo build

Next

The Compiler Daemon

Status: 🟢 On by default, on every Kotlin version Kargo supports.

The Kotlin compiler is a large Java program, and most of what a short build costs is starting one: a fresh JVM, a cold compiler, no warm JIT. The daemon is one compiler process that stays alive between builds, so the second build and every build after it start warm.

On a 400-file project, one file edited:

wall clock
No daemon11.7s
Daemon, plus incremental compilation3.2s

Both backends use it. On the kotlinc path it makes a full recompile roughly twice as fast; with the build-tools backend it compounds with recompiling only what changed.

What Kargo keeps

One daemon per compiler version, JDK and set of JVM arguments — a daemon holds one loaded compiler, and reusing it for a build that wants another would hand that build the wrong one. Each lives under ~/.kargo/daemon/, and shuts itself down after fifteen minutes with nothing to do.

kargo cache stats          # whether one is running, and what it holds
kargo cache stop-daemon    # stop it now

A daemon that cannot start is never a failed build: Kargo compiles in a fresh JVM instead and says so under -v.

Turning it off

A one-shot build has nothing to reuse a daemon for, and leaving a JVM behind on a CI runner is a cost with no return. Any of these is enough:

# ~/.kargo/config.toml
[build]
daemon = false
kargo build --no-daemon
KARGO_NO_DAEMON=1 kargo build

When it will not help

  • The first build after a toolchain change. A new Kotlin or JDK is a new daemon, and the first build pays for starting it.
  • A build that compiles nothing. The fingerprint already answers those without a compiler at all.
  • kargo clean followed by a build. The daemon is still warm, but there is a whole project to compile through it.

Auditing Dependencies

Status: 🟢 Implemented — kargo audit queries the live OSV database. ⚪ The [audit] policy section (ignore lists, severity gates) is planned.

kargo audit

Every artifact in your resolved graph is checked against OSV, Google's open vulnerability database, which aggregates GitHub Security Advisories, the Maven ecosystem's advisories, and others.

    Scanning 47 packages

  GHSA-xxxx-yyyy-zzzz  high
    com.fasterxml.jackson.core:jackson-databind 2.13.0
    Deserialization of untrusted data
    Fixed in 2.13.4.2
    https://osv.dev/GHSA-xxxx-yyyy-zzzz
      via io.ktor:ktor-serialization-jackson 2.3.0

  1 vulnerability found (1 high)

The via line is the part that matters in practice: it names what pulled the vulnerable artifact in, which tells you whether you can fix it by bumping one direct dependency.

Filtering by severity

kargo audit --fail-on high        # exit non-zero only for high and critical
kargo audit --fail-on critical
kargo audit --fail-on low         # the default: anything at all fails

Severities, lowest to highest: low, moderate, high, critical.

Pick the gate that matches what you will actually act on. An audit that fails every build on an unfixable low in a test-only dependency gets silenced entirely, which is worse than a gate set at high.

Fixing what it finds

kargo tree --why jackson-databind       # find the path in
kargo update jackson-databind           # take the newest compatible version
kargo update --major jackson-databind   # if the fix is a major bump

When the vulnerable artifact arrives transitively and the parent has not updated, declare the fixed version directly:

[dependencies]
jackson-databind = "com.fasterxml.jackson.core:jackson-databind:2.13.4.2"

Nearest-wins resolution means a direct declaration beats any transitive one. This is the standard override, and it works today.

Policy

Status: ⚪ Planned.

[audit]
ignore = [
    "GHSA-xxxx-yyyy-zzzz",   # test-only dependency, not reachable at runtime
]
fail-on = "high"

Every entry in ignore should carry a comment saying why. An unexplained ignore list is indistinguishable from an abandoned one, and the next person cannot tell whether the risk was assessed or just silenced.

In CI

- run: kargo audit --fail-on high

Two placements, and they answer different questions:

WhereQuestion answered
On every pull requestDid this change introduce a vulnerability?
On a daily scheduleDid a vulnerability get published against code we already shipped?

The scheduled run is the one teams skip and then need. Advisories are published against versions you already depend on, with no commit on your side to trigger a PR build.

See Continuous Integration.

Limitations worth knowing

kargo audit tells you a vulnerable version is in your graph. It does not tell you the vulnerable code path is reachable from your application. A deserialization flaw in a library you only call for one trivial helper may not be exploitable in your context — but reachability analysis is not something a dependency graph can answer, so the audit does not pretend to.

It also requires network access, and a lockfile that reflects your manifest. Run kargo lock first if resolution is stale.

Other supply-chain checks

kargo tree --licenses      # what you are shipping, legally
kargo tree --duplicates    # the same library at several versions
kargo fetch --verify       # re-verify every cached checksum

Checksums are verified on every download and every cache read, not only when you ask — a tampered or truncated artifact fails the build rather than producing a confusing compiler error.

Next

Publishing

Status: ⚪ Planned — [signing], [repositories], and publishing metadata all parse, and the kargo-maven crate has the module in place, but kargo publish and kargo login are not implemented. This page describes the intended behavior. See Implementation Status.

Kargo publishes to any Maven repository: Maven Central, Google's, a corporate Nexus or Artifactory, or GitHub Packages.

kargo publish

What a published release needs

[package]
name = "my-lib"
group = "com.example"          # required — the Maven group id
version = "1.0.0"
kotlin = "2.4.21"
description = "A useful library"
license = "Apache-2.0"
repository = "https://github.com/example/my-lib"
authors = ["Jane Doe <jane@example.com>"]

group, name, and version become the coordinate com.example:my-lib:1.0.0. The metadata fields become POM elements — and Maven Central rejects a POM missing a description, a license, a developer, or an SCM URL, so filling them in is not optional if that is where you are publishing.

What gets uploaded

ArtifactContents
my-lib-1.0.0.jarCompiled classes
my-lib-1.0.0.pomDependencies and metadata
my-lib-1.0.0-sources.jarSources, for IDE navigation
my-lib-1.0.0-javadoc.jarKDoc-generated documentation
*.ascGPG signatures, when signing is configured
*.md5, *.sha1, *.sha256Checksums

Multiplatform projects publish one artifact per target plus a root module with Gradle Module Metadata, so Gradle consumers get the right platform artifact automatically.

Where it goes

[repositories]
releases = { url = "https://nexus.example.com/repository/maven-releases", username = "${env:NEXUS_USER}", password = "${env:NEXUS_PASS}" }
snapshots = { url = "https://nexus.example.com/repository/maven-snapshots", auth = "my-nexus" }
kargo publish --repository releases

A version ending in -SNAPSHOT publishes with a timestamp, and republishing the same snapshot version is allowed. Release versions are immutable: a repository that already has 1.0.0 rejects a second upload, which is a feature.

Authentication

Credentials come from .kargo.env or global config — never from a committed manifest.

kargo login                            # store a token for a repository
kargo login --repository releases
# ~/.kargo/config.toml
[credentials.my-nexus]
username = "deploy"
token-cmd = "op read 'op://Dev/Nexus/token'"

token-cmd keeps the secret in your password manager rather than on disk.

kargo publish refuses to run if the manifest contains unresolved ${env:…} placeholders, so a missing variable cannot be published as a literal string.

Signing

Maven Central requires GPG signatures.

[signing]
gpg-key = "${env:GPG_KEY_ID}"
gpg-password = "${env:GPG_PASSPHRASE}"
# .kargo.env
GPG_KEY_ID=ABCD1234
GPG_PASSPHRASE=…

Every uploaded artifact gets a detached .asc signature. Your public key must be on a keyserver Central checks before the release validates.

A release in practice

kargo test                                    # 1. green
kargo audit                                   # 2. no known vulnerabilities
# 3. set the version in Kargo.toml
kargo build --release                         # 4. build what you will ship
kargo publish --dry-run                       # 5. see what would upload
kargo publish                                 # 6. upload
git tag v1.0.0 && git push --tags             # 7. tag the commit

--dry-run builds and signs everything, then stops before upload. Use it the first time you publish to a new repository, where the failure mode is a half-uploaded release.

Versioning

Semver, and version must parse as semver or the manifest is rejected.

ChangeBump
Removed or changed a public signatureMajor
Added public API, compatiblyMinor
Fixed something, no API changePatch

Kotlin-specific traps worth knowing: adding a parameter with a default value is source-compatible but not binary-compatible; neither is adding a member to an interface without a default implementation; and changing a data class's constructor breaks its generated copy. All three are major bumps for a published library.

GitHub Packages

[repositories]
github = { url = "https://maven.pkg.github.com/example/my-lib", username = "${env:GITHUB_ACTOR}", password = "${env:GITHUB_TOKEN}" }
- env:
    GITHUB_ACTOR: ${{ github.actor }}
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  run: kargo publish --repository github

Next

Packaging

Status: ⚪ Planned — [package.docker] parses, but kargo package is not implemented. This page describes the intended behavior. See Implementation Status.

Publishing produces Maven artifacts for other builds to consume. Packaging produces things people and machines run: a JAR you can java -jar, a container image, an XCFramework for Xcode.

kargo package

By target

TargetDefault output
jvmFat JAR with dependencies bundled
androidAPK, or AAB with --bundle
ios-*.framework, or an XCFramework with --ios-universal
jsBundled .js plus .d.ts declarations
linux-x64, mingw-x64, macos-*Native executable
wasm-js.wasm plus JavaScript glue

Output lands in build/<target>/<profile>/dist/.

JVM

kargo package                      # fat JAR
kargo package --format thin        # JAR plus a lib/ directory
kargo package --format dist        # ZIP with bin/ launcher scripts and lib/
FormatUse when
Fat JARA single file to copy and run. Simplest to deploy.
ThinDependencies change less often than your code — layer them in a container.
Dist ZIPYou want launcher scripts for Unix and Windows.

Fat JARs need a duplicate strategy, because two dependencies will eventually both ship META-INF/services/…:

[package.jar]
main-class = "com.example.MainKt"
merge-service-files = true
exclude = ["META-INF/*.SF", "META-INF/*.DSA"]

merge-service-files concatenates META-INF/services entries instead of letting one overwrite the other. Without it, a service-loader-based library — most JDBC drivers, many logging bridges — silently stops finding its implementations. The exclusions drop signature files that are invalid once a JAR is repackaged.

Docker

kargo package --docker
kargo package --docker --tag my-service:1.2.0
kargo package --docker --push
[package.docker]
base-image = "eclipse-temurin:25-jre-alpine"
ports = [8080]
entrypoint = "java -jar /app/app.jar"
labels = { maintainer = "team@example.com" }

Kargo generates the Dockerfile and builds the image. With no base-image, it picks a JRE matching your java-target.

The generated Dockerfile copies dependencies and application code in separate layers, so a code-only change does not invalidate the dependency layer — the difference between a 2 MB push and a 200 MB one.

Bring your own Dockerfile when you need to:

kargo package --docker --dockerfile ./Dockerfile

Apple frameworks

kargo package --target ios-arm64                # device framework
kargo package --ios-universal                   # XCFramework: device + simulator
kargo package --target macos-arm64 --format app-bundle

An XCFramework is what an Xcode project should consume: one bundle containing every architecture, so Xcode picks the right slice for device and simulator builds without a build-phase script.

import MyLib

let greeting = Greeting().greet()

Native binaries

kargo package --target linux-x64
kargo package --target mingw-x64
kargo package --target macos-arm64

Produces a self-contained executable with no JVM required. Each needs a matching host — Kotlin/Native does not cross-compile between operating systems.

Signing

kargo package --sign
[signing]
gpg-key = "${env:GPG_KEY_ID}"
gpg-password = "${env:GPG_PASSPHRASE}"

Apple targets use Xcode's signing identity for code signing; JVM and native artifacts get detached GPG signatures. See Secrets for handling the credentials.

In CI

- run: kargo package --release
- uses: actions/upload-artifact@v4
  with:
    name: dist
    path: build/*/release/dist/

Package from a tag, not from every commit — see Continuous Integration.

Next

Plugins and Hooks

Status: ⚪ Planned — [hooks] parses and the kargo-plugin crate is scaffolded, but no lifecycle phase dispatches hooks and no plugin mechanism is live. This page describes the intended design. See Implementation Status.

Kargo's manifest is declarative on purpose, which means it cannot express everything. Extensibility is the escape hatch — deliberately narrower than Gradle's "a build script is a program", and correspondingly easier to reason about.

Three tiers, in increasing power and decreasing isolation.

Hooks

Run a command at a lifecycle boundary:

[hooks]
pre-build = ["fmt --check", "lint"]
post-compile = ["./scripts/generate-openapi.sh"]
post-test = ["coverage-report"]

Entries are Kargo subcommands or external commands. They run in the project directory with the full set of KARGO_* environment variables available, so a script knows the target, profile, variant, and output directory without being told.

Hook points

PhaseHooks
Resolutionpre-resolve, post-resolve
Fetchingpre-fetch, post-fetch
Buildpre-build, post-build
Compilationpre-compile, post-compile
Testpre-test, post-test
Lint and formatpre-lint, post-lint, pre-fmt, post-fmt
Publishpre-publish, post-publish
Cleanpre-clean, post-clean
Per variantpre-variant-build, post-variant-build

A non-zero exit from a pre-* hook stops the build. That is what makes pre-build = ["fmt --check"] a gate rather than a suggestion.

pre-variant-build fires once per variant during --all-variants, which is where per-variant codegen belongs.

Keep hooks boring

A hook that takes 400ms runs on every build, every save under kargo watch, and every CI job. Hooks are for cheap, deterministic steps. Expensive codegen belongs in an annotation processor whose output is fingerprinted and cached — a hook is not.

Subcommand plugins

Any executable named kargo-<name> on your PATH becomes kargo <name>:

# ~/.local/bin/kargo-deploy
kargo deploy staging

This is Cargo's model, and it is the right default for team tooling: a plugin is an ordinary program in any language, with no API to learn and nothing to version against Kargo itself.

Plugins get project context from the environment and from kargo metadata:

#!/usr/bin/env bash
set -euo pipefail
PROJECT=$(kargo metadata --format json)
NAME=$(jq -r .package.name <<< "$PROJECT")
echo "Deploying $NAME to ${1:?environment required}"
kargo plugin install my-plugin
kargo plugin list
kargo plugin remove my-plugin

Script plugins

For logic that needs to participate in the build rather than wrap it, embedded Rhai scripts:

[plugins.my-codegen]
script = "kargo-plugins/codegen.rhai"
hook = "pre-compile"
// kargo-plugins/codegen.rhai
let manifest = get_manifest();
let version = manifest.package.version;

emit_file(
    "generated/Version.kt",
    `package com.example

object Version {
    const val NAME = "${version}"
}
`
);

log("info", `generated Version.kt for ${version}`);

Scripts are sandboxed: file writes are scoped to the project's generated-source directory, and there is no process spawning or network access. The trade is capability for the guarantee that a script cannot do something surprising to the machine running the build.

Script API

FunctionPurpose
get_manifest()The parsed manifest
get_dependencies()The resolved dependency graph
get_targets()Active targets
emit_file(path, content)Write a generated source file
register_task(name, deps, handler)Define a task
register_command(name, desc, handler)Add a subcommand
register_hook(phase, handler)Attach to a lifecycle phase
log(level, message)Structured logging into the build output

Files written with emit_file are added to the compilation and fingerprinted, so generated code participates in incremental builds properly.

WASM plugins

Status: ⚪ Design only.

A third tier for distributable plugins: compiled to WebAssembly, run in a wasmtime sandbox with explicit capabilities, installable from a registry. This is how a third-party plugin could be trusted enough to run in your build without auditing its source.

Which tier to use

You want toUse
Run a check before buildsA hook
Add a team-specific commandA subcommand plugin
Generate sources from the manifestA script plugin
Transform compiler behaviorA Kotlin compiler plugin in [plugins]
Process annotationsKSP

Try the list top-down. A hook you can read in one line is worth more than a plugin you have to maintain.

Next

Editors and IDEs

Status: ⚪ Planned — kargo metadata and kargo lsp are not implemented. This page describes the intended integration. See Implementation Status.

Kargo projects are meant to work in your editor without that editor knowing anything about Kargo. Two pieces make that possible: a machine-readable project model, and a language server.

kargo metadata

kargo metadata --format json

One JSON document describing the fully resolved project:

{
  "package": { "name": "my-app", "version": "1.2.0", "kotlin": "2.4.21" },
  "targets": [
    {
      "name": "jvm",
      "javaTarget": "25",
      "sourceSets": [
        { "name": "commonMain", "kotlin": ["src/commonMain/kotlin"] },
        { "name": "jvmMain", "kotlin": ["src/jvmMain/kotlin"], "dependsOn": ["commonMain"] }
      ],
      "classpath": [
        "~/.kargo/cache/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.8.0/kotlinx-coroutines-core-1.8.0.jar"
      ],
      "compilerArgs": ["-jvm-target", "25"]
    }
  ],
  "variants": ["free-staging-dev", "paid-production-release"],
  "buildDir": "build"
}

Everything an editor needs — source roots, classpath JARs, compiler arguments, the source-set graph — without reimplementing resolution. This is also the contract subcommand plugins use, which keeps one format honest instead of two.

kargo metadata --format json | jq -r '.targets[].classpath[]'

Language server

kargo lsp

An LSP server providing:

  • diagnostics from kargo check, as you type
  • lint warnings inline, with auto-fixes as code actions
  • completion and validation inside Kargo.toml, including dependency coordinates
  • jump-to-definition across source sets, respecting expect/actual

Any LSP-capable editor can drive it. For Kotlin code intelligence itself, the intent is to delegate to the Kotlin language server rather than reimplement it — Kargo's job is to tell it the right classpath and source roots.

IntelliJ IDEA and Android Studio

Status: ⚪ Planned — a plugin consuming kargo metadata.

The goal is opening a Kargo project with full code intelligence and no Gradle import step. kargo metadata exists precisely so a plugin can map the project model onto IntelliJ's module system without duplicating resolution logic.

Until then, the practical workaround is a minimal Gradle or Maven file that declares the same dependencies for the IDE's benefit while Kargo does the real builds. It is not elegant, and it is the honest state of things today.

VS Code

Status: ⚪ Planned.

An extension wrapping kargo lsp, plus tasks for build, test, and run, and Kargo.toml completion.

Today, .vscode/tasks.json gets you most of the way:

{
  "version": "2.0.0",
  "tasks": [
    { "label": "kargo build", "type": "shell", "command": "kargo build", "group": "build" },
    { "label": "kargo test", "type": "shell", "command": "kargo test", "group": "test" },
    { "label": "kargo check", "type": "shell", "command": "kargo check" }
  ]
}

Editor-agnostic workflow that works now

kargo watch --build-only    # continuous compilation in a terminal
kargo check                 # bind to a keystroke
kargo test --filter MyTest  # run one test

Not as good as inline diagnostics, but fast — a native binary with no daemon gives useful feedback on check well before an IDE would finish importing.

Next

Continuous Integration

Status: 🟢 The build, test, and dependency commands used here work today. Steps using ⚪ planned commands are marked.

Kargo suits CI well: one binary, no daemon, no wrapper, and caches that are ordinary directories you can restore.

GitHub Actions

name: CI

on:
  pull_request:
  push:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Kargo
        run: cargo install --git https://github.com/dejanradmanovic/kargo kargo-cli

      - name: Cache Kargo directories
        uses: actions/cache@v4
        with:
          path: |
            ~/.kargo/toolchains
            ~/.kargo/cache
            ~/.kargo/build-cache
          key: kargo-${{ runner.os }}-${{ hashFiles('Kargo.lock') }}
          restore-keys: kargo-${{ runner.os }}-

      - run: kargo build --release
      - run: kargo test
      - run: kargo audit --fail-on high

The cache key is the important line. Keying on Kargo.lock means a dependency change invalidates the artifact cache, while restore-keys still gives you the previous cache as a starting point rather than a cold download of everything.

DirectoryHoldsWorth caching
~/.kargo/toolchainsKotlin compilersYes — hundreds of MB per version
~/.kargo/cacheMaven artifactsYes — shared by every checkout
~/.kargo/build-cacheCompiled outputYes — the big win on repeat builds
build/This build's outputNo

Install once, if you can

cargo install compiles Kargo from source on every run, which is slow. Download the prebuilt binary instead — one request, no toolchain, and the checksum comes with it:

      - name: Install Kargo
        run: |
          base=https://github.com/dejanradmanovic/kargo/releases/download/v0.2.0
          asset=kargo-x86_64-unknown-linux-gnu.tar.gz
          curl -fsSLO "$base/$asset"
          curl -fsSLO "$base/sha256sums.txt"
          sha256sum --ignore-missing --check sha256sums.txt
          tar xzf "$asset"
          install -Dm755 kargo /usr/local/bin/kargo

Pin the version rather than using latest/download, so a release cannot change what your pipeline runs. The alternatives, if no binary fits your platform: a container image with Kargo preinstalled, or cargo install with the Cargo registry and target directory cached.

      - uses: Swatinem/rust-cache@v2        # caches the cargo install build
      - run: cargo install --git https://github.com/dejanradmanovic/kargo kargo-cli

Splitting the pipeline

Fast checks first, so an obvious failure does not wait behind a full build:

jobs:
  quick:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: kargo fmt --check      # ⚪ planned
      - run: kargo lint             # ⚪ planned
      - run: kargo check

  test:
    needs: quick
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4
      - run: kargo test

kargo check in the quick job is deliberate: it catches compile errors in a fraction of a full build.

Multiplatform matrices

Native targets need matching hosts:

    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            target: jvm
          - os: ubuntu-latest
            target: js
          - os: macos-latest
            target: ios-simulator-arm64
          - os: windows-latest
            target: mingw-x64
    steps:
      - run: kargo build --target ${{ matrix.target }}

Apple targets require macOS. Nothing cross-compiles to iOS.

Reproducible CI builds

      - run: kargo fetch
      - run: kargo build --release --offline

kargo fetch downloads everything in the lockfile; --offline then makes the build fail rather than reach the network. If it passes, the build genuinely depended only on what the lockfile named — the honest test of reproducibility, and the configuration to use for a release build.

Test reports

Status: ⚪ --report and --coverage are planned.

      - run: kargo test --report junit --coverage
      - uses: actions/upload-artifact@v4
        if: always()
        with:
          name: test-results
          path: build/reports/
      - uses: codecov/codecov-action@v6
        with:
          files: build/reports/coverage/coverage.xml

if: always() matters — you want the report from the run that failed.

Scheduled audits

on:
  schedule:
    - cron: "0 6 * * 1"     # Mondays, 06:00 UTC

jobs:
  audit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: kargo audit --fail-on high

New advisories land against versions you already depend on, with no commit to trigger a PR build. Without a scheduled run, you learn about them from someone else. See Auditing Dependencies.

Release workflow

Status: ⚪ publish and package are planned.

on:
  push:
    tags: ["v*"]

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: kargo test
      - run: kargo build --release
      - run: kargo package --release
      - run: kargo publish
        env:
          NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
          NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
          GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
          GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

Secrets come from the environment, never a committed .kargo.env — see Secrets.

GitLab CI

variables:
  KARGO_HOME: "$CI_PROJECT_DIR/.kargo-home"

cache:
  key:
    files: [Kargo.lock]
  paths:
    - .kargo-home/cache
    - .kargo-home/build-cache
    - .kargo-home/toolchains

build:
  image: rust:latest
  before_script:
    - cargo install --git https://github.com/dejanradmanovic/kargo kargo-cli
  script:
    - kargo build --release
    - kargo test

GitLab only caches paths inside the project directory, hence KARGO_HOME.

Docker

FROM rust:1.91 AS kargo
RUN cargo install --git https://github.com/dejanradmanovic/kargo kargo-cli

FROM eclipse-temurin:25-jdk AS build
COPY --from=kargo /usr/local/cargo/bin/kargo /usr/local/bin/kargo
WORKDIR /src
COPY Kargo.toml Kargo.lock ./
RUN kargo fetch
COPY src ./src
RUN kargo build --release

FROM eclipse-temurin:25-jre
COPY --from=build /src/build/jvm/release/output/*.jar /app/app.jar
ENTRYPOINT ["java", "-jar", "/app/app.jar"]

Copying the manifest and lockfile before the sources is the standard layering trick: dependencies are re-fetched only when they actually change.

Keeping the test jars out of the image

A release image has no use for the dev-dependencies, and a plain kargo fetch downloads them anyway. --skip-dev resolves the whole graph — the lockfile is written whole either way — but downloads only what the build will open:

COPY Kargo.toml Kargo.lock ./
RUN kargo fetch --skip-dev
COPY src ./src
RUN kargo build --release

A stage that runs the tests adds the other half on top of that layer, without re-downloading what the build layer already has:

FROM build AS test
RUN kargo fetch --dev-only
RUN kargo test

The two flags are the halves of one choice, so they cannot be combined. Neither changes Kargo.lock: a partial fetch never writes a partial lockfile.

kargo build needs no equivalent flag: it never downloads the dev-dependencies, whether or not the cache already has them.

Next

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

Troubleshooting

Status: 🟢 The diagnostics here work today. ⚪ kargo doctor is planned.

First moves

kargo build -v          # full compiler command lines and resolution detail
kargo self info         # versions, paths, cache sizes
kargo env               # what the build sees (secrets masked)
kargo tree              # the resolved graph

-v is usually enough. It prints the exact kotlinc invocation, which turns "the build failed" into a command you can run yourself.

Toolchain problems

Kotlin 2.4.21 not found and no download starts

Either auto-download = false is set, or the network is unavailable.

kargo toolchain list
kargo toolchain install 2.4.21

JDK not found

Kargo checks [toolchain] jdk, then .kargo.env, then JAVA_HOME, then common paths — see Toolchains.

java -version
echo $JAVA_HOME
[toolchain]
jdk = "/usr/lib/jvm/java-25-openjdk"

Unsupported class file major version

Your java-target exceeds the JDK running your code. java-target = "25" needs a Java 25 runtime; lower it to what you deploy on.

Apple targets fail on Linux or Windows

Expected. Kotlin/Native cannot cross-compile to Apple platforms — you need a macOS host with Xcode.

Dependency problems

Could not resolve com.example:thing:1.0.0

In order of likelihood: a typo in the coordinate; the artifact lives in a repository you have not declared; or credentials are missing for a private one.

kargo tree                         # is it even in the graph?
kargo add com.example:thing:1.0.0  # verifies existence before writing
kargo env                          # are the credentials present?

The wrong version of a transitive dependency wins

Kargo uses Maven's nearest-wins rule, not Gradle's highest-wins. A direct declaration beats everything:

kargo tree --why some-lib
kargo tree --conflicts
[dependencies]
some-lib = "com.example:some-lib:2.0.0"

Checksum mismatch

The downloaded artifact does not match its published checksum. Usually a corrupted cache entry or a proxy mangling the response; occasionally something worse.

kargo self clean
kargo fetch --verify

--offline fails but a normal build works

Something is not in the cache. Run kargo fetch while online, then retry — this is exactly what --offline is for detecting.

Build problems

A stale build, apparently

Incremental compilation is supposed to be correct. Establish whether it is the cache:

kargo clean && kargo build        # clears fingerprints
kargo cache clean && kargo build  # clears the build cache too

If a clean build differs from an incremental one, that is a bug worth filing with both -v outputs.

Sources are not being compiled

Source discovery is by directory convention. A file in src/kotlin/ rather than src/main/kotlin/ is invisible. Check it against Project Layout, and confirm the target name matches the source set: ios-arm64 reads src/iosArm64Main/, not src/ios/.

kargo run cannot find a main class

[package]
main-class = "com.example.MainKt"

A top-level fun main() in Main.kt with package com.example compiles to com.example.MainKt — the Kt suffix is easy to forget.

This command is not yet implemented

The command is accepted by the CLI but not built yet. Check Implementation Status for where it sits.

Manifest problems

Failed to parse Kargo.toml

The message includes the line. The recurring causes are a bare value where a table belongs, and inline-table syntax spread across lines — TOML requires an inline table to fit on one line:

# Invalid
my-repo = {
  url = "https://example.com"
}

# Valid
my-repo = { url = "https://example.com" }

# Also valid
[repositories.my-repo]
url = "https://example.com"

package.version must be valid semver

version = "1.0" is not semver. Use 1.0.0.

Unresolved ${env:NEXUS_PASSWORD}

The variable is not in .kargo.env and not in the environment. This is an error rather than an empty string on purpose — see Secrets.

Performance

Every build recompiles everything

kargo build --timings
kargo build -v            # look for what missed its fingerprint

Common causes: .kargo/fingerprints/ is being deleted between builds (a CI cache that excludes it); a hook rewriting a source file on every run; a generated file with a timestamp in it, which changes its hash every time.

CI is slow

Cache ~/.kargo/toolchains, ~/.kargo/cache, and ~/.kargo/build-cache — see Continuous Integration.

kargo doctor

Status: ⚪ Planned.

kargo doctor
Checking project health

  ✓ Kotlin 2.4.21 toolchain installed
  ✓ JDK 25 found at /usr/lib/jvm/java-25-openjdk
  ✗ Android SDK platform 36 not installed
      run: sdkmanager "platforms;android-36"
  ! kotlinx-coroutines-core 1.8.0 is declared but never imported
  ! expect fun platformName() has no actual for target js
  ✓ Build cache healthy (2.1 GiB, 87% hit rate)

  1 error, 2 warnings

One command for the class of problem that is really an environment problem.

Getting help

Open an issue with:

  • kargo self info output
  • the failing command with -v
  • your Kargo.toml, with secrets removed
  • what you expected instead

Next

Command Reference

Every command Kargo accepts. The status marker reflects what runs today — 🟢 implemented, 🟡 partial, ⚪ planned. Planned commands parse and then exit with "this command is not yet implemented". See Implementation Status.

Global flags

These work on every command.

FlagStatusEffect
-v, --verbose🟢Full compiler command lines and resolution detail.
-q, --quiet🟢Print only warnings and errors. Cannot be combined with -v.
--color <when>🟢auto (default), always, or never.

Exit codes

CodeMeaning
0Success
1Failure with no more specific code
2Command invoked incorrectly
3Manifest, lockfile, or config problem
4Dependency resolution failed
5Network or repository failure
6Missing or unusable toolchain
101Compilation, annotation processing, or test failure

kargo run exits with the status of the program it ran.

CommandStatusPurpose
new🟢Create a project
init🟢Add Kargo to an existing directory
build🟢Compile
run🟢Compile and execute
test🟡Run tests
check🟢Type-check only
clean🟢Remove build output
watch🟢Rebuild on change
add🟢Add a dependency
remove🟢Remove a dependency
update🟢Update locked versions
fetch🟢Download without building
lock🟢Regenerate the lockfile
tree🟢Print the dependency graph
outdated🟢Show available updates
audit🟢Scan for vulnerabilities
env🟢Show the resolved environment
toolchain🟢Manage Kotlin, JDK, and Android SDKs
cache🟢Manage the build cache and compile daemon
self🟢Manage the Kargo installation
lint⚪Run the linter
fmt⚪Format sources
fix⚪Apply auto-fixes
doc⚪Generate KDoc
bench⚪Run benchmarks
publish⚪Publish to a Maven repository
package⚪Create a distributable
repl⚪Kotlin REPL
script⚪Run a Kotlin script
metadata⚪Emit the project model as JSON
completions🟢Shell completions
plugin⚪Manage plugins
target⚪Manage targets
variant⚪Inspect build variants
flavor⚪Manage flavors
doctor⚪Diagnose project health
migrate⚪Migrate from Gradle
lsp⚪Language server

kargo new

🟢 Implemented.

kargo new <name> [-t|--template <template>]

Creates a directory named <name> containing a manifest, lockfile, .gitignore, .kargo.env, and source files.

ArgumentDefaultNotes
<name>requiredAlso the package name. Alphanumeric, -, _.
-t, --templatejvmjvm, lib, kmp, cmp, android

See Project Templates.

kargo init

🟢 Implemented.

kargo init [-t|--template <template>]

Adds Kargo to the current directory: manifest, lockfile, .gitignore, .kargo.env. Writes no source files and never overwrites an existing file.

kargo build

🟢 Implemented. 🟡 Flavor and variant flags are accepted but not yet applied.

kargo build [flags]
FlagStatusEffect
-t, --target <name>🟢Build one target.
-p, --profile <name>🟢Build with a named profile.
--release🟢Shorthand for --profile release.
--offline🟢Resolve only from the local cache.
--timings🟢Print per-phase timings.
--flavor <name>🟡Accepted, not applied.
--variant <name>🟡Accepted, not applied.
--all-variants🟡Accepted, not applied.

Output goes to build/<target>/<profile>/. See Building and Running.

kargo run

🟢 Implemented for JVM targets.

kargo run [-t|--target <name>] [--variant <name>] [-- <args>...]

Builds, then executes package.main-class. Everything after -- is passed to your program.

kargo run -- --port 8080

The program runs on Kargo's own streams: its output reaches the terminal while it runs, and it can read stdin. Stopping Kargo stops the program, on SIGTERM as well as Ctrl-C.

kargo test

🟡 Partial — --target and --filter work; the rest are accepted but not implemented.

kargo test [flags]
FlagStatusEffect
-t, --target <name>🟢Test one target.
-f, --filter <pattern>🟢Substring match on the fully qualified test name.
--coverage⚪Instrument and report coverage.
--report <formats>⚪junit, html, comma-separated.
--parallel⚪Run test classes concurrently.
--flavor <name>⚪Test one flavor.
--variant <name>⚪Test one variant.

See Testing.

kargo check

🟢 Implemented.

kargo check [--variant <name>]

Type-checks without producing artifacts.

kargo clean

🟢 Implemented.

kargo clean [--variant <target>/<profile>]

With no flag, removes build/ along with the metadata describing it, .kargo/fingerprints/ and .kargo/incremental/. With --variant, removes that variant's output and incremental state only — for example --variant jvm/dev. Downloaded dependencies under .kargo/dependencies/ are a cache and survive either; kargo cache clean owns them.

kargo watch

🟢 Implemented.

kargo watch [--build-only]

Rebuilds — and by default re-runs — on source or manifest changes. A program still running from the previous cycle is stopped first, so watching a server restarts it on each change rather than waiting for it to exit. Ending the session stops the program too, on SIGTERM as well as Ctrl-C.

kargo add

🟢 Implemented.

kargo add <group:artifact[:version]> [--version <v>] [--rename <key>]
          [--dev] [--target <name>] [--flavor <name>]

Verifies the artifact exists, then updates Kargo.toml and Kargo.lock. Existing formatting and comments are preserved, and the entry is inserted in alphabetical order.

Omit the version and Kargo takes the current release from the first repository that lists the artifact, reporting it as (latest). Snapshots are never chosen. With --offline an omitted version is an error rather than a guess.

FlagEffect
--version <v>The version, instead of naming it in the coordinate. Giving it both ways is an error.
--rename <key>The manifest key to file it under. Defaults to the artifact id.
noneWrites to [dependencies]
--devWrites to [dev-dependencies]
--target jvmWrites to [target.jvm.dependencies]
--flavor freeWrites to [flavor.free.dependencies]

kargo remove

🟢 Implemented. Alias: kargo rm.

kargo remove <key> [--dev] [--target <name>] [--flavor <name>]

Takes the manifest key, not the coordinate.

kargo update

🟢 Implemented.

kargo update [--major] [--dep <key>] [--dry-run]

Updates Kargo.lock to the newest semver-compatible versions. --major allows breaking bumps, --dep limits the update to one dependency, --dry-run reports without writing.

kargo fetch

🟢 Implemented.

kargo fetch [--verify] [--skip-dev | --dev-only] [--offline]

Downloads everything in the lockfile without building.

FlagDoes
--verifyRe-checks the checksums of already-cached artifacts.
--skip-devDownloads everything but the dev-dependencies.
--dev-onlyDownloads only the dev-dependencies.
--offlineReaches no repository, reporting what the cache is missing instead of filling it.

The two scope flags are the halves of one choice and cannot be combined. Both resolve the whole graph and write the whole lockfile — only the downloads narrow, so a partial fetch never leaves a partial Kargo.lock. They are for layered builds: --skip-dev for an image layer that only builds, --dev-only for a test stage on top of it. See Continuous Integration.

A fetch leaves nothing for a later command to download: the test runner and the annotation processing tooling come with the dependency graph, so kargo build and kargo test both work under --offline afterwards.

kargo lock

🟢 Implemented.

kargo lock

Resolves the manifest and rewrites Kargo.lock.

kargo tree

🟢 Implemented.

kargo tree [flags]
FlagShows
--depth <n>Only the first n levels.
--why <name>The path from your manifest to that artifact.
--duplicatesArtifacts present at more than one version.
--conflictsVersion conflicts and how each was resolved.
--licensesThe license of every artifact.
--invertedDependents instead of dependencies.

kargo outdated

🟢 Implemented.

kargo outdated [--major]

Lists dependencies with newer versions available. --major includes breaking bumps.

kargo audit

🟢 Implemented.

kargo audit [--fail-on <severity>]

Checks the resolved graph against OSV. --fail-on takes low, moderate, high, or critical. See Auditing Dependencies.

kargo env

🟢 Implemented.

kargo env [--reveal]

Prints the resolved environment from .kargo.env and the process environment, with secret-looking values masked. --reveal unmasks them.

kargo toolchain

🟢 Implemented.

kargo toolchain install [<kotlin-version>] [--jdk [<major>]] [--android [<level>]]
kargo toolchain list
kargo toolchain remove [<kotlin-version>] [--jdk <major>] [--android]
kargo toolchain use <kotlin-version>
kargo toolchain path
kargo toolchain install 2.4.21
kargo toolchain install --jdk 21
kargo toolchain install --android 36
kargo toolchain install 2.4.21 --jdk --android

use sets the default for new projects; it never overrides a project's package.kotlin. See Toolchains.

kargo cache

🟢 Implemented.

kargo cache stats         # size and entry count, plus the project's .kargo/
kargo cache clean         # clear the local build cache and the project's .kargo/
kargo cache push          # push outputs to the remote cache (⚪ no transport yet)
kargo cache stop-daemon   # stop the Kotlin compile daemon

See The Build Cache.

kargo self

🟢 Implemented.

kargo self update [--check]
kargo self info
kargo self clean

info prints versions, config paths, and cache sizes. clean removes unused toolchains and stale cache entries.

update replaces the running binary with the newest release, after checking the download against the release's published checksums. If it cannot verify the download it installs nothing and leaves the current binary in place. --check only reports whether a newer version exists.

Once the new binary is in place, update regenerates every completion script installed with kargo completions --install, so they describe the version now on disk. A script that cannot be rewritten is a warning: the upgrade itself already succeeded. Nothing is reported when no completions were installed.

kargo lint

⚪ Planned.

kargo lint [--fix]

Runs the built-in linter against [lint] configuration. See Linting and Formatting.

kargo fmt

⚪ Planned.

kargo fmt [--check]

Formats sources per [format]. --check reports without writing and exits non-zero if anything would change.

kargo fix

⚪ Planned.

kargo fix

Applies every auto-fixable lint and formatting suggestion.

kargo doc

⚪ Planned.

kargo doc [--open]

Generates KDoc into build/docs/. --open opens it in a browser.

kargo bench

⚪ Planned.

kargo bench [--compare <baseline>]

Runs kotlinx-benchmark benchmarks. --compare diffs against a stored baseline.

kargo publish

⚪ Planned.

kargo publish

Publishes JAR, POM, sources, and KDoc to a Maven repository, signing if [signing] is configured. See Publishing.

kargo package

⚪ Planned.

kargo package [--docker] [--ios-universal]

Creates a distributable. --docker builds a container image; --ios-universal builds an XCFramework. See Packaging.

kargo repl

⚪ Planned.

kargo repl

Starts a Kotlin REPL with your project's classpath loaded.

kargo script

⚪ Planned.

kargo script <file.kts>

Runs a Kotlin script against the project's dependencies.

kargo metadata

⚪ Planned.

kargo metadata [--format json]

Emits the resolved project model — targets, source sets, classpaths, compiler arguments — for editors and plugins. See Editors and IDEs.

kargo completions

🟢 Implemented.

kargo completions <bash|zsh|fish|powershell|elvish> [--install]

Writes a completion script to stdout, generated from the command surface this binary actually has — so the completions match the version installed rather than the version the docs were written for.

--install writes it where the shell reads it instead, and reports the path. Three shells load it from there on their own; for the other two the output names the one line to add to a profile. Installing again replaces the file, and kargo self update does exactly that for every shell installed this way, so an upgrade does not leave completions describing the old binary.

Shell--install writesLoaded
bash$XDG_DATA_HOME/bash-completion/completions/kargoautomatically
fish$XDG_CONFIG_HOME/fish/completions/kargo.fishautomatically
zsh~/.zfunc/_kargoneeds an fpath line
powershell$KARGO_HOME/completions/kargo.ps1needs a dot-source line
elvish$KARGO_HOME/completions/kargo.elvneeds an eval line

XDG_DATA_HOME and XDG_CONFIG_HOME fall back to ~/.local/share and ~/.config; KARGO_HOME falls back to ~/.kargo.

An unrecognized shell is a usage error, exit 2.

The per-shell setup, in full: Shell completions.

kargo plugin

⚪ Planned.

kargo plugin install <name>
kargo plugin list
kargo plugin remove <name>

See Plugins and Hooks.

kargo target

⚪ Planned.

kargo target add <target>
kargo target list
kargo target remove <target>

Edits [targets] and creates the matching source-set directories.

kargo variant

⚪ Planned.

kargo variant list
kargo variant info <name>

list prints every variant in the flavor-by-profile matrix minus exclusions. info prints one variant's source sets, dependencies, and build config. See Flavors and Variants.

kargo flavor

⚪ Planned.

kargo flavor add <dimension> <name>
kargo flavor remove <dimension> <name>

Edits [flavors].

kargo doctor

⚪ Planned.

kargo doctor

Checks toolchain availability, SDK versions, unused dependencies, missing actual declarations, and cache health. See Troubleshooting.

kargo migrate

⚪ Planned.

kargo migrate

Reads Gradle build files and writes a Kargo.toml, reporting what it could not translate. See Coming from Gradle.

kargo lsp

⚪ Planned.

kargo lsp

Starts a Language Server Protocol server on stdio. See Editors and IDEs.

Exit codes

CodeMeaning
0Success
1The operation failed — compile error, failing test, unresolved dependency
2Invalid usage — unknown flag, bad argument

Audit and lint failures exit 1, which is what makes them usable as CI gates.

Manifest Format

Every section of Kargo.toml. All of them parse and validate today; the Effect column says whether a section currently changes a build. See Implementation Status, and The Manifest for the guided version.

Keys are kebab-case. Maps preserve sorted order when serialized, so generated output is byte-stable.

SectionEffect
[package]🟢 Active
[targets]🟢 Active
[source-sets.<name>]🟢 Active
[dependencies]🟢 Active
[dev-dependencies]🟢 Active
[target.<name>.dependencies]🟢 Active
[flavor.<name>.dependencies]🟡 Parsed, not applied
[plugins]🟢 Active
[ksp] / [ksp-options]🟢 Active
[kapt] / [kapt-options]🟢 Active
[build-config]🟢 Active
[compose]⚪ Parsed
[flavors]🟡 Parsed, not applied
[profile.<name>]🟢 Active
[repositories]🟢 Active
[toolchain]🟢 Active
[workspace]🟡 Parsed, not orchestrated
[catalog]🟡 Parsed, references unresolved
[test]⚪ Parsed
[lint] / [format]⚪ Parsed
[hooks]⚪ Parsed
[signing]⚪ Parsed
[package.docker]⚪ Parsed

[package]

KeyTypeRequiredDescription
namestringyesAlphanumeric, -, _. Validated on load.
versionstringyesMust parse as semver.
kotlinstringyesExact Kotlin compiler version.
groupstringfor publishingMaven group id.
main-classstringfor kargo runJVM entry point, e.g. com.example.MainKt.
descriptionstringnoCarried into the published POM.
authorslistno"Name <email>" entries.
licensestringnoSPDX identifier.
repositorystringnoSource repository URL.
ksp-versionstringnoPins the KSP processor API version.
[package]
name = "my-service"
group = "com.example"
version = "1.2.0"
kotlin = "2.4.21"
description = "Order processing service"
authors = ["Jane Doe <jane@example.com>"]
license = "Apache-2.0"
repository = "https://github.com/example/my-service"
main-class = "com.example.MainKt"

[targets]

A map of target name to options. Names accept kebab-case or camelCase. See the Targets reference for the full list.

[targets.jvm]
java-target = "25"
[targets]
jvm = { java-target = "25" }
android = { min-sdk = 24, target-sdk = 36, compile-sdk = 36 }
ios-arm64 = {}
js = { module-kind = "es" }
KeyApplies toDescription
java-targetjvm, androidBytecode level, e.g. "17", "25".
module-kindjs"es" or "commonjs".
min-sdkandroidMinimum Android API level.
target-sdkandroidAndroid API level targeted.
compile-sdkandroidAndroid API level compiled against.
cinteropnativeC interop definitions, see below.

Android requires min-sdk <= target-sdk; violating it fails validation.

[source-sets.<name>]

Declares what the conventional layout would otherwise infer for one source set.

[source-sets.jvmMain]
kotlin = ["legacy/src/java", "build/generated/kotlin"]
resources = ["legacy/src/resources"]
depends-on = ["commonMain"]

[source-sets.jvmAndAndroidMain]
depends-on = ["commonMain"]
targets = ["jvm", "android"]
KeyTypeDescription
kotlinlistSource roots, relative to the project root, replacing src/<name>/kotlin.
resourceslistResource roots, replacing src/<name>/resources.
depends-onlistParent source sets, replacing the inferred parent.
targetslistThe targets this set compiles into, which is how a grouping the standard hierarchy does not provide gets one.

The name is main or test in the Maven layout, and ends in Main or Test in the multiplatform one. A key left out keeps the convention, so moving the sources says nothing about the resources, and an empty list reads the same way as leaving the key out. Declaring a set is itself what brings it into existence — its directories need not be under src/.

See the Source Sets reference.

[dependencies]

A map of local alias to dependency. Three forms:

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

# detailed
my-lib = { group = "com.example", artifact = "my-lib", version = "1.0.0" }

# catalog reference
ktor-server = { catalog = "ktor-server", bundle = true }

Detailed form keys:

KeyTypeDescription
groupstringMaven group id. Required.
artifactstringMaven artifact id. Required.
versionstringExact version. Empty means "from an imported BOM".
scopestringcompile (default), runtime, provided, test, system, import.
optionalboolNot propagated to consumers.
classifierstringFor platform-specific artifacts.
exclusionsarray of tables{ group, artifact }; omit artifact for the whole group.
[dependencies.jackson-databind]
group = "com.fasterxml.jackson.core"
artifact = "jackson-databind"
version = "2.16.1"

[[dependencies.jackson-databind.exclusions]]
group = "org.slf4j"
artifact = "slf4j-log4j12"

Catalog form keys: catalog (the entry name) and bundle (whether the name refers to a bundle).

[dev-dependencies]

Identical shape. On the test compile and runtime classpath only; never published.

[target.<name>.dependencies]

Dependencies that apply only when building that target.

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

[target.ios.dependencies]
ktor-client-darwin = "io.ktor:ktor-client-darwin:2.3.0"

[flavor.<name>.dependencies]

🟡 Parsed, not yet applied to builds.

[flavor.free.dependencies]
ad-sdk = "com.example:ad-sdk:2.0.0"

Note the singular flavor here, versus plural flavors for definitions.

[plugins]

Kotlin compiler plugins by id. A bare string, or a table with a version.

[plugins]
serialization = "org.jetbrains.kotlin.plugin.serialization"
parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version = "2.4.21" }

Without version, the plugin tracks package.kotlin.

[ksp]

KSP annotation processors, in dependency form.

[ksp]
room-compiler = "androidx.room:room-compiler:2.6.1"

[ksp-options]

String options passed to KSP processors.

[ksp-options]
"room.schemaLocation" = "build/schemas"
"room.incremental" = "true"

[kapt]

KAPT annotation processors, for libraries that have not moved to KSP.

[kapt]
dagger-compiler = "com.google.dagger:dagger-compiler:2.59.2"

Only what this section declares runs. Generated sources land in build/<target>/<profile>/generated/kapt/sources and join the main compile; the Java stubs the processors read stay in generated/kapt/stubs.

Every pass is a full pass — there is no incremental KAPT — and kapt's own javacOption has no manifest key. KAPT is deprecated upstream, so prefer [ksp] when a processor offers both.

[kapt-options]

Options for the KAPT processors, passed as -A<key>=<value> the same way a javac invocation would pass them.

[kapt-options]
"dagger.fastInit" = "enabled"

[build-config]

Compile-time constants emitted into a generated BuildConfig object. Values are strings and support ${env:…} interpolation.

[build-config]
API_VERSION = "v2"
TELEMETRY_ENABLED = "false"

Merged with flavor build-config, flavors taking precedence.

[compose]

⚪ Parsed; the compiler plugin is not applied yet.

[compose]
enabled = true

See Compose Multiplatform.

[flavors]

🟡 Parsed and validated; not applied to builds.

[flavors]
dimensions = ["tier", "environment"]
default = { tier = "paid", environment = "staging" }
exclude = [{ tier = "free", environment = "production" }]

[flavors.tier.free]
build-config = { IS_PAID = "false" }
application-id-suffix = ".free"

[flavors.tier.paid.signing]
keystore = "release.keystore"
key-alias = "paid-release"
store-password-cmd = "op read 'op://Dev/Keystore/password'"
KeyTypeDescription
dimensionslistOrdered axes. Order determines variant naming.
defaulttableFlavor per dimension, used when none is specified.
excludearray of tablesCombinations that do not exist.

Per-flavor keys, under [flavors.<dimension>.<flavor>]:

KeyTypeDescription
build-configtableConstants for this flavor.
application-id-suffixstringAppended to the application id.
signingtablekeystore, key-alias, store-password-cmd.

See Flavors and Variants.

[profile.<name>]

[profile.dev]
debug = true
optimization = false

[profile.release]
debug = false
optimization = true
compiler-args = ["-Xjvm-default=all"]
KeyTypeDescription
debugboolEmit debug symbols.
optimizationboolEnable compiler optimizations.
compiler-argslistExtra flags passed to the compiler verbatim.

dev and release exist without being declared. Any other name defines a custom profile. See Build Profiles.

[repositories]

A map of name to URL or table. Maven Central is always available and tried last.

[repositories]
google = "https://maven.google.com"
internal = { url = "https://nexus.example.com/maven", username = "${env:NEXUS_USER}", password = "${env:NEXUS_PASS}" }
shared = { url = "https://nexus.example.com/maven", auth = "my-nexus" }
KeyTypeDescription
urlstringRepository base URL. Required in table form.
usernamestringBasic auth user. Use ${env:…}.
passwordstringBasic auth password or token. Use ${env:…}.
authstringName of a [credentials.*] entry in global config.

[toolchain]

[toolchain]
jdk = "25"
kotlin-mirror = "https://mirror.example.com/kotlin"
auto-download = true
KeyTypeDescription
jdkstringA major version, or an absolute path.
kotlin-mirrorstringAlternative to the JetBrains release archive.
auto-downloadboolDefault true. Set false for air-gapped builds.

See Toolchains.

[workspace]

🟡 Parsed; member builds are not orchestrated yet.

[workspace]
members = ["app", "shared", "libs/*"]
exclude = ["experimental"]

Globs are supported in members. A workspace root usually has no [package]. See Workspaces.

[catalog]

🟡 Parsed; { catalog = … } references are not resolved yet.

[catalog.versions]
ktor = "2.3.0"

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

[catalog.bundles]
ktor-server = ["ktor-server-core", "ktor-server-netty"]

[catalog.plugins]
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
SubsectionShape
versionsname to version string
librariesname to { group, artifact, version or version.ref }
bundlesname to a list of library names
pluginsname to { id, version or version.ref }

See Version Catalogs.

[test]

⚪ Parsed; coverage is not implemented.

[test.coverage]
engine = "kover"
min-line = 80
min-branch = 70
exclude = ["**/generated/**", "**/BuildConfig.*"]
KeyTypeDescription
enginestringkover or jacoco.
min-lineintegerFail below this line coverage percentage.
min-branchintegerFail below this branch coverage percentage.
excludelistGlob patterns excluded from measurement.

[lint]

⚪ Parsed; the linter is not implemented.

[lint]
rules = ["naming", "style", "complexity"]
severity = "warning"

See the Lint Rules reference.

[format]

⚪ Parsed; the formatter is not implemented.

[format]
style = "official"
indent = 4
max-line-length = 120

[hooks]

⚪ Parsed; no lifecycle phase dispatches hooks yet.

A map of phase name to a list of commands.

[hooks]
pre-build = ["fmt --check", "lint"]
post-compile = ["./scripts/generate-openapi.sh"]
post-test = ["coverage-report"]

Phase names are listed in Plugins and Hooks.

[signing]

⚪ Parsed; publishing is not implemented.

[signing]
gpg-key = "${env:GPG_KEY_ID}"
gpg-password = "${env:GPG_PASSPHRASE}"

[package.docker]

⚪ Parsed; packaging is not implemented.

[package.docker]
base-image = "eclipse-temurin:25-jre-alpine"
ports = [8080]
entrypoint = "java -jar /app/app.jar"
labels = { maintainer = "team@example.com" }

[target.<name>.cinterop.<name>]

⚪ Parsed; CInterop is not implemented.

[target.ios-arm64.cinterop.mylib]
def-file = "src/nativeInterop/cinterop/mylib.def"
headers = ["include/mylib.h"]
compiler-opts = ["-Iinclude"]
linker-opts = ["-L/usr/local/lib", "-lmylib"]

Environment interpolation

Any string value may contain ${env:VAR}, resolved before TOML parsing from .kargo.env and then the process environment. An unresolved reference is an error naming the variable.

[repositories]
internal = { url = "${env:NEXUS_URL}", username = "${env:NEXUS_USER}", password = "${env:NEXUS_PASS}" }

Validation

Checked when the manifest loads, before any build work:

  • package.name is non-empty and contains only alphanumerics, -, and _
  • package.version parses as semver
  • Android min-sdk <= target-sdk
  • Target names are recognized, in [targets] and in a source set's targets
  • [source-sets] names end in Main or Test (or are main/test), and their depends-on edges form no cycle
  • [flavors] default and exclude reference declared dimensions and flavors

Failures report the offending key rather than a generic parse error.

Lockfile Format

Status: 🟢 Implemented — generated, read, and verified on every build.

Kargo.lock records the exact resolution of your dependency graph: every artifact, its version, its checksum, and where it came from. A build with a current lockfile performs no version resolution.

You do not edit this file. kargo add, kargo remove, kargo update, and kargo lock write it.

Shape

[[package]]
name = "kotlinx-coroutines-core"
group = "org.jetbrains.kotlinx"
version = "1.8.0"
checksum = "sha256:1a2b3c…"
source = "https://repo.maven.apache.org/maven2"
scope = "compile"
targets = ["jvm", "ios-arm64"]

[[package.dependencies]]
name = "kotlin-stdlib"
group = "org.jetbrains.kotlin"
version = "1.9.21"

[[package]]
name = "kotlin-stdlib"
group = "org.jetbrains.kotlin"
version = "1.9.21"
checksum = "sha256:4d5e6f…"
source = "https://repo.maven.apache.org/maven2"
scope = "compile"
targets = ["jvm", "ios-arm64"]

[[package]]

FieldTypeDescription
namestringMaven artifact id.
groupstringMaven group id.
versionstringThe exact resolved version.
checksumstringsha256: or sha1: digest of the artifact.
sourcestringRepository URL the artifact came from.
scopestringResolved scope: compile, runtime, provided, test, ksp, kapt. tool marks a jar Kargo provisions for itself, such as the test launcher.
targetslistTargets whose graph includes this package.
packagingstringWhat the package publishes, when that is not a jar: aar for an Android library.

[[package.dependencies]]

The edges of the graph, as name, group, and version triples pointing at other [[package]] entries. Storing edges rather than a flat list is what lets kargo tree --why reconstruct the path to any artifact without re-resolving.

Properties

Deterministic. Packages are written in sorted order with sorted fields, so resolving the same manifest twice produces byte-identical output. A diff shows dependency changes, not reordering noise.

Complete. Every transitive artifact appears, not just your direct dependencies.

Verified. Checksums are checked on download and on cache reads. A corrupted or substituted artifact fails the build rather than reaching the compiler.

Atomic. The file is written to a temporary file in the same directory and then renamed, so an interrupted write cannot leave a truncated lockfile.

Per-target aware. The targets field records which targets include each package, so a multiplatform project can resolve different artifacts per platform within one lockfile.

Commands

kargo lock              # resolve the manifest and rewrite the lockfile
kargo fetch             # download everything the lockfile names
kargo fetch --verify    # re-verify checksums of cached artifacts
kargo update            # move to newer compatible versions
kargo update --dry-run  # show what would change

Committing it

ProjectCommitReason
ApplicationYesEvery machine and CI run builds an identical graph.
LibraryUsually notConsumers resolve their own graph; yours has no effect on them.

For a library, committing the lockfile pins only what your own CI tests against. That is a defensible choice — just know it does nothing for your users.

When it is regenerated

ActionEffect
kargo add / kargo removeIncremental update for the changed dependency.
kargo updateVersions re-resolved within the allowed range.
kargo lockFull re-resolution from the manifest.
Editing Kargo.toml by handThe next build detects the mismatch and re-resolves.
kargo build with a current lockfileNo resolution at all.

Merge conflicts

A conflict in Kargo.lock is not worth resolving by hand. Take either side and regenerate:

git checkout --theirs Kargo.lock
kargo lock

The result is deterministic, so you will get the correct file regardless of which side you started from.

Next

Global Configuration

Status: 🟢 The file is read and most keys are honored. ⚪ Remote cache keys parse but have no transport yet, and [lint] / [format] defaults await the linter.

~/.kargo/config.toml holds machine-wide settings: parallelism, cache location, credentials, toolchain preferences. On Windows, %USERPROFILE%\.kargo\config.toml.

Project settings in Kargo.toml always win. Global config is for what belongs to the machine, not the project — nothing here should be required for a checkout to build.

A complete example

[build]
jobs = 8
default-target = "jvm"
compiler-backend = "build-tools"

[repositories]
google = "https://maven.google.com"
internal = "https://nexus.example.com/repository/maven-public"

[credentials.my-nexus]
username = "deploy"
token-cmd = "op read 'op://Dev/Nexus/token'"

[cache]
dir = "~/.kargo/build-cache"
max-size = "10GB"
write = true
remote = "https://cache.example.com/kargo"
remote-auth = "${env:KARGO_CACHE_TOKEN}"
remote-push = false

[toolchain]
kotlin-mirror = "https://mirror.example.com/kotlin/releases"
auto-download = true
jdk = "/usr/lib/jvm/java-25-openjdk"

[lint]
default-rules = ["naming", "style"]

[format]
style = "official"

[build]

KeyTypeDefaultDescription
jobsintegerCPU count⚪ Parallel compilation jobs. Parsed and exported as KARGO_JOBS; nothing acts on it yet.
default-targetstringnoneTarget used when a project declares several and you pass no --target.
compiler-backend"cli" | "build-tools""build-tools"How the compiler is invoked. build-tools compiles incrementally; cli spawns kotlinc.
daemonbooltrueReuse a long-lived compiler process between builds.

jobs has no effect today, and setting it will not change a build. Two separate reasons, both worth knowing:

  • There is one compilation unit per build — every main source set is flattened into it — so there is no second compile for a job limit to schedule. See the unit graph.
  • Within that one unit, the only parallelism the Kotlin compiler offers is -Xbackend-threads, and Kargo does not pass it. Its code-generation workers append to unsynchronised lists in every version Kargo supports, so a build that uses it can fail with an internal compiler exception instead of compiling — rarely, and never twice in the same place. You can still pass it yourself through [profile] compiler-args, with that risk.

jobs does not bound downloads either. Those are capped separately at 8 concurrent requests, which is about being a good citizen towards a repository rather than about this machine's cores, so the two are deliberately not the same number.

The default, build-tools, compiles through the Kotlin Build Tools API, so a one-file change recompiles one file rather than the whole source set. It needs Kotlin 2.4 or later and a JVM or Android target, and downloads about 60MB of its own jars once per Kotlin version; a build it cannot serve compiles with kotlinc instead and never fails for the backend's sake.

compiler-backend = "cli" pins the old behaviour, and KARGO_COMPILER_BACKEND=cli (or =build-tools) chooses for a single build. See Incremental Compilation.

[repositories]

A map of name to URL, merged with each project's [repositories]. For repositories every project on this machine should see — an internal mirror, for instance.

[repositories]
internal = "https://nexus.example.com/repository/maven-public"

Credentials do not belong here. Use [credentials].

[credentials]

Named credential sets that a project references by name, so a shared manifest never needs to know how your machine stores secrets.

[credentials.my-nexus]
username = "deploy"
password = "literal-but-please-do-not"

[credentials.ci-registry]
username = "ci"
token-cmd = "secret-tool lookup service registry"
KeyTypeDescription
usernamestringBasic auth user.
passwordstringBasic auth password or token.
token-cmdstringCommand whose stdout is the credential.
# in a project's Kargo.toml
[repositories]
internal = { url = "https://nexus.example.com/maven", auth = "my-nexus" }

Prefer token-cmd. It keeps the secret in your password manager rather than in a plaintext file, and it works with anything that has a CLI — 1Password, pass, secret-tool, Vault.

[cache]

KeyTypeDefaultDescription
dirstring~/.kargo/build-cacheLocal build cache location, which KARGO_HOME moves along with everything else Kargo keeps globally.
max-sizestring10GBLRU eviction threshold. "500MB", "10GB". A value that is not a size is reported and ignored, leaving the default.
writebooltrueWhether a build stores its output here. Reading is unaffected: false still restores from entries that are already there.
remotestringnone⚪ Remote cache base URL.
remote-authstringnone⚪ Bearer token for the remote cache.
remote-pushboolfalse⚪ Whether this machine uploads.

dir is the build cache — your compiled output. Downloaded Maven artifacts are a separate cache with a separate lifetime, and it is not configurable here: it follows KARGO_HOME (see Paths).

Keep remote-push = false on developer machines. A cache any client can write to lets whoever can push an entry decide what your next build compiles to.

See The Build Cache.

[toolchain]

KeyTypeDefaultDescription
kotlin-mirrorstringJetBrains releasesAlternative download source.
auto-downloadbooltrueFetch missing toolchains automatically.
jdkstringdiscoveredA major version, or an absolute path.

auto-download = false is the air-gapped setting: builds then fail naming the missing version instead of attempting a download.

See Toolchains.

[lint] and [format]

⚪ Defaults for projects that declare none. Awaiting the linter.

[lint]
default-rules = ["naming", "style"]

[format]
style = "official"

Precedence

For any setting, later wins:

  1. ~/.kargo/config.toml
  2. Kargo.toml
  3. .kargo.env (for ${env:…} values)
  4. The process environment
  5. Command-line flags

So kargo build --offline beats any configured value, and a project that pins [toolchain] jdk beats your machine's default.

Inspecting

kargo self info     # paths, versions, sizes
kargo env           # resolved environment, secrets masked

Paths

PathContents
~/.kargo/config.tomlThis file
~/.kargo/toolchains/Kotlin compilers, managed JDKs, Android SDK
~/.kargo/cache/Maven artifacts, in Maven layout
~/.kargo/build-cache/Compiled output, content-addressed

~ is expanded in dir values.

Next

Targets

Status: 🟢 JVM. 🟡 Android, JavaScript, and Native have compiler backends but are not reachable from a multi-target build yet. ⚪ WebAssembly. See Implementation Status.

A target is a platform you compile for. Declare them in [targets]; every name below is accepted in kebab-case or camelCase (ios-arm64 and iosArm64 are the same target).

Every target

NamePlatformStatus
jvmKotlin/JVM🟢
androidKotlin/JVM for Android🟡
jsKotlin/JS🟡
wasm-jsKotlin/Wasm, browser⚪
wasm-wasiKotlin/Wasm, WASI⚪
ios-arm64iOS device🟡
ios-simulator-arm64iOS simulator, Apple silicon🟡
ios-x64iOS simulator, Intel🟡
macos-arm64macOS, Apple silicon🟡
macos-x64macOS, Intel🟡
linux-x64Linux, x86_64🟡
linux-arm64Linux, ARM64🟡
mingw-x64Windows, x86_64🟡
tvos-arm64tvOS device🟡
tvos-simulator-arm64tvOS simulator🟡
watchos-arm64watchOS device🟡
watchos-simulator-arm64watchOS simulator🟡
android-native-arm64Android NDK, ARM64🟡
android-native-x64Android NDK, x86_64🟡

jvm

[targets.jvm]
java-target = "25"
OptionDefaultDescription
java-target25Bytecode level. "17", "21", "25".

Output: a JAR in build/jvm/<profile>/output/. Source sets: src/main/kotlin for single-target projects, src/jvmMain/kotlin for multiplatform ones.

java-target is independent of the JDK you compile with — build on JDK 25 and emit Java 17 bytecode if that is what you deploy onto.

android

[targets.android]
min-sdk = 24
target-sdk = 36
compile-sdk = 36
java-target = "17"
OptionDefaultDescription
min-sdk24Minimum supported API level.
target-sdk36API level the app is tested against.
compile-sdk36API level compiled against.
java-target25Bytecode level.

min-sdk <= target-sdk is validated. Kargo locates the Android SDK via [toolchain], ANDROID_SDK in .kargo.env, ANDROID_HOME, or ANDROID_SDK_ROOT, and installs the required platform if missing.

android.* resolves against the compile-sdk platform. If it is not installed, Kargo says so and names the kargo toolchain install --android that fixes it.

.aar dependencies work like jars. AndroidX is published only to Google's Maven, so declare it:

[repositories]
google = "https://maven.google.com"

Status: 🟡 Compiles Kotlin against the Android SDK and .aar dependencies. Resource compilation, manifest merging, and APK or AAB packaging are planned.

javascript

[targets.js]
module-kind = "es"
OptionValuesDefaultDescription
module-kindes, commonjsesModule format emitted.

Use es for bundlers and modern browsers, commonjs for older Node tooling. Output: .js plus .d.ts declarations. Node.js is needed to run JS tests.

native

The Kotlin/Native family: ios-*, macos-*, linux-*, mingw-x64, tvos-*, watchos-*, android-native-*.

[targets]
ios-arm64 = {}
ios-simulator-arm64 = {}
macos-arm64 = {}
linux-x64 = {}

No per-target options besides cinterop. Output is a .framework for Apple targets, an executable or shared library elsewhere.

Host requirements. Kotlin/Native does not cross-compile between operating systems:

Target familyRequired host
ios-*, macos-*, tvos-*, watchos-*macOS with Xcode
linux-*Linux
mingw-x64Windows
android-native-*Linux or macOS, with the NDK

This is a Kotlin/Native constraint, not a Kargo one. Plan CI matrices around it — see Continuous Integration.

cinterop

Status: ⚪ Planned.

[target.ios-arm64.cinterop.mylib]
def-file = "src/nativeInterop/cinterop/mylib.def"
headers = ["include/mylib.h"]
compiler-opts = ["-Iinclude"]
linker-opts = ["-L/usr/local/lib", "-lmylib"]
KeyTypeDescription
def-filestringThe .def describing the library. Required.
headerslistHeaders to process.
compiler-optslistFlags for the C compiler.
linker-optslistFlags for the linker.

webassembly

Status: ⚪ Planned.

[targets]
wasm-js = {}
wasm-wasi = {}

wasm-js targets browsers with JavaScript interop; wasm-wasi targets WASI runtimes. Output is a .wasm module plus glue code for wasm-js.

Choosing a target name

For iOS, declare both ios-arm64 (device) and ios-simulator-arm64 (simulator) — you need both to develop and ship, and shared code goes in src/iosMain via the source-set hierarchy.

Add ios-x64 only if you still support Intel Macs for simulator builds.

Source-set mapping

TargetTarget-specific source setShared with
jvmsrc/jvmMain/kotlincommonMain
androidsrc/androidMain/kotlincommonMain
jssrc/jsMain/kotlinjsAndWasmMain, commonMain
ios-arm64src/iosArm64Main/kotliniosMain, appleMain, nativeMain, commonMain
linux-x64src/linuxX64Main/kotlinnativeMain, commonMain

Full rules in Source Sets.

Next

Source Sets

Status: 🟢 Conventional directories are discovered, the intermediate source sets are inferred from the target list, and [source-sets.*] overrides what either of those would decide. See Implementation Status.

A source set is a directory of code compiled into one or more targets. Kargo discovers them by name; there is nothing to declare.

Naming

src/<sourceSetName>/kotlin        # Kotlin sources
src/<sourceSetName>/resources     # bundled resources
src/<sourceSetName>/composeResources   # Compose assets

The name is the target in camelCase plus Main or Test:

Source setCompiled into
commonMainevery target
commonTestevery target's tests
jvmMainjvm
androidMainandroid
jsMainjs
iosArm64Mainios-arm64
iosSimulatorArm64Mainios-simulator-arm64
linuxX64Mainlinux-x64

Single-target JVM projects use the Maven layout instead — src/main/kotlin and src/test/kotlin — which is what kargo new generates for the jvm and lib templates.

The hierarchy

Writing identical iOS code in iosArm64Main and iosSimulatorArm64Main is the problem intermediate source sets solve. Kargo infers them from your target list:

graph TD
    COMMON["commonMain"] --> NATIVE["nativeMain"]
    COMMON --> JVM["jvmMain"]
    COMMON --> ANDROID["androidMain"]
    COMMON --> JSWASM["jsAndWasmMain"]
    NATIVE --> APPLE["appleMain"]
    NATIVE --> LINUX["linuxMain"]
    NATIVE --> MINGW["mingwMain"]
    NATIVE --> ANDROIDNATIVE["androidNativeMain"]
    APPLE --> IOS["iosMain"]
    APPLE --> MACOS["macosMain"]
    APPLE --> TVOS["tvosMain"]
    APPLE --> WATCHOS["watchosMain"]
    IOS --> IOSARM["iosArm64Main"]
    IOS --> IOSSIM["iosSimulatorArm64Main"]
    LINUX --> LINUXX64["linuxX64Main"]
    JSWASM --> JS["jsMain"]
    JSWASM --> WASM["wasmJsMain"]
    JSWASM --> WASI["wasmWasiMain"]
Intermediate setCovers
nativeMainevery Kotlin/Native target
appleMainiOS, macOS, tvOS, watchOS
iosMainevery iOS target
macosMainmacOS targets
tvosMaintvOS targets
watchosMainwatchOS targets
linuxMainLinux targets
mingwMainWindows targets
androidNativeMainAndroid NDK targets
jsAndWasmMainjs, wasm-js, wasm-wasi

Only the directories you create exist. A project with one iosMain and no iosArm64Main is normal and correct, and so is a gap in the middle: with appleMain and iosArm64Main but no iosMain, the leaf depends on appleMain directly.

Each *Main set has a matching *Test set with the same relationships, and also sees its own *Main.

What goes where

CodeSource set
Business logic, models, use casescommonMain
An expect declarationcommonMain
JVM file I/O, JDBC, servletsjvmMain
Context, Activity, Android APIsandroidMain
UIKit, Foundation, anything from platform.*iosMain
Browser DOM accessjsMain
POSIX calls shared by Linux and ApplenativeMain

The rule of thumb: put code as high in the hierarchy as it compiles. Code in commonMain is tested once and works everywhere; code pushed down into a platform set has to be written and tested per platform.

Dependencies between source sets

A source set sees everything its ancestors declare. So iosArm64Main can use anything from iosMain, appleMain, nativeMain, and commonMain.

Target-specific dependencies follow the same path:

[dependencies]
ktor-client-core = "io.ktor:ktor-client-core:2.3.0"       # commonMain and below

[target.ios.dependencies]
ktor-client-darwin = "io.ktor:ktor-client-darwin:2.3.0"    # iosMain and below

Resources

src/commonMain/resources/            # every target
src/jvmMain/resources/               # jvm only
src/commonMain/composeResources/     # Compose: typed Res accessors

Resources merge along the hierarchy, with the more specific set winning on a name collision — how a platform substitutes one asset without duplicating the rest.

Flavor source sets

Status: 🟡 Specified; not applied to builds yet.

Flavors add a dimension, composing most-specific-last:

src/
├── commonMain/kotlin/       # all targets, all flavors
├── jvmMain/kotlin/          # jvm, all flavors
├── freeMain/kotlin/         # free, all targets
├── freeJvmMain/kotlin/      # free, jvm only
└── paidIosMain/kotlin/      # paid, ios only

Explicit overrides

For layouts that cannot move — a migrating project, generated code in an unusual location:

[source-sets.jvmMain]
kotlin = ["legacy/src/java", "build/generated/kotlin"]
resources = ["legacy/src/resources"]
depends-on = ["commonMain"]
KeyTypeDescription
kotlinlistSource roots, relative to the project root, replacing the convention.
resourceslistResource roots, replacing the convention.
depends-onlistParent source sets, replacing the inferred parent.
targetslistTargets this set compiles into.

A key you leave out keeps the convention, so moving the sources says nothing about the resources; an empty list is the same as leaving the key out, since a source set with no sources is one you simply do not declare. The name decides which compilation the set joins: main and test in the Maven layout, a name ending in Main or Test in this one.

Declaring a set is what brings it into existence. src/jvmMain need not exist for [source-sets.jvmMain] to be compiled, which is the point when the code is somewhere else entirely.

Parents you wire yourself

depends-on replaces the inferred parent rather than adding to it, so a set that names one is out of the hierarchy's hands:

[source-sets.iosArm64Main]
depends-on = ["appleMain"]

With that, iosArm64Main hangs off appleMain even when iosMain exists, and iosMain is no longer compiled into ios-arm64 — nothing in that target's chain reaches it any more.

Groupings the hierarchy does not have

The standard hierarchy has no set shared by the JVM and Android targets and only those two. targets declares one:

[source-sets.jvmAndAndroidMain]
depends-on = ["commonMain"]
targets = ["jvm", "android"]

Each target named gains the set, and that target's own set hangs off it: jvmMain sat under commonMain and now sits under jvmAndAndroidMain. A target with no set of its own — a project whose JVM and Android code is entirely shared creates no jvmMain — compiles the grouping directly.

Only the target's own set moves. An intermediate such as iosMain is shared with every iOS target beneath it, so a grouping naming ios-arm64 alone is compiled into ios-arm64 without ios-simulator-arm64 inheriting it. To put a set above a shared intermediate, name every target under it.

src/jvmAndAndroidTest, if it exists, is grouped the same way without declaring it twice, exactly as the inferred hierarchy mirrors itself. A set the manifest wires with its own depends-on keeps those parents, which is how a grouping is overruled for one target.

A name Kargo does not recognize as a target, and a depends-on cycle, are both rejected when the manifest loads.

Troubleshooting

My file is not being compiled. Check the directory name against the table above. src/ios/kotlin is not a source set; src/iosMain/kotlin is.

Why does commonMain not see a dependency? A dependency declared under [target.jvm.dependencies] is only visible from jvmMain down. Common code needs it in [dependencies], which means it must be a multiplatform artifact.

Next

Environment Variables

Status: 🟢 The variables below are set during builds. 🟡 KARGO_JOBS is set, but describes no limit the build itself observes. ⚪ Variables marked planned depend on features that are not built yet (workspaces, flavors reaching the build path).

Kargo exports a standard set of variables to compiler invocations, hooks, and plugins, so a script never has to be told where it is or what it is building.

Package

VariableExampleStatus
KARGO_MANIFEST_DIR/home/jane/my-app🟢
KARGO_PKG_NAMEmy-app🟢
KARGO_PKG_VERSION1.2.0🟢
KARGO_PKG_VERSION_MAJOR1🟢
KARGO_PKG_VERSION_MINOR2🟢
KARGO_PKG_VERSION_PATCH0🟢
KARGO_PKG_AUTHORSJane Doe <jane@example.com>🟢
KARGO_PKG_DESCRIPTIONOrder processing service🟢
KARGO_PKG_REPOSITORYhttps://github.com/example/my-app🟢

The split version components save a script from parsing semver to stamp a build number or compute a Docker tag.

Build context

VariableExampleStatus
KARGO_BUILD_DIR/home/jane/my-app/build🟢
KARGO_TARGETjvm🟢
KARGO_PROFILErelease🟢
KARGO_JOBS8🟡
KARGO_KOTLIN_VERSION2.4.21🟢
KARGO_TOOLCHAIN_DIR~/.kargo/toolchains/kotlin-2.4.21🟢
KARGO_CACHE_DIR~/.kargo/cache⚪

KARGO_TOOLCHAIN_DIR is how a hook reaches kotlinc or kotlin-daemon-client without guessing a path or depending on a global install.

KARGO_JOBS is [build] jobs passed through verbatim, and that is all it is: nothing in Kargo runs concurrently because of it, so it is a number a hook can read rather than a budget a hook is sharing. Sizing your own parallelism to it is choosing that number yourself — which is reasonable, since it defaults to the core count, but it is not coordination. It does not bound downloads either; those have a limit of their own.

Flavors and variants

Set when flavors are configured. ⚪ Flavors do not reach the build path yet, so these are not populated today.

VariableExample
KARGO_VARIANTpaid-production-release
KARGO_FLAVOR_<DIMENSION>KARGO_FLAVOR_TIER=paid
KARGO_BUILD_CONFIG_<KEY>KARGO_BUILD_CONFIG_API_URL=https://api.example.com

Dimension names are upper-cased: dimension tier becomes KARGO_FLAVOR_TIER. Every build-config entry is exported with a KARGO_BUILD_CONFIG_ prefix, so a deploy script can read the same API URL the application was compiled with.

Workspaces

Status: ⚪ Planned — depends on workspace orchestration.

VariableExample
KARGO_WORKSPACE_DIR/home/jane/my-workspace
KARGO_WORKSPACE_MEMBERshared

Variables from .kargo.env

Every entry in .kargo.env is exported to builds, hooks, and plugins, and is available for ${env:…} interpolation in the manifest.

# .kargo.env
DEPLOY_TARGET=staging
[hooks]
post-build = ["./scripts/deploy.sh"]
#!/usr/bin/env bash
echo "Deploying $KARGO_PKG_NAME $KARGO_PKG_VERSION to $DEPLOY_TARGET"
echo "Artifacts in $KARGO_BUILD_DIR/$KARGO_TARGET/$KARGO_PROFILE/output"

Variables Kargo reads

Alongside what it exports, Kargo honors these from your environment:

VariableUsed for
JAVA_HOMEJDK discovery
ANDROID_HOME, ANDROID_SDK_ROOTAndroid SDK discovery
KARGO_HOMEOverrides ~/.kargo — useful in CI where only project paths are cached
NO_COLORDisables colored output
RUST_LOGVerbosity of internal tracing output, for debugging Kargo itself
export KARGO_HOME="$CI_PROJECT_DIR/.kargo-home"

Terminal output

Read by Kargo, not set by it. An explicit --color overrides them.

VariableEffect
NO_COLORSet to anything to disable colour.
CLICOLOR=0Disable colour.
CLICOLOR_FORCE=1Colour even when the output is piped.

In practice

# A hook that stamps the build
cat > build/generated/version.txt <<EOT
${KARGO_PKG_NAME} ${KARGO_PKG_VERSION}
built for ${KARGO_TARGET} (${KARGO_PROFILE})
with Kotlin ${KARGO_KOTLIN_VERSION}
EOT

Next

Lint Rules

Status: ⚪ Planned — [lint] parses, but no rules run yet. This page specifies the intended rule set. See Implementation Status.

Rules are grouped into categories. Enable categories, not individual rules, in the common case:

[lint]
rules = ["naming", "style", "complexity", "performance", "correctness"]
severity = "warning"
SeverityEffect
errorReported, command exits non-zero
warningReported, command succeeds
infoReported quietly

naming

Kotlin naming conventions.

RuleFlags
class-namingClasses and interfaces not in PascalCase
function-namingFunctions not in camelCase (backtick test names exempt)
property-namingProperties not in camelCase
constant-namingconst val and top-level val not in SCREAMING_SNAKE_CASE
package-namingPackages not lowercase and dot-separated
type-parameter-namingType parameters not single uppercase letters or PascalCase
boolean-prefixBoolean properties without an is, has, or can prefix

Mechanical and uncontroversial. A good first category to turn on at error.

style

Formatting-adjacent issues the formatter does not rewrite on its own.

RuleFlags
import-orderingImports not alphabetized
unused-importImports nothing in the file uses
wildcard-importimport foo.*
redundant-qualifierFully qualified names that are already imported
trailing-commaMissing trailing commas in multi-line argument lists
brace-styleBraces not in Kotlin's standard position
max-line-lengthLines over [format] max-line-length
semicolonsUnnecessary statement terminators
explicit-unit-returnA redundant : Unit

Most are auto-fixable with kargo lint --fix.

complexity

RuleDefault threshold
function-length60 lines
cyclomatic-complexity15 branches
nesting-depth4 levels
parameter-count7 parameters
class-length600 lines
nested-block-depth4 levels
cognitive-complexity20

Thresholds are configurable:

[lint.complexity]
function-length = 40
cyclomatic-complexity = 10

On an existing codebase this category produces a long list on day one. Introduce it at info, work the list down, then promote it.

performance

RuleFlags
unnecessary-allocationA temporary collection where a sequence would do
inefficient-collection-callfilter {}.first() instead of first {}
string-concat-in-loopBuilding a string with += in a loop
boxed-primitiveA boxed type where the primitive would serve
deprecated-apiCalls to APIs marked @Deprecated
redundant-suspendsuspend on a function that never suspends
eager-collection-opsA chain of eager operations that should be an asSequence()

correctness

The category most likely to find real bugs.

RuleFlags
unreachable-codeCode after an unconditional return or throw
unused-variableA local that is assigned and never read
unused-parameterA parameter the function body ignores
suspicious-equals== between unrelated types
platform-type-npeAn unchecked platform type from Java interop
empty-catchA catch block that swallows silently
unsafe-castas where as? would be safe
implicit-nothingAn inferred Nothing type that is probably unintended
missing-actualAn expect with no actual for a configured target
coroutine-scope-leakA CoroutineScope created and never cancelled

Configuring individual rules

[lint]
rules = ["naming", "style", "correctness"]
severity = "warning"

[lint.rules]
wildcard-import = "error"       # stricter than the category default
max-line-length = "off"         # the formatter already handles it
empty-catch = "error"

Per-rule values override the category: off, info, warning, error.

Suppressing in code

@Suppress("function-length")
fun theBigOne() { … }
// kargo-lint-disable-next-line unsafe-cast
val x = y as String
// kargo-lint-disable-file max-line-length

A suppression should come with a reason in a comment. An unexplained suppression is indistinguishable from an abandoned one.

Generated code

[lint]
exclude = ["**/generated/**", "**/BuildConfig.kt", "build/**"]

Generated files are excluded by default — build/, KSP and KAPT output, and BuildConfig. Linting code you did not write produces noise you cannot fix.

Output formats

kargo lint --format text     # colored terminal output, the default
kargo lint --format json     # machine-readable
kargo lint --format sarif    # GitHub code scanning and similar

Custom rules

Status: ⚪ Planned.

[lint.custom]
no-println = "lint-rules/no-println.rhai"

For conventions a general-purpose linter cannot know: an internal API that must not be called from a particular module, or a logging facade that must be used instead of println. See Plugins and Hooks.

Next

Glossary

Terms as Kargo uses them. Several have different meanings in Gradle or Maven; those differences are called out.

Artifact

A file published to a Maven repository — a JAR, a POM, a klib. Identified by a coordinate.

BOM

Bill of materials. A POM that declares versions for a family of artifacts without pulling any of them in. Imported with scope = "import". See Dependencies.

BuildConfig

A generated Kotlin object holding compile-time constants from [build-config], flavors, and the active profile. See Flavors and Variants.

Build cache

A content-addressed store of compiled output, keyed by a hash of every compilation input. Distinct from the artifact cache, which holds downloaded dependencies. See The Build Cache.

Compilation unit

One compiler invocation: a set of sources, a classpath, and compiler arguments producing one output. The granularity at which Kargo fingerprints and caches.

Coordinate

group:artifact:version, for example org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0. The globally unique address of an artifact.

Dimension

An independent axis of flavor variation — tier, environment, brand. Declared in [flavors] dimensions.

expect / actual

Kotlin's mechanism for platform-specific implementations: declare an expect in common code and an actual per platform. See Kotlin Multiplatform.

Fingerprint

A hash of a compilation unit's inputs. Equal fingerprints mean the previous output is still valid. See Incremental Compilation.

Flavor

A named value within a dimension — free or paid in tier. Android calls this a product flavor; Kargo applies the concept to every target.

Intermediate source set

A source set shared by a family of targets, such as iosMain or appleMain, inferred from your target list. See Source Sets.

KAPT

Kotlin Annotation Processing Tool. The older annotation-processing mechanism, which generates Java stubs first. Slower than KSP; use it only for processors that have not migrated.

klib

The Kotlin/Native library format — the Native equivalent of a JAR.

KMP

Kotlin Multiplatform. Compiling one codebase for several platforms.

KSP

Kotlin Symbol Processing. The modern annotation-processing API, operating on Kotlin's own symbol model rather than Java stubs. Declared in [ksp].

Lockfile

Kargo.lock. The exact resolved graph, with checksums. See Lockfile Format.

Manifest

Kargo.toml. The declarative definition of a project. See Manifest Format.

Nearest wins

The conflict-resolution rule: when two paths need different versions of the same artifact, the one declared closest to your project wins. This is Maven's rule. Gradle picks the highest version instead — the most common source of surprise when migrating. See Dependency Resolution.

Profile

A named set of compiler settings — dev, release, or a custom one. Gradle calls the analogous Android concept a build type. See Build Profiles.

Resolution

Turning declared dependencies into an exact set of artifact versions, following transitive dependencies and mediating conflicts.

Scope

Where a dependency applies: compile, runtime, provided, test, import. Gradle's configurations (implementation, api, compileOnly) map onto these — see Coming from Gradle.

Source set

A directory of sources compiled into one or more targets, identified by directory name — commonMain, jvmMain, iosMain. See Source Sets.

Target

A platform compiled for — jvm, android, ios-arm64, js. Declared in [targets]. See Targets.

Toolchain

A downloaded Kotlin compiler installation, or a managed JDK or Android SDK, stored under ~/.kargo/toolchains/. See Toolchains.

Transitive dependency

A dependency of a dependency. Resolved and locked like any other, and the usual subject of kargo tree --why.

Unit graph

The directed graph of compilation units for a build, determining what can compile in parallel and what must wait.

Variant

One flavor per dimension, plus a profile — free-staging-release. The thing that actually gets built.

Workspace

Several Kargo packages built together under one root manifest, sharing a lockfile. Gradle calls this a multi-project build. See Workspaces.

Build Lifecycle

Status: 🟢 Phases 1 and 3 through 8 run today. 🟡 Variant resolution and ⚪ hook dispatch are not wired in. See Implementation Status.

What happens between kargo build and a JAR. Useful when a build surprises you; not required reading.

graph TD
    LOAD["1 · Load manifest"] --> VARIANTS["2 · Resolve variants"]
    VARIANTS --> RESOLVE["3 · Resolve dependencies"]
    RESOLVE --> FETCH["4 · Fetch artifacts"]
    FETCH --> PLAN["5 · Plan the unit graph"]
    PLAN --> CODEGEN["6 · Generate code"]
    CODEGEN --> COMPILE["7 · Compile"]
    COMPILE --> PACKAGE["8 · Package"]

The order is fixed. Kargo has no user-defined task graph, which is the trade it makes: less expressive than Gradle, and far easier to reason about when something goes wrong.

1. Load the manifest

Read Kargo.toml, interpolate ${env:…} from .kargo.env and the environment, parse, and validate. Validation happens here so a typo in a version string fails in milliseconds rather than after a download.

2. Resolve variants

🟡 Not applied yet.

Expand [flavors] × profiles into variants, subtract exclusions, and select which to build from --variant, --flavor, or the configured default.

3. Resolve dependencies

With a current lockfile, this is a read. Otherwise Kargo fetches POMs, walks the transitive graph, mediates conflicts nearest-wins, and writes Kargo.lock.

4. Fetch artifacts

Download whatever the lockfile names and is not already in ~/.kargo/cache/, verifying checksums. --offline skips the network and fails if anything is missing.

5. Plan the unit graph

⚪ One unit, not a graph, today: every main source set is flattened into a single main unit, and kargo test compiles a test unit after it. The graph is the model being built towards, not what the build plans now.

Discover source sets from the project layout and build a graph of compilation units. Each unit is one compiler invocation; edges are "must compile before".

Each unit is then fingerprinted — source hashes, dependency set, compiler arguments, compiler version, target — and units whose fingerprint is unchanged are dropped from the plan. See Incremental Compilation.

6. Generate code

BuildConfig from [build-config] and flavors, then KSP and KAPT processors. Generated sources are added to their units and included in the fingerprint, so generated code participates in incremental builds correctly.

7. Compile

Surviving units are dispatched to the compiler backend for their target — kotlinc, kotlinc-js, or kotlinc-native.

⚪ Compilation is single-threaded. There is one unit per build, so there is nothing to overlap, and [build] jobs bounds nothing today — see jobs.

A fingerprint miss checks the build cache before actually compiling; a hit restores the output instead.

8. Package

Assemble the output for the target: a JAR for the JVM, a klib or framework for Native, a bundle for JS. kargo package does more elaborate work on top of this.

Resources are staged beside the classes here, and this phase decides for itself whether to run: it has its own fingerprint over the resource files, so editing only a resource rebuilds the JAR without recompiling anything, and editing only Kotlin does not re-read the resources.

Where hooks fire

⚪ Planned.

Every phase boundary is a hook point:

BoundaryHooks
Around phase 3pre-resolve, post-resolve
Around phase 4pre-fetch, post-fetch
Around phases 5–8pre-build, post-build
Around phase 7pre-compile, post-compile
Per variantpre-variant-build, post-variant-build

A non-zero exit from a pre-* hook stops the build.

What the other commands do

CommandPhases
kargo check1–7, no artifact assembly
kargo test1–8, then compile and run test units
kargo fetch1, 3, 4
kargo lock1, 3
kargo tree1, 3, then print
kargo run1–8, then execute

This is why kargo check is the fast feedback loop: it does everything that finds errors and nothing that assembles an artifact. It still runs phase 6 — skipping it would have the type-check miss the generated sources and report unresolved references to code the build compiles — and the classes phase 7 produces go to a temporary directory it discards.

Next

Dependency Resolution

Status: 🟢 Implemented — POM inheritance, BOM imports, nearest-wins mediation, scopes, exclusions, and SNAPSHOT handling all work.

Resolution turns what you declared into exactly which artifact versions get compiled against. Kargo follows Maven's semantics, because that is what the artifacts in Maven Central were published under.

The algorithm

  1. Start from your direct dependencies at depth 0.
  2. Fetch each artifact's POM and read its dependencies.
  3. Walk breadth-first, recording the depth at which each artifact is first seen.
  4. When the same artifact appears at two versions, nearest wins — the shallower depth. Equal depth is broken by declaration order.
  5. Apply exclusions, drop optional dependencies of transitive deps, and filter by scope.
  6. Write the result to Kargo.lock with a checksum per artifact.

Breadth-first is what makes "nearest" meaningful: a direct dependency is always depth 0, so declaring a version directly overrides anything transitive.

Nearest wins, and why it may surprise you

my-app
├── library-a v1.0 → kotlin-stdlib v1.9.0     (depth 1)
└── library-b v2.0
    └── library-c v1.5 → kotlin-stdlib v1.9.21  (depth 2)

kotlin-stdlib 1.9.0 wins at depth 1 — even though 1.9.21 is newer.

Gradle would pick 1.9.21, because it resolves to the highest version. This is the single most common surprise when moving a build to Kargo, and it is a deliberate choice: nearest-wins makes the outcome depend on your declarations rather than on what any transitive dependency happens to request, which makes it predictable and stable under dependency updates.

To force a version, declare it:

[dependencies]
kotlin-stdlib = "org.jetbrains.kotlin:kotlin-stdlib:1.9.21"

Depth 0 beats everything.

kargo tree --conflicts    # every mediation decision
kargo tree --why some-lib # the path that pulled it in

Scopes

ScopeCompileRuntimePropagates to consumers
compileyesyesyes
runtimenoyesyes, as runtime
providedyesnono
testtests onlytests onlyno
importn/an/aversion constraints only

A transitive compile dependency stays compile. A transitive dependency of a runtime dependency becomes runtime. provided and test do not propagate at all — which is why you sometimes have to declare something your dependency also uses.

Exclusions

[dependencies.some-lib]
group = "com.example"
artifact = "some-lib"
version = "1.0.0"

[[dependencies.some-lib.exclusions]]
group = "org.slf4j"
artifact = "slf4j-log4j12"

[[dependencies.some-lib.exclusions]]
group = "commons-logging"      # the whole group

Exclusions apply to that dependency's subtree only. If another path also pulls the excluded artifact in, it still arrives — exclusion is not a global ban.

BOM imports

[dependencies.ktor-bom]
group = "io.ktor"
artifact = "ktor-bom"
version = "2.3.0"
scope = "import"

An imported BOM contributes version constraints and no artifacts. Dependencies with an empty version take theirs from the BOM, including one imported by a POM further up the parent chain. If nothing supplies a version, resolution warns naming the artifact and the POM that declared it, and leaves it out of the graph.

POM features

Kargo implements the parts of the POM format that affect resolution:

FeatureBehavior
Parent inheritanceWalks the parent chain, merging properties, licenses and dependency management
Property interpolation${project.version} and friends
dependencyManagementVersion constraints without dependencies
RelocationFollows <relocation> to the artifact's new coordinate
Packaging typesjar, pom, aar, klib
optionalNot propagated transitively
ProfilesActivation by property or JDK is not supported

That last row is deliberate: POM profile activation makes resolution depend on the resolving environment, which breaks reproducibility.

SNAPSHOT versions

A -SNAPSHOT version resolves through the repository's version-level maven-metadata.xml to a specific timestamped build, and the lockfile records that exact build — so a snapshot dependency is reproducible until you deliberately kargo update.

Snapshots and reproducibility remain in tension. Prefer released versions for anything you ship.

Multiplatform resolution

A multiplatform artifact publishes a root module plus one per platform. Kargo reads Gradle Module Metadata to select the right platform artifact for each target, and Kargo.lock records which targets each package belongs to.

Performance

MechanismEffect
LockfileA current lockfile skips resolution entirely
POM cachePOMs are cached in ~/.kargo/cache alongside artifacts
Parallel metadata fetchIndependent POMs download concurrently
Early terminationA subtree already resolved at a shallower depth is not rewalked

The practical consequence: commit your lockfile. It is the difference between reading a file and walking a dependency graph over the network.

Next

Maven Compatibility

Status: 🟢 Reading from Maven repositories is fully implemented. 🟡 Gradle Module Metadata is parsed but not yet used for variant selection. ⚪ Publishing is planned.

Kargo is a Maven client. It does not define a new package format, run a registry, or ask libraries to republish. Anything you can consume from Gradle or Maven, you can consume from Kargo.

Repository layout

Standard Maven layout, with the group id's dots becoming path separators:

https://repo.maven.apache.org/maven2/
  org/jetbrains/kotlinx/kotlinx-coroutines-core/1.8.0/
    kotlinx-coroutines-core-1.8.0.pom
    kotlinx-coroutines-core-1.8.0.jar
    kotlinx-coroutines-core-1.8.0.module          # Gradle Module Metadata
    kotlinx-coroutines-core-1.8.0-sources.jar
    *.sha1, *.sha256, *.md5

So any static file server with this layout is a usable repository — including an S3 bucket or a directory served over HTTP.

Metadata

FileRead for
<artifact>-<version>.pomDependencies, properties, parent, packaging
maven-metadata.xml (artifact level)Available versions, latest, release
maven-metadata.xml (version level)Timestamped SNAPSHOT builds
<artifact>-<version>.moduleGradle Module Metadata, for multiplatform variants

Gradle Module Metadata

A .module file is a JSON document describing an artifact's variants — JVM runtime, JVM API, iOS arm64, and so on — with the attributes needed to pick one. This is how a single coordinate like io.ktor:ktor-client-core:2.3.0 serves every Kotlin platform.

Kargo parses these files where they exist.

Status: 🟡 Parsed, but variant selection does not yet use the attributes. Multiplatform artifacts resolve, with less precision than they eventually will.

Artifacts without a .module file resolve from the POM alone, which is all a JVM-only library needs.

Checksums

Every download is verified against the published sha256 when available, falling back to sha1. Cached artifacts are re-verified on read, not only on download, and Kargo.lock records the checksum independently — so a repository that serves different bytes for the same coordinate fails the build rather than silently changing what you compile.

kargo fetch --verify     # re-verify the whole cache against the lockfile

Authentication

[repositories]
internal = { url = "https://nexus.example.com/repository/maven-releases", username = "${env:NEXUS_USER}", password = "${env:NEXUS_PASS}" }
token-based = { url = "https://maven.pkg.github.com/acme/libs", username = "${env:GITHUB_ACTOR}", password = "${env:GITHUB_TOKEN}" }

HTTP Basic, which is what Nexus, Artifactory, GitHub Packages, and Maven Central's staging API all accept. Credentials come from .kargo.env or global config, never a committed manifest.

The local cache

~/.kargo/cache/ mirrors the Maven layout:

~/.kargo/cache/
  org/jetbrains/kotlinx/kotlinx-coroutines-core/1.8.0/
    kotlinx-coroutines-core-1.8.0.jar
    kotlinx-coroutines-core-1.8.0.pom

Mirroring the remote layout rather than inventing a flat store means the cache is inspectable with ls, and --offline is just "resolve against this directory".

kargo fetch              # populate it
kargo build --offline    # use only what is here
kargo self clean         # prune it

Repository order

Repositories are tried in declaration order, with Maven Central last. The first repository that has the artifact wins, and the lockfile records which one it was — so a later change in repository order cannot silently swap an artifact's source.

Publishing

Status: ⚪ Planned.

The upload side of the same protocol: JAR, POM, sources, KDoc, GPG signatures, and checksums, PUT to the repository. SNAPSHOT versions get timestamped; release versions are immutable. See Publishing.

What Kargo does not do

Not supportedWhy
POM profile activationMakes resolution depend on the resolving machine
Dynamic version rangesSame reason — versions are exact
LATEST and RELEASEDeprecated in Maven, non-reproducible
Maven pluginsA different execution model entirely
settings.xmlKargo has its own config

Each omission trades expressiveness for a build that produces the same output tomorrow as it does today.

A range naming exactly one version — [2.6.1] — is resolved, since it is an exact version. A wider range is not.

Next

Incremental Compilation

Status: 🟢 Skipping whole units, the local build cache, and recompiling only what changed inside a unit all work. ⚪ Nothing is compiled in parallel: every main source set is flattened into one unit, and that unit compiles on one thread.

Why a second kargo build finishes in milliseconds.

Fingerprints

Before compiling a unit, Kargo hashes everything that could change its output:

InputWhy it matters
Source file contentsThe obvious one
Resolved dependency setA new library version changes what compiles
Compiler argumentsIncluding profile compiler-args
Compiler versionTwo Kotlin versions produce different bytecode
TargetSame sources, different output
Generated inputsBuildConfig, KSP and KAPT output
The output a unit compiles againstThe tests compile against the main classes, so editing main recompiles them

Equal fingerprint, no compile. Different fingerprint, compile.

Fingerprints are stored in .kargo/fingerprints/, outside build/, so a partial clean does not destroy them. kargo clean removes both.

Note that contents are hashed, not timestamps. Touching a file without changing it does not trigger a rebuild, and git checkout moving a file back to a previous state restores a hit rather than a miss.

Resources have a fingerprint of their own, because they change a different output. Nothing under a resources directory reaches the compiler, so editing one rebuilds the jar and leaves the compile alone.

The unit graph

A build is a directed graph of units. Edges mean "must finish first" — a JVM unit waits for the commonMain unit it depends on.

graph LR
    COMMON["commonMain"] --> JVM["jvmMain"]
    COMMON --> IOS["iosMain"]
    COMMON --> JS["jsMain"]
    JVM --> JVMTEST["jvmTest"]
    COMMON --> COMMONTEST["commonTest"]

⚪ The graph is the model, not the implementation. Every main source set is flattened into one main unit, so there is nothing yet for a graph to order or for a scheduler to overlap.

Two consequences, once it is in place: units with no path between them compile in parallel, up to KARGO_JOBS; and a change to commonMain invalidates everything downstream, while a change to jvmMain invalidates only jvmMain and jvmTest.

That asymmetry is worth knowing when a build feels slower than it should. Code that changes often sits better in a platform source set than in commonMain.

Three levels of avoidance

In order of how often they save you time:

1. Fingerprint hit. Nothing to do. This is the no-op build.

2. Build cache hit. The fingerprint is new to this working tree, but the output is in the build cache from a previous build — another branch, a git bisect step, a pre-clean build. Restore instead of compile.

3. Compile. Actually invoke the compiler, then store the output in the cache keyed by the fingerprint.

Within a unit

Status: 🟢 On by default. A project it cannot serve compiles the way it always did.

Edit one file and Kargo recompiles that file and whatever referenced what changed in it — not the whole source set. On a 400-file project, a one-file edit recompiles one file.

This is the Kotlin compiler's own incremental compilation, which Kargo drives through the Kotlin Build Tools API. The kotlinc command-line compiler cannot do it at all, which is why Kargo only falls back to that.

What is left of the wall clock after this is compiler startup, and the daemon is what removes that.

It needs:

  • Kotlin 2.4 or later. Earlier versions compile the whole source set.
  • A JVM or Android target.
  • About 60MB, once per Kotlin version. The API ships as its own artifacts rather than inside the Kotlin distribution, so the first build on a new Kotlin version downloads them into the artifact cache. kargo fetch keeps them there.

Nothing about it can fail a build. Anything that stops it — an older Kotlin, jars that will not download, a JDK without javac — compiles the whole source set instead, which is what every build did before. kargo build -v says which happened.

To turn it off:

# ~/.kargo/config.toml
[build]
compiler-backend = "cli"
KARGO_COMPILER_BACKEND=cli kargo build   # for one build

Correctness over speed

The fingerprint deliberately includes inputs that rarely change, such as the compiler version and the full argument list. Hashing more than strictly necessary costs a few milliseconds and makes a stale hit impossible.

So reaching for kargo clean should never be the fix for a wrong build. If a clean build differs from an incremental one, that is a bug worth filing with both -v outputs.

When everything recompiles anyway

CauseFix
compiler-backend = "cli", or Kotlin older than 2.4Expected: the kotlinc launcher has no within-unit incremental compilation. See Within a unit
.kargo/ deleted between buildsInclude it in the CI cache — both fingerprints/ and incremental/
kargo clean, or build/ removed by handExpected: the next build has no output to be incremental against
The build cache restored the outputExpected once; the build after it is incremental again
A hook rewriting a source file every runMake the hook idempotent
Generated code containing a timestampRemove it — it changes the hash every build
kargo test after any edit to mainExpected: the test sources are compiled against main's output
kargo update ranExpected: the dependency set is an input
A profile's compiler-args changedExpected
The Kotlin version changedExpected
kargo build --timings
kargo build -v        # shows which units missed and why

Next

Contributing to Kargo

Kargo is pre-1.0 and there is a lot to build. This section is for people working on Kargo itself; if you are using Kargo, start at Getting Started.

Setting up

RequirementNotes
Rust 1.91 or newerThe floor is [workspace.package].rust-version in Cargo.toml. Install via rustup.
Git
A JDKOnly for end-to-end tests that actually compile Kotlin.
git clone https://github.com/dejanradmanovic/kargo.git
cd kargo
cargo build
cargo test --workspace
cargo run -- new /tmp/scratch-app     # exercise the CLI

The Rust floor moves when a dependency bump requires it. If cargo build complains about an unsupported feature, run rustup update stable before anything else.

Enable the git hooks

Once per clone:

git config core.hooksPath .githooks
HookRunsWarm-cache cost
commit-msgthe subject conventioninstant
pre-commitcargo fmt --check, cargo clippy -- -D warnings~10s
pre-pushthe above plus cargo test --workspace~25s

They run the same gates as CI, so failures surface before a pull request does.

  • Bypass once with --no-verify, or set KARGO_SKIP_HOOKS=1.
  • Formatting is checked, not applied — the hooks never rewrite your files. Run cargo fmt --all yourself.
  • The checks see the working tree, not the staged snapshot, so a failure can come from unstaged work in progress.
  • They call plain cargo, honoring rustup's toolchain selection. Set RUSTUP_TOOLCHAIN if this repo needs a non-default toolchain.

The CI gates

Every pull request must pass:

cargo check --workspace --all-targets
cargo test --workspace                              # on Linux, macOS, Windows
cargo fmt --all -- --check
cargo clippy --workspace --all-targets -- -D warnings

CI runs with RUSTFLAGS: -Dwarnings on dtolnay/rust-toolchain@stable. Clippy and fmt are hard gates — run both before pushing. Coverage is a hard gate too: cargo-llvm-cov measures the workspace and the job fails below 90% line coverage. See Testing.

Finding something to work on

Implementation Status is the map. Anything marked ⚪ is unbuilt, and the ones with the clearest specs are the easiest places to start:

  • kargo lint and kargo fmt — the crates are scaffolded and the rule set is specified
  • kargo publish — the Maven protocol is already implemented for reading
  • Hook dispatch — [hooks] parses, and the hook points are defined
  • Wiring flavors into the build path — types and BuildConfig generation exist

Open an issue before starting something large, so two people do not build the same thing twice.

Pull requests

  1. Branch descriptively: feat/resolver-nearest-wins, fix/core-empty-sourceset.
  2. Follow the code conventions and testing conventions.
  3. Run the CI gates locally.
  4. Update the docs in the same PR — including Implementation Status if you changed what works.
  5. Write a conventional commit subject — and give the pull request the same form. It is squash-merged, so the title is what lands on main, and a CI check enforces it.
  6. Resolve every review thread before merging — see Review and approval.

A PR that implements a documented feature should flip its status marker. A PR that changes documented behavior should change the documentation. Both live in this repository, so there is no excuse for them to drift.

Review and approval

Every pull request is reviewed by CodeRabbit, and its approval counts: the main ruleset asks for one approving review, and CodeRabbit can be the one.

GateWhat satisfies it
One approving reviewCodeRabbit, or a maintainer
Every review thread resolvedyou, before you merge
13 required status checks, plus CodeQLCI

.coderabbit.yaml at the repository root is what makes that workable. Two settings decide the shape of a review:

  • auto_approvals.max_merge_risk: low — CodeRabbit approves what it rates low risk and withholds on moderate and above, which is where a person looks.
  • auto_approvals.allow_author_approval: false — you cannot satisfy the required review on your own pull request by commenting @coderabbitai approve on it.

Threads are merge gates

required_review_thread_resolution is on, so every thread CodeRabbit opens has to be resolved before the merge button works.

Resolving is not agreeing. When a finding is wrong, or asks for something the conventions refuse — a comment that would break scripts/check-comment-budget.sh is the recurring one — say why and resolve the thread. CodeRabbit reads the conventions from CLAUDE.md and the nested crates/*/CLAUDE.md, which are in its default guideline patterns, so the config carries no second copy of them.

The approval is not durable

dismiss_stale_reviews_on_push is on, so a push dismisses the approval and CodeRabbit re-reviews the new head to re-earn it. That is why the config sets auto_review.auto_pause_after_reviewed_commits: 0: at the default of 5, CodeRabbit stops reviewing partway through a long-running branch, and the dismissed approval would then be permanently out of reach.

One more ruleset parameter can ask for a second approval CodeRabbit cannot give: require_extra_approval_for_unattributed_changes demands it when a commit's author is not attributable to a GitHub account. Set user.email to the address on your GitHub account and it never fires.

Why there is no CODEOWNERS

require_code_owner_review is on, and this repository has no CODEOWNERS file, which makes the requirement vacuous — no path is owned, so no owner review is demanded.

That is deliberate. GitHub Apps cannot be listed in CODEOWNERS; only users and teams can. A CODEOWNERS covering the changed paths would therefore make CodeRabbit's approval unable to satisfy the gate however it is configured, and every pull request would need a human approval. Adding one means choosing that; until it is chosen, the file stays absent.

Development tips

cargo test -p kargo-core              # one crate
cargo test -p kargo-resolver resolve  # one test by name
RUST_LOG=debug cargo run -- build     # internal tracing output
cargo build --release                 # target/release/kargo
cargo run -- --help

To try your build against a real project:

cargo install --path crates/kargo-cli --force
cd /path/to/a/kotlin/project
kargo build -v

Where to look next

Crate Architecture

Kargo is a Rust workspace of ten crates. The layering is strict, and the constraints below are not style preferences — breaking them makes the build graph cyclic or drags I/O into pure data types.

graph LR
    CLI["kargo-cli"] --> OPS["kargo-ops"]
    OPS --> CORE["kargo-core"]
    OPS --> RESOLVER["kargo-resolver"]
    OPS --> COMPILER["kargo-compiler"]
    OPS --> LINT["kargo-lint"]
    OPS --> PLUGIN["kargo-plugin"]
    OPS --> TOOLCHAIN["kargo-toolchain"]
    RESOLVER --> MAVEN["kargo-maven"]
    RESOLVER --> CORE
    COMPILER --> TOOLCHAIN
    COMPILER --> CORE
    MAVEN --> CORE
    LINT --> CORE
    PLUGIN --> CORE
    CORE --> UTIL["kargo-util"]

Who owns what

CrateResponsibility
kargo-utilError types, filesystem helpers, process spawning, hashing, progress bars. No domain logic.
kargo-coreData types and their parsing and serialization: Manifest, Package, Workspace, Target, SourceSet, Dependency, Flavor, Variant, Profile, Config, Lockfile, VersionCatalog, Properties. No I/O beyond reading config files.
kargo-mavenThe Maven protocol: POM parsing, maven-metadata.xml, artifact download, checksums, auth, publishing.
kargo-resolverThe resolution algorithm. Uses kargo-maven for metadata.
kargo-compilerCompiler invocation, build cache, incremental state, unit graph, job queue, KSP and KAPT.
kargo-toolchainKotlin and JDK download, version management, SDK discovery.
kargo-pluginPlugin system: script engine, subcommand discovery, hook dispatch.
kargo-lintLint engine and formatter. Tree-sitter Kotlin parsing, rule execution.
kargo-opsHigh-level operations wiring the rest together. One module per CLI command.
kargo-cliBinary entry point. Clap parsing, dispatch to kargo-ops. No business logic.

Hard constraints

  • kargo-core depends on nothing but kargo-util. Never add kargo-core → kargo-maven, kargo-ops, or anything else.
  • kargo-util depends on no other kargo-* crate.
  • kargo-cli depends only on kargo-ops, kargo-core, and kargo-util.
  • kargo-core contains no async code and no network I/O.
  • A new crate needs a discussion about the boundary first.

The reason kargo-core is kept pure: every other crate depends on it, so anything it pulls in becomes a dependency of the whole workspace, and anything it does at runtime becomes impossible to test without a network or a filesystem.

Where code goes

AddingGoes in
A new manifest sectionkargo-core (type plus parsing), then whoever consumes it
A new CLI commandkargo-cli/src/cli.rs (flags), commands/ (dispatch), kargo-ops (logic)
A new target backendkargo-compiler: implement TargetCompiler, register in dispatch.rs
A resolution changekargo-resolver
A repository-protocol changekargo-maven
A lint rulekargo-lint/src/rules/
A shared helperkargo-util — but only if it has no domain knowledge

Adding a target backend is deliberately cheap: implement the TargetCompiler trait and register it in dispatch::resolve. The build orchestration layer needs no changes.

Command flow

kargo build --release
  │
  ├─ kargo-cli      parse flags into Command::Build
  ├─ commands/      dispatch to the handler
  ├─ kargo-ops      ops_build: orchestrate the phases
  │   ├─ kargo-core        load and validate the manifest
  │   ├─ kargo-toolchain   ensure the Kotlin version and a JDK
  │   ├─ kargo-resolver    resolve, or read the lockfile
  │   │   └─ kargo-maven   fetch POMs and artifacts
  │   └─ kargo-compiler    plan units, fingerprint, compile, cache
  └─ print the result

kargo-ops is the only layer that knows about more than one subsystem. That is intentional: it keeps the orchestration in one readable place and the subsystems independently testable.

Crate-specific notes

Several crates carry their own CLAUDE.md with local conventions:

  • crates/kargo-core/CLAUDE.md
  • crates/kargo-maven/CLAUDE.md
  • crates/kargo-resolver/CLAUDE.md
  • crates/kargo-compiler/CLAUDE.md

Read the one for the crate you are editing.

Next

Code Conventions

The rules CI enforces, and the ones it cannot.

Clean code

The named standard is Robert C. Martin's Clean Code. The numbers below are the limits; the principles above them decide the cases the numbers do not cover.

  • Single Responsibility — one reason to change, per function and per module.
  • DRY — one authoritative representation per piece of knowledge. Duplication's real cost is divergence, not duplicated bytes.
  • KISS — the simplest thing that satisfies the requirement.
  • YAGNI — build the requirement, not the generalisation you imagine needing.
  • Boy Scout Rule — leave a file cleaner than you found it, which includes deleting its baseline #![allow(...)] when you can bring the module into line.

Functions

Target 20-30 lines, and 60 is the limit — clippy::too_many_lines is the lint that expresses it. Martin's own guidance is 20, which is the target rather than the threshold: match arms, builder chains and explicit error mapping cost vertical space in Rust that a Java method hides.

A function does one thing. The test is mechanical: if you can extract a function whose name is not a restatement of its own body, the original was doing more than one thing. The related rule is one level of abstraction per function — high-level orchestration and string-munging do not belong in the same body.

Nesting depth 2 is the target and 5 is the limit (clippy::excessive_nesting); clippy::cognitive_complexity catches the branchy functions that stay shallow. Three or four arguments at most — past that, introduce a params struct:

// Not this.
fn compile(a: &Path, b: &Path, c: &[Dep], d: bool, e: bool, f: &Profile) { }

// This.
fn compile(unit: &CompileUnit, profile: &Profile) { }

Keep Command-Query Separation: a function does something or answers something, not both. If it must both mutate through &mut and return data, the name says so.

Modules

One responsibility per module. A module that splits cleanly into groups of functions touching disjoint data is two modules wearing a trenchcoat, and the sign of it is usually a file over ~400 production lines.

Names carry no type or scope prefix. kargo_ops::ops_build stutters, and clippy::module_name_repetitions says so. One word per concept — fetch or download or get for a given act, not all three.

The corollary is that the module path is part of the name: the type is config::Global, not config::GlobalConfig, and the function is download::text, not download::download_text. A name that only reads with the module in front of it should be called with the module in front of it — config::Global::load() rather than an imported bare Global. The lint sees only public modules, so it follows the public surface rather than the file tree, and the handful of items where the repeated word is the one doing the work carry an #[expect] saying which word and why.

Comments

A comment explaining what the code does is a defect in the code. Rename the variable, extract the function, or give the magic number a name instead; reaching for the comment means expression lost. Martin's restatement is the operative version: don't comment bad code, rewrite it.

A comment earns its place when it carries what the code cannot — intent, a consequence worth warning about, a non-local invariant, a subtle failure mode, a coupling between two places that must stay in sync, legal text, a TODO. A /// on a public item is documentation, not a failure of expression; see Documentation comments. The rule above is aimed at // inside a function body.

Banners are banned. No // -----, no // -- fn_name ----, no // Public types. A file that needs internal signposting needs splitting, and the banner marks where to split it.

Coverage

Coverage is part of the standard, not only a CI job: new code is expected to be covered as you write it. The thresholds, and how to reproduce the measurement locally, are in Testing.

Where Clean Code and Rust part ways

Clean Code is a Java book, and some of it does not transfer. Do not "clean up" into the Java it was arguing against:

  • Result + ? with thiserror/miette stays. The exception chapters are moot here; see Errors.
  • Option stays. "Don't return null" is solved at the type level.
  • Read "class" as "module" or "type", and ignore the inheritance advice entirely.

Errors

thiserror for error types in library crates, miette for user-facing reporting with context and help text.

return Err(KargoError::Manifest {
    message: format!("package.version '{v}' is not valid semver"),
}
.into());

No .unwrap() or .expect() in library code — anything outside kargo-cli. Use ?, or return a Result. In kargo-cli, .expect() is acceptable only in main() setup.

This is not pedantry. A panic in a build tool prints a Rust backtrace at someone debugging their Kotlin project, which tells them nothing and looks like a crash rather than a message.

Add context when propagating:

let content = std::fs::read_to_string(path)
    .map_err(|e| KargoError::Manifest {
        message: format!("Failed to read {}: {e}", path.display()),
    })?;

An error message should name the file, the key, or the coordinate at fault. "Invalid manifest" is not an error message.

Logging

tracing macros only — info!, debug!, warn!, error!.

Never println! or eprintln! for diagnostics in library code. println! is correct in kargo-cli command handlers, where the point is user-facing output.

tracing::debug!("fingerprint miss for unit {}", unit.name);
tracing::warn!("Failed to remove {}: {e}", path.display());
RUST_LOG=debug cargo run -- build

API design

// Good
pub fn load(path: &Path, name: &str) -> miette::Result<Manifest>

// Avoid: forces the caller to allocate
pub fn load(path: PathBuf, name: String) -> miette::Result<Manifest>
  • &str over String, &Path over PathBuf, when ownership is not needed.
  • impl Into<String> or impl AsRef<Path> for builder-style APIs.
  • Return owned types — String, PathBuf, Vec.

Types

BTreeMap, not HashMap, wherever ordering is observable: manifests, lockfiles, anything serialized. This is what makes Kargo.lock byte-stable across runs and kargo add produce a one-line diff.

Derive Debug, Clone, Serialize, Deserialize on public data types.

#[serde(rename_all = "kebab-case")] for TOML field names, or per-field #[serde(rename = "…")]:

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Config {
    #[serde(default, rename = "java-target")]
    pub java_target: Option<String>,
}

Use #[serde(default)] liberally. Every optional manifest section should be omittable.

Dependencies

All external versions live in the workspace [workspace.dependencies]:

# Cargo.toml (workspace root)
[workspace.dependencies]
serde = { version = "1", features = ["derive"] }
# crates/kargo-core/Cargo.toml
[dependencies]
serde.workspace = true

Never pin a version in an individual crate manifest. One version per dependency across the workspace, or Cargo resolves two and the binary grows.

A new dependency is worth justifying in the PR description. Every one is a supply-chain surface, a compile-time cost, and a potential MSRV bump — a dependency bump can raise the Rust floor and make the workspace refuse to build, in which case rust-version and the README prerequisites move together.

Documentation comments

Public items get a doc comment, and only public items: a /// on a private helper is a reason that belongs either on the pub caller or in a // at the line it explains. Modules get a //! header saying what the module is for. missing_docs is a hard gate, so the public half is checked rather than asked for; the modules that still carry a #![allow(missing_docs)] baseline are the ones waiting on #131. missing_docs_in_private_items is deliberately off — it is the inverse of this rule.

Three sections are checked too, each exactly where it applies: missing_errors_doc asks a documented pub fn returning Result for # Errors, missing_panics_doc asks one that can panic for # Panics, and missing_safety_doc asks an unsafe fn for # Safety. Say what the caller can act on — which variant, and what it means — rather than restating the signature.

//! Target-agnostic compiler dispatch.
//!
//! Adding a new target backend requires implementing `TargetCompiler` and
//! registering it here — zero changes to the build orchestration layer.

Explain why where the code cannot. The existing defaults.rs is the model: each constant carries the reasoning for its value, so the next person bumping it knows what the constraint actually was.

Write the reason, do not cite it. A comment ending in a bare issue reference — (kargo#198) — sends a reader with the code in front of them outside the repository to read a closed issue restating the comment they came from, and nothing can check that the number still means anything. The history already keeps what the number was for: the commit that added the comment names the issue, so git log -S and git blame answer "why is this here" with the discussion rather than a link to it. scripts/check-issue-references.sh enforces this from the Conventions workflow, over crates/**/*.rs only — commit messages, pull request bodies and CHANGELOG.md are where an issue reference belongs.

Formatting and lint

cargo fmt --all
cargo clippy --workspace --all-targets -- -D warnings

Both are hard CI gates, and the hooks in .githooks/ run them on commit.

rustfmt.toml pins only what the defaults already do, plus newline_style = "Unix". That one is paired with *.rs text eol=lf in .gitattributes: without the git half, a checkout under the Windows default core.autocrlf=true yields CRLF files that cargo fmt --check then rejects wholesale. imports_granularity and group_imports are deliberately absent — they are nightly-only, and stable rustfmt ignores them with a warning, so pinning them would be configuration that does nothing.

The lints are in [workspace.lints] in the root Cargo.toml, with their thresholds in clippy.toml. File length has no lint — clippy has never shipped one — so scripts/check-file-length.sh enforces it from the Conventions workflow.

Silencing a clippy lint needs a reason, and the reason has to be about this code rather than about the backlog:

#[allow(clippy::too_many_arguments)] // mirrors the CLI flag surface

An #[allow] carrying a #131 baseline comment is the exception: those are not reviewed exceptions but a record of what was already over the limit when the gates landed, and each one is deleted by the refactor that brings its item into line.

Commit messages

Conventional Commits:

<type>(<scope>): <description>

[optional body]

Types: feat, fix, refactor, docs, test, chore, perf. There is no ci or build: chore covers build configuration, dependencies and CI.

Scopes are crate names minus the kargo- prefix: cli, core, ops, maven, resolver, compiler, plugin, lint, toolchain, util. Omit the scope for workspace-wide changes. Dependabot adds two of its own, deps and deps-dev, configured in .github/dependabot.yml.

feat(core): add flavor and variant types to manifest parsing
fix(maven): handle missing checksum in POM metadata
refactor(resolver): extract conflict resolution into its own module
docs: restructure the book around task-oriented guides
chore: update workspace dependencies

Write the subject in the imperative mood and keep it under about 72 characters. The body is where "why" belongs.

How it is enforced

scripts/check-conventional-subject.sh is the one implementation of the rule above. It reads the scope list out of [workspace].members, so adding a crate does not also mean editing the checker. Two things call it:

ChecksWhen
.githooks/commit-msgthe message you are writinggit commit
.github/workflows/conventions.ymlthe pull request titleopened, edited, pushed to

The pull request title is the one that matters. Pull requests here are squash-merged, so the title — not your local commit subjects — becomes the commit that lands on main, and that is what the changelog is generated from. A title that fails the check can be fixed in place; editing it re-runs the check without needing an empty push.

Run it yourself on anything:

scripts/check-conventional-subject.sh --subject "feat(core): add flavors"

Revert "..." titles pass as-is, since GitHub quotes a subject that already passed once.

Next

Testing

cargo test --workspace          # everything
cargo test -p kargo-core        # one crate
cargo test -p kargo-resolver nearest   # one test by name substring

CI runs the workspace suite on Linux, macOS, and Windows. A test that assumes a path separator or a home directory layout will fail on one of them.

Where tests go

One question decides it: does the test need to reach something that is not pub?

  • Yes — it goes inline, in an #[cfg(test)] mod tests at the bottom of the file that defines the item. A test for a private helper has nowhere else to live.
  • No — it goes in crates/<crate>/tests/, which cargo compiles as a separate crate that links yours the way a real consumer does.

That is the whole rule. Reach for "unit versus integration" and you will argue about the label; ask whether the test needs to see inside the module and you have an answer in five seconds.

LocationFor
crates/<crate>/src/** inlineTests that touch non-pub items
crates/<crate>/tests/Everything else: public API, fixture-driven cases, CLI behavior
tests/fixtures/Sample manifests and mock repository data, shared across crates
tests/projects/Whole sample projects, built and run by the end-to-end tier

Two things worth knowing about that table:

The repo root has no test tier. The root Cargo.toml is a virtual workspace — [workspace] with no [package] — so cargo compiles nothing from a root tests/*.rs. tests/fixtures/ and tests/projects/ are data directories read by crate tests, not test targets. A cross-crate test belongs in the tests/ directory of the crate that owns the entry point; CLI-level behavior goes in crates/kargo-cli/tests/, which drives the built binary through assert_cmd.

Visibility is a real constraint here, not a formality. A crate's top-level modules are mostly pub mod, but the submodules under them usually are not — ops_build/package.rs and plugins/ksp/standalone.rs sit behind a plain mod, so nothing in them is reachable from tests/ at any visibility, and kargo-cli is wholly unreachable because it is a binary. Check how a file's module chain is declared before concluding a test could move out of it.

scripts/check-inline-tests.sh enforces the rule, against scripts/inline-test-baseline — one line per file with an inline test mod, naming the non-pub item that keeps it there. Adding an inline test mod means adding a line; widening that item to pub fails the check until the file either names another private item or moves its tests to tests/. The conventions workflow runs it on every pull request, so the placement rule is checked rather than asserted.

Do not convert existing tests as a drive-by. A PR that moves tests and changes behavior is one nobody can review — move them in a PR that does nothing else.

Fixtures

tests/fixtures/
├── simple-jvm.toml
├── with-flavors.toml
├── with-catalog.toml
├── kmp-compose.toml
├── invalid-missing-name.toml
└── test.kargo.env

Each fixture is small and covers one scenario, with a name that says which. A fixture exercising five features at once tells you nothing when it fails.

What to cover

AreaCases
Manifest parsingValid and invalid Kargo.toml, every section
Interpolation${env:…} from .kargo.env and the environment, unresolved references
ResolutionTransitive graphs, conflicts, scope propagation, exclusions, BOM imports
Maven protocolPOM parsing, parent inheritance, metadata parsing, URL layout
Version parsingSemver edge cases, SNAPSHOT handling
CLICommand output, ideally as snapshots
LockfileRound-trip stability, byte-identical regeneration

A bug fix should come with a test that fails before it and passes after. That is the only way to know the fix addresses the reported problem rather than a neighbor.

Naming

No test_ prefix. Name the behavior and the condition it holds under:

#[test]
fn parse_manifest_with_flavors() { … }

#[test]
fn resolve_conflict_nearest_wins() { … }

#[test]
fn manifest_rejects_invalid_semver() { … }

A test name should tell you what broke without opening the file, and test_ is five characters that never do. The #[test] attribute directly above says it is a test; inside #[cfg(test)] mod tests the module path says it twice; and in crates/<crate>/tests/ cargo prints the target name as a header above that file's results. Prefixing only buries the part of the name that varies.

The rule is deliberately the same in both locations. Naming that depended on where a test lived would turn every move between the two into a rename, and tests move — the placement rule above sends them one way the first time something stops being pub.

rustc and cargo drop the prefix in their own suites, so this also keeps the tree reading like idiomatic Rust rather than like a port from another language.

Assertions

Always with a message:

assert_eq!(
    resolved.version, "1.9.21",
    "nearest-wins should pick the depth-1 version"
);

assert!(
    result.is_err(),
    "a manifest without package.name must be rejected"
);

For error cases, assert on the message too — an error that fires for the wrong reason still passes is_err():

let err = Manifest::parse_toml(input).unwrap_err();
assert!(
    err.to_string().contains("package.name"),
    "error should name the offending key, got: {err}"
);

.unwrap() in test code is fine. The no-panic rule is about library code.

Network

Resolution and download tests must not hit the network. Use fixtures and a mock repository layout under tests/fixtures/. A test suite that needs Maven Central fails on an airplane and flakes in CI.

kargo audit is the exception: it queries OSV live, so its tests cover request construction and response parsing rather than end-to-end behavior.

End-to-end runs

The end-to-end tier is the exception to the network rule, and the only one: kargo build on a real project is what users actually do, and it cannot be mocked into a meaningful test. Whether a processor's output lands where the compiler can use it, whether the jar carries an entry point, whether resolution reproduces its own lockfile — each of those is a fact about a real toolchain running over real sources.

It lives in crates/kargo-cli/tests/, driving the built binary through assert_cmd like every other CLI test. There is no separate workspace member for it and no root-level tier: the root Cargo.toml is a virtual workspace, so a root tests/*.rs compiles into nothing. The targets share one harness in crates/kargo-cli/tests/support/:

TargetCoversSamples
e2e_sample_projectsArtifacts, the build cache, --release, clean, run, test, lockfile regenerationjvm-sample, ksp-sample, plus every sample's lockfile
e2e_annotation_processingKAPT and KSP: generated sources, stubs, processor options, processor errors, stale outputkapt-sample, mixed-ap-sample
e2e_reporting_commandscheck, tree and its modes, fetch --verify, and the informational commandsjvm-sample
e2e_androidThe Android SDK on the classpath, .aar dependencies, compile-sdk in the fingerprintkargo new --template android
e2e_templatesThe service templates: resolution, compile, their own tests, and the service starting on the port it is givenkargo new --template ktor, --template spring

Each needs Maven Central, a Kotlin toolchain, and a JDK, so each is opt-in and cargo test skips them with a note:

KARGO_E2E=1 cargo test -p kargo-cli --test e2e_sample_projects
KARGO_E2E=1 cargo test -p kargo-cli --test e2e_annotation_processing
KARGO_E2E=1 cargo test -p kargo-cli --test e2e_reporting_commands
KARGO_E2E=1 cargo test -p kargo-cli --test e2e_android
KARGO_E2E=1 cargo test -p kargo-cli --test e2e_templates

e2e_android also needs an installed Android platform, two for the compile-sdk test, and skips without one.

Each test copies its sample into a temporary directory — including the sample's .kargo/ dependency cache, so a developer who has run the samples once pays no download, and the sample itself is never modified. Run the annotation-processing target after any change to crates/kargo-compiler/src/plugins/ or to the annotation-processing phase of kargo-ops, and the sample-projects target after any change to the build pipeline, the build cache, or resolution output.

In CI

The End-to-end job in .github/workflows/ci.yml runs every target on every pull request and every push to main. It is deliberately one ubuntu leg, not the three-OS matrix the rest of the suite uses: it downloads a compiler, spawns JVMs, and talks to Maven Central, so the matrix would triple the slowest and most environment-dependent part of CI for little extra signal.

Three things make that leg predictable, and each is load-bearing:

  • actions/setup-java pins a JDK 21. The samples declare java-target = "21" and JDK discovery reads JAVA_HOME first, so without the pin the leg inherits whatever the runner image ships.
  • A kargo fetch warm-up populates each sample's .kargo/, and actions/cache keeps that plus ~/.kargo across runs, keyed on the sample manifests and lockfiles. The tests read those caches through the copy they make, so a warm run downloads nothing.
  • Tests run with --test-threads=1. Each one spawns a Kotlin compile, and several JVMs at once on a four-core runner buy wall-clock with memory pressure.

A sample project is a test input, so changing one changes what CI asserts. If a change to tests/projects/ is intended, commit the regenerated Kargo.lock with it — every_sample_regenerates_its_committed_lockfile fails otherwise, by design.

Platform-specific code

#[cfg(unix)]
#[test]
fn executable_bit_is_set() { … }

#[cfg(windows)]
#[test]
fn path_normalization_on_windows() { … }

Prefer writing the test for every platform and normalizing paths in the code under test. A #[cfg(unix)] test is one CI matrix leg's worth of coverage.

Coverage

Coverage gates at 85% line coverage across the workspace, with Codecov's patch status held at 90% for the lines a change touches. Reproduce the project measurement locally with the same two steps the Coverage job uses:

cargo llvm-cov --workspace \
  --ignore-filename-regex '(^|/)tests/' \
  --lcov --output-path lcov.raw.info

scripts/filter-inline-test-coverage.sh \
  --input lcov.raw.info --summary --fail-under-lines 85

The Coverage job is a required status check, so falling below 85% blocks the merge. Test targets under tests/ are excluded — they are test code, not code under test — and the exclusion is duplicated in codecov.yml, so change both together.

The two thresholds differ on purpose. 85% is roughly where the workspace sits, so the project gate holds the line rather than chasing it; 90% on the patch ratchets new code up without blocking a change on a gap it did not create. kargo-ops is still the largest gap; the Codecov dashboard has the current per-crate figures, and a pull request that adds tests to a thin module is always welcome.

About a third of what is left is not reachable from an ordinary test: vendor downloads, the watch loop, interactive prompts, code that replaces the running binary, and the two annotation-processing passes that would need their own sample projects. Covering every line a test can reach would land around 94%, which is the practical ceiling rather than 100%.

Codecov reports the same threshold on each pull request: one comment, updated in place on every push, plus inline annotations on uncovered lines in Files Changed. The patch status covers the lines the change touched, which is the number worth reading on a review — a change that adds uncovered lines is the case the gate exists to catch.

Treat the percentage as a floor, not a goal. Hitting a number by testing what is easy to test is how a suite becomes expensive to maintain and bad at finding bugs; a module with no coverage at all is still the strongest signal on the report.

Next

Cutting a Release

A release is produced by merging one pull request. Nothing is hand-edited: not the version, not the changelog, not the tag.

The loop

merge to main
      |
      v
release-plz release-pr  ->  opens or updates "chore: release vX.Y.Z"
      |                       - bumps [workspace.package].version
      |                       - adds the CHANGELOG.md section
      v
you merge that PR
      |
      v
release-plz release     ->  pushes the tag vX.Y.Z
      |
      v
release.yml             ->  builds 5 platform binaries, computes
                            sha256sums.txt, creates the GitHub release
                            with the CHANGELOG.md section as its body

The release pull request is long-lived. Every merge to main updates it in place, so it always shows the version and the notes you would get by releasing right now. Ignore it for a month and it keeps accumulating; there is no deadline attached to it and no cost to leaving it open.

Both halves live in .github/workflows/release-plz.yml, and the binary build is unchanged in .github/workflows/release.yml.

Releasing

  1. Open the release pull request. Read the CHANGELOG.md diff as a user would: this is the text that becomes the release notes.
  2. Fix anything that reads badly by editing CHANGELOG.md on that branch. The next push to main leaves your edits alone and appends to them.
  3. Merge it.
  4. Watch the Release workflow. It must finish with five archives and sha256sums.txt attached. A release with no assets means the tag did not trigger the build — see the token.

To not release, do nothing. That is the whole mechanism.

The version number

The next version is computed from the Conventional Commit subjects since the last tag, and all ten crates move together — they share [workspace.package].version, and release-plz.toml puts them in one version_group so none of them can drift.

Commits since the last tagNext version from 0.2.0
only fix, docs, chore, …0.2.1
any feat0.3.0
any ! breaking marker0.3.0

Pre-1.0, release-plz's own default is that a feature bumps only the patch. features_always_increment_minor = true overrides that, because the 0.x minor is what Cargo treats as the compatibility boundary and because this repo's history already works that way — v0.1.0 to v0.2.0 was a feature release.

While the version is below 1.0 a breaking change and a feature are indistinguishable in the number. That is 0.x, not a configuration mistake.

What goes in the changelog

Sections come from the commit type, and the crate shows up as the scope on each line. chore, test, ci, build and style commits are dropped: they change nothing a user of the binary can observe, and the git history is where someone looking for them will go. A commit marked breaking with ! is never dropped, whatever its type.

Dependency bumps are the exception among chores — they are how a security advisory reaches a user — so chore(deps) gets its own Dependencies section.

The mapping lives in [changelog].commit_parsers in release-plz.toml.

Check the diff, don't trust it. release-plz attributes a commit to a crate by the files it touches, and on this workspace it has been observed to leave commits out. Reviewing the CHANGELOG.md diff in the release pull request is therefore part of releasing, not a formality — and it is why generating the notes into a reviewable pull request is better than generating them at tag time.

The token

This is the part that has to be right. A tag pushed with the default GITHUB_TOKEN does not trigger other workflows. release.yml triggers on push: tags: ["v*"], so with the default token the tag lands, and the binaries are never built — with nothing anywhere reporting a failure.

So both jobs read a RELEASE_PLZ_TOKEN secret, and skip with a warning when it is absent rather than pushing a tag that goes nowhere. Until the secret exists, releases stay manual and the workflow is inert.

Either of these works. A GitHub App is better — the release pull request is authored by a bot rather than attributed to a person, and there is no personal credential to rotate — but a fine-grained PAT is much less setup.

A fine-grained PAT. Settings → Developer settings → Personal access tokens → Fine-grained tokens. Scope it to this repository, grant Contents: read and write and Pull requests: read and write, then store it as the repository secret RELEASE_PLZ_TOKEN.

A GitHub App. Create an app with the same two permissions, install it on the repository, and store its id and private key as secrets. Then mint a token per run in both jobs:

- uses: actions/create-github-app-token@v2
  id: app-token
  with:
    app-id: ${{ secrets.RELEASE_PLZ_APP_ID }}
    private-key: ${{ secrets.RELEASE_PLZ_APP_KEY }}
# ...
  env:
    GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}

The same limitation applies to CI on the release pull request: opened with the default token, no checks run on it.

Releasing by hand

Pushing a v* tag still builds and publishes everything — that path never changed, and it is the fallback if the automation is wedged:

# Set [workspace.package].version, add the CHANGELOG.md section, commit.
git tag v0.3.0 && git push origin v0.3.0

If CHANGELOG.md has no section for the tag, release.yml says so in a warning annotation and falls back to GitHub's generated "What's Changed" list, so the release is never left with an empty body.

Why release-plz

The commit convention is already mandated and already followed here, so the information a changelog needs is in the history and nothing was consuming it. The alternative — a changeset file per pull request, as pnpm's changesets or knope do — buys better prose at the cost of a file that is easy to forget, and here it would mostly restate the subject line.

The cost of deriving it is real, though: the changelog is only as good as the commit subjects. That is the other reason .github/workflows/conventions.yml checks pull request titles — see Commit messages.

Working on the Docs

The documentation site is mdBook: plain Markdown files plus a navigation file, built to static HTML and published to GitHub Pages.

Build it locally

cargo install mdbook
mdbook serve docs --open

serve watches the source and reloads the browser on save. For a one-off build:

mdbook build docs      # output in docs/book/

docs/book/ is gitignored. Only sources are committed; the published site is built by CI.

Layout

docs/
├── book.toml              # mdBook configuration
├── theme/
│   ├── custom.css         # status callouts, tables, diagrams
│   └── mermaid-init.js    # renders ```mermaid fences
└── src/
    ├── SUMMARY.md         # navigation — every page must be listed
    ├── introduction.md
    ├── status.md
    ├── getting-started/
    ├── guide/
    ├── reference/
    ├── design/
    └── contributing/

Adding a page

  1. Create the .md file in the right section.
  2. Add it to SUMMARY.md — a page missing from SUMMARY.md is not built.
  3. Open with a status callout (see below).
  4. Link to it from related pages.

create-missing = false is set in book.toml, so a SUMMARY.md entry without a file fails the build. That is deliberate: CI catches the broken link rather than publishing a dead nav item.

The status convention

Every page opens with one line stating implementation status:

# Publishing

> **Status:** ⚪ Planned — `[signing]` parses, but `kargo publish` is not
> implemented. See [Implementation Status](../status.md).
MarkerMeaning
🟢Works today
🟡Partly working — say which part
⚪Specified, not built

Mark individual sections too when a page is mixed:

## Remote cache

> **Status:** ⚪ Planned.

Implementation Status is the single source of truth. Update it in the same PR that changes what works, and keep the per-page markers consistent with it.

Writing for these docs

Document the design, not the current state. These docs describe Kargo as it is being built to be; the status markers carry the difference. A planned feature is documented fully, in the present tense, with its marker — not hedged into vagueness.

Be accurate about what exists. Aspirational is not the same as invented. If a page shows kargo new output, that output must match what kargo new actually prints. Check the source before writing a code block for an implemented feature.

Lead with the task. Readers arrive with "how do I add a dependency", not "tell me about the dependency subsystem". Open with the command, then explain.

Say why, not just what. A table of flags is reference material. "Use --offline after kargo fetch to prove your build is reproducible" is a document.

Keep the architecture in its place. How Kargo Works exists for people debugging something surprising. It is not the point of the site, and user-facing pages should not require it.

Conventions

  • Hard-wrap prose at roughly 80 columns.
  • Fenced code blocks always carry a language: bash, toml, kotlin, rust, json, yaml, text.
  • Relative links between pages, with the .md extension — mdBook rewrites them.
  • Tables for anything enumerable: flags, keys, status.
  • Reference file.rs:42 style paths when pointing at source.

Diagrams

Fenced mermaid blocks render as diagrams:

```mermaid
graph LR
    A["kargo-cli"] --> B["kargo-ops"]
```

theme/mermaid-init.js converts these blocks and loads mermaid from a CDN, choosing a light or dark theme to match the reader's. There is no mdBook preprocessor to install — a plain mdbook build renders them. Offline, the diagram source stays visible as code, which still reads.

Publishing

.github/workflows/docs.yml builds the site on every push to main and deploys to GitHub Pages. Pull requests build it without deploying, so a broken SUMMARY.md or a missing page fails the PR.

Pages must be enabled once in the repository settings, with Source set to GitHub Actions.

Checking your work

mdbook build docs      # fails on a SUMMARY.md entry with no file
mdbook serve docs      # read what you wrote

Then click through the links you added. mdBook does not validate link targets inside pages — only SUMMARY.md entries.

The repository's other docs

FilePurpose
README.mdThe repository's front door. Short; links here.
CONTRIBUTING.mdA pointer to Contributing.
CLAUDE.md, .cursor/rules/Instructions for AI assistants working on Kargo.
crates/*/CLAUDE.mdCrate-local conventions.

Keep README.md short. It should orient a newcomer and send them here, not duplicate the docs.