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.
What to read next
| If you want to⦠| Go to |
|---|---|
| Understand every manifest key | The Manifest |
| Manage dependencies properly | Dependencies |
| Start a library instead of an app | Project Templates |
| Target iOS, JS, or Android too | Kotlin Multiplatform |
| Build a Compose UI | Compose Multiplatform |
| Know what each directory is for | Project Layout |