Hey folks.
I'm writing a KSP processor for a multiplatform project where I want to scan annotated JVM code and generate both JVM + JS code, however the current
CodeGeneration
API does not seem to support writing to a different source set rather than the one being processed. My workaround is to pass
fileName = "../../(a lot more "../")/jsMain/OutputFileName"
With multiplatform, I imagine generating code for another platform will be a common use case. I'd be glad to contribute a PR with improvements in this area.
I thought about a
targetPlatform
parameter (of type enum) on
CodeGenerator.createNewFile
. What do you think?
t
Ting-Yuan Huang
08/25/2021, 6:12 AM
A few notes
1. Currently, the dirs are based on source sets, each corresponds to a compilation. E.g.,
commonMain
,
androidDebug
,
jsTest
, etc.
2. Another related issue is providing target or source-set specific ksp configuration, so that ksp doesn't apply on all compilations.
Because this is a new model (compared to kapt), there is no know solution / practice. We are still exploring how to do it right. Ideas are welcome and let's discuss before spending non-trivial amount of time on implementation.
e
edrd
08/26/2021, 12:43 AM
Nice, thanks for the info.
I will think about this and try to come with some ideas.