Some questions regarding incremental compilation. ...
# ksp
o
Some questions regarding incremental compilation. Details in thread.
1. If the list of a generated file's dependencies is only known after creating the file, is using
Copy code
codeGenerator.createNewFile(
        dependencies = Dependencies(aggregating = true),
        // ...
    ).use { output ->
        // ...
    }
followed by
Copy code
codeGenerator.associateWithClasses(
        classes = sourceClassDeclarations,
        // ...
    )
the correct way to do it? 2. 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? 3. Is preventing KSP re-processing when deleting a source non-dependency the only optimization available for aggregating dependencies (as any new file or changing any existing file – dependency or not – must always trigger KSP)?
t
1. Yes 2. Yes 3. Kind of. You are right that the only situation that an aggregating output is up-to-date is the deletion of unrelated sources (besides nothing touched at all). On the other hand, when triggering re-processing, sources that are known unrelated won't be passed to processors and reprocessing of those unrelated sources are avoided.
🙏 1
o
Thanks for the insights! Your addition regarding point 3 makes dependency registration seem valuable even in the aggregation case where file deletions are a rare event.