elihart
09/16/2021, 7:13 PMksp.incremental.log=true
(very helpful, btw!) so I think I understand what is going on.
My generated file (aggregating) relies on both a symbol in sources acquired with getSymbolsWithAnnotation
and a set of classes on the classpath (via getDeclarationsFromPackage
). The file’s originating elements reflect this, as do the ksp incremental logs, so the dependencies seem correctly understood by KSP.
My problem is that when there are classpath changes and the processor incrementally runs, KSP sees that only the classpath files changed and does not consider my source file as dirty, so my call to getSymbolsWithAnnotation
does not return anything. This is problematic because I need both the symbol in source as well as the classpath files to generate my output file, and this fails when I cannot get the source symbol with getSymbolsWithAnnotation
.
I understand why KSP does this, and it is optimal for some cases, but it makes generating a file that depends on both sources and classpath difficult - I think I would have to work around this by manually getting all files and parsing them.
Would it be reasonable instead for KSP to look at the set of inputs to a generated file, and if any one of those input is a classpath change then consider the rest of the inputs as dirty as well? according to the docs this is already done with sources, but maybe not for classpath changes?
Propagation by input-output correspondence: If a source file is changed or affected, all other source files having some output in common with that file are affected.
Ting-Yuan Huang
09/16/2021, 9:27 PMTing-Yuan Huang
09/16/2021, 9:43 PMcreateNewFile
, what's the dependencies (list of KSFile
) passed in to account for getDeclarationsFromPackage
? Or do you mean this is the workaround you would do?elihart
09/16/2021, 9:49 PMcreateNewFile
I believe for the classpath dependencies I use the KSClassDeclaration
from getDeclarationsFromPackage
and pass the KSClassDeclaration.containingFile
(it’s done through XProcessing)
In the kspSourceToOutputs.log
it shows the source name as <AnyChanges is a virtual file; DO NOT USE.>:
Ting-Yuan Huang
09/16/2021, 10:47 PMcontainingFile
is always null
for classes from classpath. We may need some addition in the API to account for changes from classpath.Ting-Yuan Huang
09/16/2021, 10:50 PMAnyChanges
is a placeholder for propagating dirtiness for sources of aggregating outputs. We can use it to fix the issue here, only for aggregating outputs.Ting-Yuan Huang
09/16/2021, 10:53 PMassociate(decl: KSDeclaration)
elihart
09/16/2021, 10:54 PMTing-Yuan Huang
09/16/2021, 11:13 PMyigit
09/16/2021, 11:48 PMTing-Yuan Huang
09/16/2021, 11:52 PMTing-Yuan Huang
09/16/2021, 11:54 PMelihart
10/22/2021, 7:50 PMTing-Yuan Huang
10/22/2021, 8:03 PMelihart
10/22/2021, 9:29 PMelihart
10/22/2021, 9:31 PMassociateWithClasses
in XProcessing but the Kotlin update seems harderyigit
10/22/2021, 9:47 PMyigit
10/22/2021, 9:47 PMelihart
10/22/2021, 11:34 PM