L-Briand / KTM

Mustache template engine in kotlin multiplatform
https://mustache.github.io/
MIT License
18 stars 0 forks source link

can't find ksp generated code #1

Open Zane-XY opened 8 months ago

Zane-XY commented 8 months ago

Using the below configuration, I can see the AutoKtmAdaptersModule is generated. But my project can't find it, even I've added

dependencies {
    add("kspJvm", "net.orandja.ktm:ksp:0.0.2")
}
val commonMain by getting {
            kotlin.srcDir("build/generated/ksp/jvm/jvmMain/kotlin")
}

or

jvmMain {
            kotlin.srcDir("build/generated/ksp/jvm/jvmMain/kotlin")
}

The compiler plugin seems to output each target in their own generated source dirs. But the usage of the AutoKtmAdaptersModule is from a commonMain sourceSet.

updates:

i get this working by defining an expect function in the commonMain,

expect fun initKtm()

and implemented it in each target:

Ktm.setDefaultAdapters(AutoKtmAdaptersModule)

This is not on the documentation though, is this the correct way? Can I just generate it as commonMain source?

L-Briand commented 8 months ago

Hello

is this the correct way?

Yes, this is the correct behavior and way to declare adapters.

Can I just generate it as commonMain source?

I don't know why but the KSP plugin do not allow to generate code for the common target. Even if the generated code is common compatible. I can't do anything about it, it is a limitation on KSP itself.

I'm working alone on this project and you are right this is a bit confusing for new people wanting to use the lib. I'll add some documentation about it. If you have some remarks on how to improve the lib, please tell.