Repository navigation
Migra Koin de KSP Annotations para o Koin Compiler Plugin - #100
Merged
Merged
Conversation
- Koin 4.2.0 -> 4.2.2; koin-ksp-compiler removed, Compiler Plugin 1.2.3 applied by com.streamplayer.kmp-library (KSP kept only for Room in core-local-storage) - @KoinApplication KoinApp + startKoin<KoinApp> replace the KSP-generated `AppModule().module` call sites; the four annotated modules become @configuration discovery roots - @KoinViewModel moves to org.koin.core.annotation; @provided dropped (gone in Koin 4.2, KSP had generated plain get() for those parameters) - PermissionsModule: lazyModule -> module so the full-graph check sees PermissionsManager (lazyModules is not followed by compile safety) - compile-safety at startKoin replaces KSP's KOIN_CONFIG_CHECK
rviannaoliveira
approved these changes
Nov 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contexto
O grafo era declarado com
koin-annotations 2.3.1+koin-ksp-compilervia o convention plugincom.streamplayer.koin-annotations-setup(KSP,kspCommonMainMetadata,srcDirdo código gerado e o workaround dedependsOn("kspCommonMainKotlinMetadata")). Este PR troca a geração por compilação: Koin Compiler Plugin 1.2.3 com Koin 4.2.2, sem KSP para o Koin.O que muda
Gradle
4.2.0->4.2.2; Compiler Plugin1.2.3aplicado nocom.streamplayer.kmp-library(todos os módulos KMP) e noandroidApp, comcompileSafety = true.com.streamplayer.koin-annotations-setupfica só com os artefatos do Koin: sai o plugin KSP, okspCommonMainMetadata, osrcDirgerado, odependsOne oKOIN_CONFIG_CHECK(34 linhas -> 3).core-local-storage(Room). Removido docore-background-work, que aplicava o plugin sem nenhum processor.Código
@KoinApplication object KoinApp+startKoin<KoinApp>(org.koin.plugin.module.dsl) substituem osNetworkModule().module/SearchModule().modulegerados pelo KSP.NetworkModule,SearchModule,NewsScreenModule,ProfilePickerStreamModule) passam a ser raízes de descoberta@Configuration.@KoinViewModel->org.koin.core.annotation;@Single->@Singleton;@Providedremovido dos 6 parâmetros (a anotação não existe mais no Koin 4.2 e o KSP geravaget()para eles, então o comportamento é o mesmo).ListStreamModule,DetailStreamModule,LocalStorageModule,SyncModule,PermissionsModule,coreSessionModule) não foram reescritos: continuam em DSL e agora são checados pelo plugin.Um ajuste de comportamento
PermissionsModule:lazyModule->module. A checagem de grafo não seguelazyModulese reportavaKOIN-D001paraPermissionsManager. A criação da instância continua sob demanda (corpo dosingle { }), só o registro do módulo passou a ser no start.Por que sem
koin-bomplatform(Any)está comoDeprecationLevel.ERRORno Kotlin DSL do Gradle 9.3 dentro dos scripts precompilados do build-logic (não é suprimível). Os artefatos do Koin são resolvidos pela mesma chavekoindolibs.versions.toml, o que mantém o alinhamento.Validação
./gradlew :androidApp:assembleDebugOK./gradlew testDebugUnitTestOK./gradlew :composeApp:compileKotlinIosSimulatorArm64OK (target nativo)./gradlew detektOK (mesmo comando do CI)KOIN-D001real durante a migração (antes do ajuste doPermissionsModule), ou seja, ela roda de verdade emstartKoin<KoinApp>.ListStreamViewModel+ sessão + DAO do Room), Detail (parametersOf(id)+rememberKoinModules), Search (lista padrão e busca digitada, exercitando os 8@Factory), News (fluxo de permissão ->PermissionsManager) e Profile picker (4@Factory+ ViewModel). Nenhuma exceção do Koin no logcat.Como testar
Abrir Início -> um título (Detail) -> busca -> Novidades (permitir/negar permissão) -> avatar (Profile picker).
Follow-ups (fora do escopo)
single<T>()/factory<T>()é uma etapa de estilo opcional.core-permission/.../di/PermissionsModule.ktnão tem declaração depackage(pré-existente).core-sessionaplica o convention plugin de annotations sem ter nenhuma anotação.Kotzilla
A sessão foi capturada no emulador depois da migração; não houve baseline em 4.2.0 e o MCP não estava conectado nesta sessão, então tempos de vida/instâncias não foram comparados com o antes.