[ksp] Add support for reading generated resource files
Currently the only way to read resource files generated by a KSP symbol processor is to use File(KotlinCompilation.kspSourcesDir, "resource") which is only available from KotlinCompilation and not KotlinCompilation.Result. It would be nice if there was a more standardized way to read generated resource files when using KSP.
Can you give some examples how you generate and access resource files from within KAPT or KSP in a regular Gradle project? Currently I don't have time to really investigate but I've done some superficial research and it seems that resource files are not managed by javac/kotlinc, so anything you do with resource files only works "accidentally" and is specific to the build system. If it works in a Java project then it doesn't necessarily also work the same way in an Android project and some things like incremental compilation or multiple rounds processing might not work at all for resource files. Still it's probably useful to replicate the Gradle behaviour if possible.
I'm generating the required metadata resource files for Gradle plugins. You can see how the file is generated here: https://github.com/ansman/auto-plugin/pull/2/files#diff-076fd4f8b560d131d682cc12aaf63c54R95
The goal is just to include it in the final jar when packaging.
Here's another example, quite similar to Nicklas's https://github.com/ZacSweers/auto-service-ksp/blob/main/processor/src/test/kotlin/dev/zacsweers/autoservice/ksp/AutoServiceSymbolProcessorTest.kt#L51-L52
I'm currently using a workaround to have access to generated sources, and mentioned it in #129. A slightly modified version could work for resources as well.
internal val KotlinCompilation.Result.workingDir: File get() =
outputDirectory.parentFile!!
val KotlinCompilation.Result.kspGeneratedReources: List<File> get() {
val kspWorkingDir = workingDir.resolve("ksp")
val kspGeneratedResources = kspWorkingDir.resolve("sources")
.resolve("resources")
return kspGeneratedResources.listFilesRecursively()
}