Quick Start¶
Five minutes from apply to a narrowed build.
1. Apply and declare what the module can build¶
// feature-mobile/build.gradle.kts
plugins {
kotlin("multiplatform")
id("com.rsicarelli.kmptargets") version "0.1.0-SNAPSHOT"
}
kmpTargets {
supports { mobile } // androidTarget + the iOS leaves
}
kotlin {
sourceSets {
commonMain.dependencies {
// ...
}
}
}
supports { } is the module's supported set: the targets this module is allowed to register. Presets (all, mobile, apple, web, jvmFamily, …) and leaves (jvm, iosArm64, linuxX64, …) compose with + and -.
Ordering: apply everything first, then supports
supports registers targets eagerly, the moment it runs. Apply all plugins that influence registration before the kmpTargets { } block — most importantly the Android Gradle plugin when the module supports androidTarget. Calling supports more than once unions; a registered target can't be retracted.
2. Build everything (default)¶
With no selection configured, every supported target registers:
3. Narrow the build to what you need now¶
Only iosArm64 registers — selection ∩ supported. The unselected targets' tasks are never created.
For a durable choice, use the config files instead of the flag:
# kmp-targets.local.properties — git-ignored personal override (beats the committed default)
kmptargets.targets=iosArm64
4. Inspect what the plugin decided¶
kmp-targets — :feature-mobile
Selection (what to build now)
targets: iosArm64
source: command line (-Pkmptargets.targets)
Supported (what this module can build)
declared: yes
targets: androidTarget, iosArm64, iosSimulatorArm64, iosX64
Registered (selection ∩ supported)
targets: iosArm64
The source line names the winning selection layer.
Where to next¶
- Selection DSL —
supports { }in full: eagerness, unions, escape hatches - Selection Layers — the precedence chain in detail
- Targets Reference — every preset and leaf
- CI — per-host selections on a 3-OS matrix