Annotated symbols not found when running from command line
See original GitHub issueHi, I’m trying to run KSP from command line following the docs
I’m running the script from above on my source files, and the code resolver.getSymbolsWithAnnotation(MyAnnotation::class.java.canonicalName).filter { !it.validate() }
returns empty list.
When I compile it using maven everything works as intended.
Any idea why does it happen?
With this snippet I’m trying to get annotations on classes I’m interested in, and it returns list of correct annotations
Code:
resolver.getAllFiles().filter { it.fileName.contains("MyFile") }.forEach { debug("$it ${it.declarations.filter { d -> d is KSClassDeclaration }.map { c -> c.annotations.toList() }.toList()}") }
Output:
info: [ksp] File: MyFile.java [[@Component, @Primary, @MyAnnotation]]
(To clarify, I have mix of java and kotlin files in the project, but resolver.getSymbolsWithAnnotation
ignores both of them. Snippet above returns correct list for all files. isAnnotationPresent
also returns false on command line env and true on mvn env)
Issue Analytics
- State:
- Created a year ago
- Comments:9
Tried playground locally with cmd mode, still can’t seem to reproduce your issue, please check attached playground, to run KSP, download and unzip kotlinc 1.6.21 into root directory of the playground and run
rm -rf out && ./run.sh -cp ./test-processor/build/libs/test-processor-1.0-SNAPSHOT.jar workload/**/*.java
playground.zip
I also created playground project from scratch for maven and it works just fine. I’m probably missing something in my main project.