https://kotlinlang.org logo
Title
f

Fudge

08/01/2019, 8:12 AM
I am making an annotation processor that generates Kotlin source files using Kotlin poet, however I am unsure how can I make incremental processing work properly. The problem is that outdated source files don't get deleted. How can I "mark" generated Kotlin source file as being outdated and that they need to be deleted? Example:
@NbtSerializable
class Foo // --> Generates source file named "FooUtil"
Now I remove
@NbtSerializable
and need
FooUtil
to be deleted as well.
s

Sergey Chelombitko

08/01/2019, 9:50 AM
You need to call
addOriginatingElement
on every TypeSpec/FunSpec/etc. builder and pass the corresponding element. Also make sure you use only
FileSpec.writeTo(Filer)
for writing files.
👍 1