We have a project that we're processing using KSP (searching for functions annotated with the `@Page...
d
We have a project that we're processing using KSP (searching for functions annotated with the
@Page
annotation). To this project, if we add an empty Kotlin file, reprocess KSP, then delete the file, then process with KSP one more time, it results with our
process
method getting called with empty sequences for "new files" and "all files" both. This looks like an empty project to us, resulting in us generating a final file which indicates that no pages were found. Are we supposed to somehow detect this case and skip our processing? Or should our
process
and
finish
method not have been triggered by KSP in this case? (Currently using
2.0.10-RC2-1.0.24
)
t
This use case is missed by the spec, where it is unclear about the behavior when an output is based on nothing. An easy fix in KSP is to invalidate aggregating outputs unconditionally. Skipping the processor won't work; There are cases the processors must be called for other valid reasons, yet the input for such output is still (mistakenly) empty. As a workaround before the fix in KSP, is it possible to postpone the writing of backend.json until there is something non-trivial to write?
d
The bug is not a big deal for us, so we don't need a workaround. We just told the user to clean and recompile. However, if it was an actual KSP bug, we worried it affected a bunch of other users (or potentially would) which is why we reported it.
🙏 1
So in the next release, what will happen? Will the processor be triggered with all files? Or just not triggered at all?
t
It'll be triggered with all files
d
So the dev who is helping me with KSP had a question -- take a look at this old thread from two years ago: https://kotlinlang.slack.com/archives/C013BA8EQSE/p1650650502293889
For aggregating dependencies, is it correct to assume that the deletion of a source file will only trigger KSP processing if that source file is from the list of dependencies?
Yes
Does that imply we should be skipping the processor entirely here?
t
It's not always possible. It's feasible in this particular case, but not if the deleted file is relevant for another output. In that case, the processor has to be called around the output that depends on the deleted input.
👍 1
Your processor would then try to generate an empty backend.json
As an optimization, we can skip calling processors when the input is empty. However, in general cases we have to supply all inputs
d
Thanks, we were just curious
Your fix should be fine in our case -- worst case we just do a bit of redundant work
But the reason we were asking about this is he framework we are building pushes being into using a live reloading environment (i.e.
gradle --continuous
) so any compilation step we can skip is a win
But if it's complicated it should be fine. Certainly better than the current situation which is broken.