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

Allow extendability (plugin support?)

Open dshatz opened this issue 11 months ago • 4 comments
trafficstars

Is your feature request related to a problem? Please describe. I am developing a ksp processor for generating a koin module from ktorfit declarations. https://github.com/dshatz/ktorfit-koin

The user creates a class:

@ServiceModule(scan="com.example.services")
class NetworkModule

My library generates:

val NetworkModule.module: Module = networkModule
val networkModule = module {
   // all ktorfit services discovered by my ksp processor.
}

Then, import the generated module into a normal Koin module.

@Module(includes=[NetworkModule::class])
class AppModule

The problem is that koin config check doesn't allow this. The error I get is: Fix your configuration: add @Module annotation on <Module class generated by ktorfit-koin>

Describe the solution you'd like Optionally disable @Module annotation presence check (for generated code?). Or implement some plugin mechanism?

Describe alternatives you've considered Disabling koin config check.

Target Koin project Koin annotations, to be specific config check part.

dshatz avatar Nov 27 '24 18:11 dshatz

I have resolved this (see latest commit in the repo above).

dshatz avatar Nov 30 '24 23:11 dshatz

can you give ref of your commit?

arnaudgiuliani avatar Jan 16 '25 15:01 arnaudgiuliani

can you give ref of your commit?

d6234843906423fcbf0ecd924f5de6564770e1d3

Check the part with markerName. Basically I manually generate an empty class for each ktorfit-koin module so that koin config check doesn't complain about missing @Module annotation on those.

Not sure if that is relevant to koin-annotations anymore. But could you explain please what's the purpose behind those generated empty classes (they end with Def from what I remember)?

dshatz avatar Jan 16 '25 15:01 dshatz

You can give a try with Koin Annotations 2.0-RC1. The idea of "tag" is marking having a way to store an index (what would result from a definition), and then retrieve it with just a class lookup. This avoids parsing heavy data, class is easily accessible by classpath search.

arnaudgiuliani avatar Jan 29 '25 15:01 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 Jun 28 '25 15:06 stale[bot]