what up guys! is there any way to get not dirty cl...
# ksp
u
what up guys! is there any way to get not dirty classes in ksp(maybe in resolver)? incremental is enabled
d
what is the use case for this?
u
well I need to get annotation to make new Implclass but since incremental build is enabled I can't get the annotation for more information there are two spreate class I have, A class and B class so I'm tring to generate B class impl class but to make BImpl that class have to check A class annotation (A class's annotation has class array and it is Bimpl class dependency)
e
Are you setting up your dependencies correctly? 🤔
d
Like Efeturi said, seems like you would need to reprocess the singleton class whenever you reprocess the annotated class that is an input for a child class. So you can specify your singleton class as a dependency when you use the code generator : https://github.com/google/ksp/blob/main/api/src/main/kotlin/com/google/devtools/ksp/processing/CodeGenerator.kt#L60 Or if you use KotlinPoet https://square.github.io/kotlinpoet/interop-ksp/#incremental-processing Then, when the input for the child class is dirty, the singleton class will also be considered dirty:
If an input file is changed, and it is associated with an output, then all other input files associated with the same output will also be reprocessed. This is transitive, namely, invalidation happens repeatedly until there is no new dirty file.
https://kotlinlang.org/docs/ksp-incremental.html#how-it-is-implemented
d
@David Rawson I'm having the same problem. Suppose that the singleton class is S, and A and B are the targets for which child classes will be created. As you said, I added S as an input when creating subclasses of A and B. However, when A is changed, only S and A are expected to become dirty, but in the process of propagating dirty internally, B, which takes S as an input, also becomes dirty. Therefore, in order to operate as an isolate process, there is a limitation that the entire processor can only operate as an aggregate process, even though options (S class) through code are required. To solve this problem, I wrote the fully qualified name of the S class with options in a separate file when processing the S class. After that, when incrementally processed, the KSClassDeclation of the S class was obtained from the file, and the option information in the annotation was imported and processed. Can you advise if there is a better way?
d
@Donghwan to me, your generated A subclass output is still isolating and still affords allows optimisations even if reprocessing A causes reprocessing of B (through S). This is because your output is isolated from having to change due to new information outside the registered inputs. If I understand correctly, having only changes to A affect the subclass A output would not normally be possible in a processor design where changes to S affect the A subclass output and the B subclass output. Making the processor aggregating would provide even less of an opportunity for optimisation since we would be saying that the output can collect new information from outside even the registered inputs (for example, in some unregistered input file C or D). I am not sure what to think about the workaround with writing S to a text file.
d
@David Rawson
Copy code
having only changes to A affect the subclass A output would not normally be possible in a processor design where changes to S affect the A subclass output and the B subclass output.
Why is the processor unable to do this part? Subclass A depends on A and S, and subclass B depends on B and S. It is correct that subclass A and subclass B should be reprocessed when S is changed, but I think subclass B should not be reprocessed when A is changed, even if S is shared as a common input. Thank you for answer
d
@Jiaxiang I am sorry I am unable to answer this above question from @Donghwan Is it because it is not feasible to make distinctions like “dirty in the context of output A but clean in the context of output B”?
j
@Ting-Yuan Huang can you help with this question?
t
An output is made out of a set of inputs. In general, processors may need all the inputs to regenerate the output. Of course, a processor may be aware of the us case mentioned in the above discussions, but from API design