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

Annotations setup in multi-module Gradle architecture

Open bogdanzurac opened this issue 2 years ago • 7 comments

Is your feature request related to a problem? Please describe. When using Koin Annotations in a multi-module Gradle architecture, we need to declare a Koin module per each individual Gradle module in order to pick up the components from that particular Gradle module. That means that even for Gradle modules that have simple setups with maybe only 1 component, we still need to manually declare a Koin module.

Describe the solution you'd like In a similar architecture, Dagger doesn't require a separate Dagger module to be defined for each Gradle module. That simplifies the setup a lot, especially for projects with hundreds of Gradle modules. Would it be possible to automatically add components from any Gradle module to the defaultModule definition from the main Gradle module that calls the startKoin method?

bogdanzurac avatar May 10 '23 17:05 bogdanzurac

Yes, this is something that could help

arnaudgiuliani avatar May 30 '23 10:05 arnaudgiuliani

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Nov 29 '23 02:11 stale[bot]

A simple step towards better multi-module experience would be to have a customizable module name with a sane default. The default module is not usable at all at the moment, because it is always generated as org.koin.ksp.generated.defaultModule. If it would be placed at <moduleName>.defaultModule instead, one could at least manually aggregate all default modules at app-level.

kalinjul avatar Mar 04 '24 12:03 kalinjul

Ok I see

arnaudgiuliani avatar Mar 29 '24 09:03 arnaudgiuliani

using app, usecases and data modules, i get this Type org.koin.ksp.generated.DefaultKt$defaultModule$1$1 is defined multiple times: C:\android\Paradigma\archetypes\compose-inital-kmm-libraries\usecases\build.transforms\0ee14af2934366395f0366a0ed59ee54\transformed\main\main_dex\org\koin\ksp\generated\DefaultKt$defaultModule$1$1.dex, C:\android\Paradigma\archetypes\compose-inital-kmm-libraries\data\build.transforms\ac83bc7ce413ddae3f62f35d4d21730b\transformed\main\main_dex\org\koin\ksp\generated\DefaultKt$defaultModule$1$1.dex

fuentepa avatar Apr 01 '24 16:04 fuentepa

@fuentepa I also encountered this problem, which can be circumvented by setting KOIN_CONFIG_CHECK=false. You can refer to the official documentation https://insert-koin.io/docs/reference/koin-annotations/start#compile-safety---check-your- koin-config-at-compile-time-since-130

XDMrWu avatar Apr 27 '24 10:04 XDMrWu

@fuentepa I also encountered this problem, which can be circumvented by setting KOIN_CONFIG_CHECK=false. You can refer to the official documentation https://insert-koin.io/docs/reference/koin-annotations/start#compile-safety---check-your- koin-config-at-compile-time-since-130

Maybe in this case it crash for that reason, but i get the same OP problem, when i have more modules using defaultmodule with anotations: that produce name colission between modules.

fuentepa avatar May 01 '24 13:05 fuentepa

Multimodule scan is ready in https://github.com/InsertKoinIO/koin-annotations/issues/135 🎉

arnaudgiuliani avatar Jul 10 '24 16:07 arnaudgiuliani