I’ve been migrating our internal annotation proces...
# ksp
p
I’ve been migrating our internal annotation processors to KSP and I’m having all sorts of trouble getting the aggregating one to work correctly incrementally. They’re a layer on top of Dagger that supports broadly similar things to Hilt or Anvil. It’s multi-round and uses symbols from both the classpath (via
getDeclarationsFromPackage
) and the current compilation unit, but is otherwise pretty simple. I reproduced a simplified, standlone version as a KSP integration test here - you can run it with
./gradlew integration-tests:test --tests 'com.google.devtools.ksp.test.BrokenIncrementalIT.*'
Any idea where I’m going wrong? Or am I running into bugs in KSP?
👀 1
t
Thanks for the repro case! Yes, this is a bug in KSP 😢 In short, the dirtiness isn't propagated properly and therefore
AppModule1
and
AutoIncludeModule_app_AppModule1
are incorrectly considered as clean*1. So they are not included in subsequent processing and therefore
getDeclarationsFromPackage
didn't return
AutoIncludeModule_app_AppModule1
. A workaround is to associate
AppModule1
to
MergedModule_AppMergedModule
manually. BTW, there is a missing association from
AppModule1
to
AutoIncludeModule_app_AppModule1
. This needs to be fixed in
AutoIncludeProcessor
. *1 They are dirty because
MergedModule_AppMergedModule
is dirty and it needs
AutoIncludeModule_app_AppModule1
, which depends on
AppModule1
❤️ 1
p
Thanks for taking a look! Are both tests failing for the same reason (the first one is adding a file to the current compilation unit, and the second to the classpath)?
BTW, there is a missing association from AppModule1 to AutoIncludeModule_app_AppModule1. This needs to be fixed in AutoIncludeProcessor.
Is this not enough? Kotlin Poet should be passing an appropriate
Dependencies
instance to
CodeGenerator
for me.
t
Ahh I missed this 🤦 Yes this should be good.
🙌 1