I got a weird situation on an Android app. I have...
# ksp
b
I got a weird situation on an Android app. I have a build as such: •
library
depends on
feature
library
also depends on a custom ksp processor The problem I'm running into is that when I make a change in the
strings.xml
file in
feature
, the first run generates the source files fine from my ksp processor, but the second run fails due to the generated files being deleted and not generated. It seems to be an issue with incremental builds, because turning incremental off will cause everything to generate just fine. More in 🧵:
I did some debugging on my ksp processor, and I noticed that on incremental builds, there are no symbols to process. Snippet of code for reference:
Copy code
@OptIn(KspExperimental::class)
    override fun process(resolver: Resolver): List<KSAnnotated> {
        val symbols = resolver.getSymbolsWithAnnotation(
            annotationName = AppLifecycleSingleton::class.qualifiedName.toString(),
        ).filterIsInstance<KSClassDeclaration>()

        if (symbols.none()) { // returns true on incremental builds
            return emptyList()
        }

        // Goes here on first run and with incremental ksp turned off
        val appLifecycleSingletons = symbols.map { it.accept(appLifecycleSingletonVisitor, Unit) }
            .flatten()
Any advice or suggestions appreciated.
j
strings.xml
is not source code, so how would KSP know to re-run if it changes? Are you attempting to use the R.string values from within KSP?
b
No, which is why this issue is so confusing. I also noticed that Hilt removes and regenerates their generated sources.