Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ open class KoinGradleExtension(objectFactory: ObjectFactory) {
*/
val compileSafety: Property<Boolean> = objectFactory.property(Boolean::class.java).convention(true)

/**
* Run compile-time safety checks in test compilations (`test`, `*Test`) too (default: true).
* Set to false when tests load partial graphs; main compilations keep [compileSafety].
*/
val testCompileSafety: Property<Boolean> = objectFactory.property(Boolean::class.java).convention(true)

/**
* Force the safety pass to always run, bypassing Kotlin's incremental compilation cache.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,16 @@ class KoinGradlePlugin : KotlinCompilerPluginSupportPlugin {
// moduleId so synthetic hint files in org.koin.plugin.hints get module-disambiguated
// and don't collide at dex merge. See KoinPluginConstants.OPTION_MODULE_ID.
val moduleId = project.path
val isTestCompilation = kotlinCompilation.name.let { it == KotlinCompilation.TEST_COMPILATION_NAME || it.endsWith("Test") }

return project.provider {
val compileSafety = extension.compileSafety.get() && (!isTestCompilation || extension.testCompileSafety.get())
listOf(
SubpluginOption(OPTION_USER_LOGS, extension.userLogs.get().toString()),
SubpluginOption(OPTION_DEBUG_LOGS, extension.debugLogs.get().toString()),
SubpluginOption(OPTION_UNSAFE_DSL_CHECKS, extension.unsafeDslChecks.get().toString()),
SubpluginOption(OPTION_SKIP_DEFAULT_VALUES, extension.skipDefaultValues.get().toString()),
SubpluginOption(OPTION_COMPILE_SAFETY, extension.compileSafety.get().toString()),
SubpluginOption(OPTION_COMPILE_SAFETY, compileSafety.toString()),
SubpluginOption(OPTION_AI_ASSIST, extension.aiAssist.get().toString()),
SubpluginOption(OPTION_MODULE_ID, moduleId),
SubpluginOption(OPTION_LOG_SEVERITY, extension.logSeverity.get()),
Expand Down