how to generate a non-source-code file with ksp

426 views Asked by At

I want to to use ksp to generate some graalvm reflect config files. How can I do that? I found the following post: How to generate android resource (xml) files by using Kotlin KSP

This describes a hacky gradle workaround to include a resource file in a configured dir and merge it with the main source sets resource dir. This is not the mechanism I would wanna use as a user of a lib, as it ties me pretty much to gradle and its clumsy.

When using createNewFile on the code generator, the file always ends up in the source code inside of the jar and not in the META-INF dir.

Is there a better way of using ksp natively somehow for creating a resource? Thanks.

1

There are 1 answers

0
cmdjulian On

I found out how to do it:

private val generator: CodeGenerator

generator.createNewFileByPath(Dependencies(false), "META-INF/native-image/io.fabric8/kubernetes/resource-config", "json")

This will create the json file at the specified resource folder location