Compiler Plugin Options
The Koin Compiler Plugin supports configuration options to customize its behavior.
Configuration
Configure the compiler plugin in your build.gradle.kts:
koinCompiler {
userLogs = true
debugLogs = false
compileSafety = true
skipDefaultValues = true
unsafeDslChecks = true
}
Available Options
userLogs
- Type: Boolean
- Default:
false - Description: Enables logs for component detection and DSL/annotation processing. Shows which components are discovered and processed by the plugin.
- Usage: Enable during development to debug component discovery issues.
koinCompiler {
userLogs = true
}
debugLogs
- Type: Boolean
- Default:
false - Description: Enables verbose debug logs for internal plugin processing (FIR/IR phases, module discovery).
- Usage: Enable when troubleshooting plugin issues or reporting bugs.
koinCompiler {
debugLogs = true
}
compileSafety
- Type: Boolean
- Default:
true - Description: Enables compile-time dependency validation. When enabled, the plugin validates that all dependencies can be resolved at build time — catching missing definitions, qualifier mismatches, and broken call sites before runtime.
- Usage: Enabled by default. Disable temporarily if you need to bypass validation during migration.
koinCompiler {
compileSafety = true
}
See Compile-Time Safety for full details on what gets validated.
skipDefaultValues
- Type: Boolean
- Default:
true - Description: When enabled, parameters with Kotlin default values will use the default instead of being resolved from the DI container. Nullable parameters and annotated parameters (
@Named,@InjectedParam, etc.) are still resolved normally. - Usage: Enabled by default. Disable to always inject all parameters from the DI container.
koinCompiler {
skipDefaultValues = true
}
unsafeDslChecks
- Type: Boolean
- Default:
true - Description: Validates that DSL function calls (like
create()) inside lambdas are the only instruction. Helps prevent common mistakes. - Usage: Disable temporarily during migration from classic DSL if needed.
koinCompiler {
unsafeDslChecks = false // Disable during migration
}
Complete Example
// 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
skipDefaultValues = true // Use Kotlin defaults instead of DI resolution
unsafeDslChecks = true // Validate DSL usage
}
Best Practices
- Keep
compileSafetyenabled (default) for compile-time dependency validation - Keep
skipDefaultValuesenabled (default) to respect Kotlin default values - Enable
userLogsduring development to see which components are detected - Keep
unsafeDslChecksenabled (default) for safer DSL usage - Use
debugLogsonly when troubleshooting plugin issues
See Also
- Compile-Time Safety - What gets validated and how
- Compiler Plugin Setup - Complete setup guide
- Starting with Annotations - Getting started