koin-annotations icon indicating copy to clipboard operation
koin-annotations copied to clipboard

Support for gradle modules with inverted dependencies

Open wintren opened this issue 3 months ago • 0 comments

Basically, I want to be able to use annotations but still be able to not have the required injections available in my gradle module. The problem right now is that if I create a class with @Single and it takes an interface; the provided injection (implementation) must be provided in that gradle module. This is not desired since I want to follow Clean/Solid and have my :data module depend on :domain.

The exact issue. Modules (:app, :domain, :data, :di) [:app -> :di, :app -> :domain] [:di -> :domain, :di -> :data], [:data -> :domain]. In domain I have a ItemRepository (interface), it's implemented (ItemRepositoryImpl) in :data with @Single(binds = [ItemRepository::class]). But in domain I also have a use case

@Single class MakeNewItemUseCase(
    val repo: ItemRepository
) { ...

When I use annotations the graph/module that is created tries to cater for the use case in just the domain module, and I get an error that the repository is not available - which is true in :domain.

I want to see either an option, or a change in behaviour, where all annotated modules in different gradle modules come together in the end to form a single Module. Or actually I don't care how it's done - I just want the the dependency declared in an unknown (to :domain) module to be provided.

Versions:

ksp = "2.2.10-2.0.2"
koin-core = "4.1.0"
koin-annotations = "2.1.0"

wintren avatar Aug 26 '25 05:08 wintren