when trying to extract out my annotations off a class i get this (using 2.0.0-1.0.21): `ERROR CLASS...
e
when trying to extract out my annotations off a class i get this (using 2.0.0-1.0.21):
ERROR CLASS: Symbol not found for Entity
I have this code:
Copy code
val annotations = klass.annotations.toList()
and in that list, the count is correct but if I try to extract out info I get null:
Copy code
it.annotationType.resolve().declaration.qualifiedName?.asString()
that
declaration
returns a
KSErrorTypeClassDeclaration
. It seems like ksp can't find the classdef for that type but it's definitely on my test's classpath. any idea what's going wrong?
klass
is a
KSClassDeclaration
t
Did you use
ksp.useKSP2=true
? If not, is this a MPP project?
e
i'm running ksp programmatically atm not from, say, gradle.
basically mimicking the
KspJvmMain.kt
approach
t
How is the classpath setup?
KSPConfig.libraries
? If the annotation class is defined in yet-to-be-compiled Java sources, a common pitfall is directories not matching package name. It also has to be within the same compilation unit, instead of libraries (if not compiled yet).
e
well, the annotation is defined in
src/main
but i'm running my processor from
src/test
so let me try and clean that up a little bit. this should all (mostly) be in
src/main
anyway
ok. so that didn't help. 😕
well, now, those annotations are actually defined in another maven module (and installed to the local repo) and that module is included on the classpath. so I'm not sure what else I need to tell ksp in order to find them.
would the (JPMS) module name matter? because my stuff is not in a module but the configuration requires a module name so I gave it ""
t
Did you put it in
KSPConfig.libraries
?
e
where would I put that?
oh, i see. is that exposed in the builder?
👀
e
i owe you a beverage of your choice! that was it.
i went looking for that yesterday and completely overlooked it. Thanks.
t
Glad to help!