https://kotlinlang.org logo
Title
t

TwoClocks

03/26/2022, 11:53 PM
The next thing: Sometimes my processor isn't called when building (gradle), and no code is generated (the output directory is empty). The only way I can get gradle/ksp to call my processor again is to touch/change the processor code itself. I feel like I'm not understading dependencies correctly. I'd like the processor to run if the resulting files don't exist....
y

yigit

03/27/2022, 12:34 AM
When you generate a file, you give all the elements that affected the file. If none of them changed, KSP won't call your processor and use the code that you generated in the previous compilation. You actually don't need to list all source elements, e.g. room only reports the RoomDatabase annotated class and KSP is able to understand that any DAO change will also invalidate it because the database accesses them
t

TwoClocks

03/27/2022, 1:07 AM
That makes sense. But the problem seems to be that if the generate files are deleted (as gradle is want to do), KSP won't run the processor... because none of the source files have changed.
at least that's what it seems like.
this seems to be repeatable. If I delete
[project-root]/build/generated/ksp/main/kotlin
Touch a file in a project that depend son the annotation, KSP doesn't run the processor, and the dependent project fails because of the missing generated code. Neither the annotaion, or the code that contains the annotation has changed... so it's not running. How do a make the resulting artifact of the annotation part of the dependency? I had sort of assumed that it was implied somehow. It doesn't seem to be (or I un-set it somehow).
j

jameskleeh

03/27/2022, 3:34 AM
when you generate files you supply one or more originating elements
ensure its correct
t

TwoClocks

03/27/2022, 8:15 PM
I think I've specified the originating elements correctly (maybe not). But when the resulting artifact is deleted, and the originating elements haven't changed, KSP does not call (or even launch) my processor. Gradle seems to like to delete the
generated
tree somewhat at random (AFAICT). So when this happens the only way I can get an artifact generated is to make meaningless change in a string in one of the originating elements.
I moved the use of that annotation into a different grade sub-project, and now it doesn't get deleted are reliquary, so it's works.