When `aggregating` of `Dependencies` is set to `tr...
# ksp
s
When
aggregating
of
Dependencies
is set to
true
, will even file changes that are not related to a particular annotation be reprocessed?
Copy code
val symbols = resolver.getSymbolsWithAnnotation("Factory")
symbols.forEach { symbol ->
    val ksClass = symbol as KSClassDeclaration
    val packageName = ksClass.packageName.asString()
    val className = ksClass.simpleName.asString()

    val file = codeGenerator.createNewFile(
        Dependencies(true, ksClass.containingFile!!), // <--
        packageName,
        "${className}Factory"
    )

    // generate code ...
}
When set to false, will only the changes in the file passed in the second argument reprocess?
Dependencies(false, ksClass.containingFile!!)
Dependencies(false, files)
=> Reprocess when any file changes. Ignore the file passed to the parameter. •
Dependencies(true, files)
=> Reprocess only when the file passed to the parameter changes. Is this right?
t
The dependencies are calculated by the association of input and output files, instead of annotations. Note that it is a many-to-many relation. The dirtyness propagation rules due to input-output associations are: 1. If an input file is changed, it will always be reprocessed. 2. 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. 3. All input files that are associated with one or more aggregating outputs will be reprocessed. In other words, if an input file isn't associated with any aggregating outputs, it won't be reprocessed (unless it meets 1. or 2. in the above). Reasons are: 1. If an input is changed, new information can be introduced and therefore processors need to run again with the input. 2. An output is made out of a set of inputs. Processors may need all the inputs to regenerate the output. 3.
aggregating=true
means that an output may potentially depend on new information, which can come from either new files, or changed existing files.
aggregating=false
means that processor is sure that the information only comes from certain input files and never from other or new files.
s
Oh, I got it.
Dependencies(true)
=> Only changed files will be input.
Dependencies(true, files)
=> Changed files and associated files will be input.
👍 1
Thank you so much! It was very helpful!