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.
| Template | Produces | Targets |
|---|---|---|
jvm | JVM application with an entry point | jvm |
lib | JVM library, no entry point | jvm |
kmp | Kotlin Multiplatform library | jvm, ios-arm64, ios-simulator-arm64 |
cmp | Compose Multiplatform app | jvm, android, ios-arm64, ios-simulator-arm64 |
android | Android application | android |
ktor | Ktor HTTP service, JSON over kotlinx.serialization | jvm |
spring | Spring Boot web service, Spring MVC and Tomcat | jvm |
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 directory | Yes, named <name> | No, uses the current one |
| Writes source files | Yes | No |
| Overwrites existing files | N/A | Never |
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
.aardependencies. 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 thekotlin-springcompiler plugin; Kargo has no equivalent yet, so the class saysopenitself.kotlin-reflectis 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 building | Template |
|---|---|
| A CLI or server | jvm |
| A library for other JVM projects | lib |
| Logic shared between an iOS and an Android app | kmp |
| An app with one UI across platforms | cmp |
| An Android-only app | android |
| An HTTP service on a coroutine-native stack | ktor |
| An HTTP service on the Spring ecosystem | spring |
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