diff --git a/projects/koin-ksp-compiler/src/jvmMain/kotlin/org/koin/compiler/BuilderProcessor.kt b/projects/koin-ksp-compiler/src/jvmMain/kotlin/org/koin/compiler/BuilderProcessor.kt index 465e5e4..e063c25 100644 --- a/projects/koin-ksp-compiler/src/jvmMain/kotlin/org/koin/compiler/BuilderProcessor.kt +++ b/projects/koin-ksp-compiler/src/jvmMain/kotlin/org/koin/compiler/BuilderProcessor.kt @@ -33,7 +33,7 @@ class BuilderProcessor( private val koinCodeGenerator = KoinGenerator(codeGenerator, logger, isComposeViewModelActive() || isKoinComposeViewModelActive()) private val koinMetaDataScanner = KoinMetaDataScanner(logger) private val koinTagWriter = KoinTagWriter(codeGenerator,logger) - private val koinConfigChecker = KoinConfigChecker(codeGenerator, logger, koinTagWriter) + private val koinConfigChecker = KoinConfigChecker(codeGenerator, logger) override fun process(resolver: Resolver): List { logger.logging("Scan symbols ...") @@ -56,10 +56,13 @@ class BuilderProcessor( logger.logging("Generate code ...") koinCodeGenerator.generateModules(moduleList, defaultModule, isDefaultModuleActive()) + val allModules = moduleList + defaultModule + koinTagWriter.writeAllTags(allModules) + if (isConfigCheckActive()) { logger.warn("Koin Configuration Check") - koinConfigChecker.verifyDefinitionDeclarations(moduleList + defaultModule, resolver) - koinConfigChecker.verifyModuleIncludes(moduleList + defaultModule, resolver) + koinConfigChecker.verifyDefinitionDeclarations(allModules, resolver) + koinConfigChecker.verifyModuleIncludes(allModules, resolver) } return emptyList() } diff --git a/projects/koin-ksp-compiler/src/jvmMain/kotlin/org/koin/compiler/verify/KoinConfigChecker.kt b/projects/koin-ksp-compiler/src/jvmMain/kotlin/org/koin/compiler/verify/KoinConfigChecker.kt index 580b586..2183401 100644 --- a/projects/koin-ksp-compiler/src/jvmMain/kotlin/org/koin/compiler/verify/KoinConfigChecker.kt +++ b/projects/koin-ksp-compiler/src/jvmMain/kotlin/org/koin/compiler/verify/KoinConfigChecker.kt @@ -26,7 +26,7 @@ const val codeGenerationPackage = "org.koin.ksp.generated" /** * Koin Configuration Checker */ -class KoinConfigChecker(val codeGenerator: CodeGenerator, val logger: KSPLogger, val koinTagWriter: KoinTagWriter) { +class KoinConfigChecker(val codeGenerator: CodeGenerator, val logger: KSPLogger) { fun verifyDefinitionDeclarations( moduleList: List, @@ -35,9 +35,7 @@ class KoinConfigChecker(val codeGenerator: CodeGenerator, val logger: KSPLogger, val isAlreadyGenerated = codeGenerator.generatedFile.isEmpty() val allDefinitions = moduleList.flatMap { it.definitions } - if (!isAlreadyGenerated) { - koinTagWriter.writeTags(allDefinitions) - } else { + if (isAlreadyGenerated) { verifyTags(allDefinitions, resolver) } } diff --git a/projects/koin-ksp-compiler/src/jvmMain/kotlin/org/koin/compiler/verify/KoinTagWriter.kt b/projects/koin-ksp-compiler/src/jvmMain/kotlin/org/koin/compiler/verify/KoinTagWriter.kt index 8cab05d..41ee561 100644 --- a/projects/koin-ksp-compiler/src/jvmMain/kotlin/org/koin/compiler/verify/KoinTagWriter.kt +++ b/projects/koin-ksp-compiler/src/jvmMain/kotlin/org/koin/compiler/verify/KoinTagWriter.kt @@ -12,7 +12,20 @@ const val tagPrefix = "KoinDef" class KoinTagWriter(val codeGenerator: CodeGenerator, val logger: KSPLogger) { - fun writeTags(allDefinitions: List) { + fun writeAllTags( + moduleList: List + ) { + + val isAlreadyGenerated = codeGenerator.generatedFile.isEmpty() + val allDefinitions = moduleList.flatMap { it.definitions } + + if (!isAlreadyGenerated) { + logger.warn("Koin Tags Generation ...") + writeTags(allDefinitions) + } + } + + private fun writeTags(allDefinitions: List) { val alreadyDeclaredTags = arrayListOf() val tagFileName = "KoinMeta-${hashCode()}" val tagFileStream = writeTagFile(tagFileName)