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

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