docs/reference/koin-annotations/options.md
The Koin Compiler Plugin supports configuration options to customize its behavior.
Configure the compiler plugin in your build.gradle.kts:
koinCompiler {
userLogs = true
debugLogs = false
compileSafety = true
strictSafety = true // auto-detected by default
skipDefaultValues = true
unsafeDslChecks = true
}
falsekoinCompiler {
userLogs = true
}
falsekoinCompiler {
debugLogs = true
}
truekoinCompiler {
compileSafety = true
}
See Compile-Time Safety for full details on what gets validated.
startKoin, koinApplication, or @KoinApplication)true if auto-detection misses your aggregator, or to false to opt out (e.g. when a test fixture only references startKoin in a comment and trips the detector).koinCompiler {
strictSafety = true // force-enable
// or
strictSafety = false // opt out of auto-detection
}
Why it exists: K2's incremental compilation today (via the Build Tools API used by AGP) doesn't track two things the DI graph relies on — DSL definitions inside module { … } lambda bodies (not part of any declaration's ABI), and @ComponentScan package-scope discovery (no source-level edge from the scanner to newly-added classes). The aggregator's compileKotlin task can be marked UP-TO-DATE even when the graph changed. strictSafety is the smallest correct workaround on top of what K2 IC currently surfaces; it has bounded cost since only the aggregator re-runs each build.
Has no effect when compileSafety = false. See koin-compiler-plugin issue #32 for background.
true@Named, @InjectedParam, etc.) are still resolved normally.koinCompiler {
skipDefaultValues = true
}
truecreate()) inside lambdas are the only instruction. Helps prevent common mistakes.koinCompiler {
unsafeDslChecks = false // Disable during migration
}
// build.gradle.kts
plugins {
alias(libs.plugins.koin.compiler)
}
koinCompiler {
userLogs = true // Log component detection
debugLogs = false // Verbose logs (off by default)
compileSafety = true // Compile-time dependency validation
strictSafety = true // Force aggregator to re-run safety pass (auto-detected by default)
skipDefaultValues = true // Use Kotlin defaults instead of DI resolution
unsafeDslChecks = true // Validate DSL usage
}
compileSafety enabled (default) for compile-time dependency validationstrictSafety at auto-detect — only override if the detector misses your aggregator or trips on a non-aggregator fileskipDefaultValues enabled (default) to respect Kotlin default valuesuserLogs during development to see which components are detectedunsafeDslChecks enabled (default) for safer DSL usagedebugLogs only when troubleshooting plugin issues