Closed eygraber closed 2 months ago
Another option would be to group by source file, I've used that successfully with ksp before though I don't think it's currently doing that for components in this project. ksp's incremental compilation only works on the file-level too anyway so there shouldn't be an issues if one function in the file changes, though I don't know if there's plans to change that.
I implemented grouping the KmpComponentCreate
functions into a single file by Component
type and it was pretty simple. I'll push that in a separate commit now.
I missed the
Target...Accessor
part in the previous PR.I also simplified the name, because what I had before was pretty gnarly since it was trying to avoid
FileAlreadyExistsException
in case there are multiple@KmpComponentCreate
functions for the sameComponent
.With this new approach the following would cause a compile time error because the processor would generate two files named
KmpComponentCreateMyComponent.kt
:Using the approach from before there would be no
FileAlreadyExistsException
, but the generated file names would beKmpComponentCreateMyComponentCreateKmp.kt
andKmpComponentCreateMyComponentMyComponentCompanionCreateKmp.kt
respectively. That works, and is safest, so the question is how ugly is too ugly for generated file names?Another approach would be to defer writing the files until the final round, and then group the functions by
Component
type, and generate one file containing all of the functions for thatComponent
.