question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Annotated symbols not found when running from command line

See original GitHub issue

Hi, 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:closed
  • Created a year ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
neetopiacommented, May 4, 2022

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

0reactions
Gzernovcommented, May 5, 2022

I also created playground project from scratch for maven and it works just fine. I’m probably missing something in my main project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Maven build cannot find symbol when accessing project ...
I'm using project lombok for the first time and I have problems compiling the project via maven when I run ...
Read more >
How to Resolve The Cannot Find Symbol Error in Java - Rollbar
The cannot find symbol error refers to a situation where the Java compiler is unable to find the symbol associated with a given...
Read more >
javax.annotations cannot find symbol
All of a sudden, Intellij (version 2018.1.5, Linux) says it cannot find symbol for classes in javax.annotation (e.g. javax.annotation.
Read more >
Intel® VTune™ Profiler Command Line Interface
Get a comprehensive overview of Intel® VTune™ Profiler for performance analysis. Understand workflows and tuning methodologies to profile serial and ...
Read more >
The java Command - Oracle Help Center
In case a matching quote is not found, the launcher will abort with an error message. @ -files are supported as they are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found