-
Notifications
You must be signed in to change notification settings - Fork 304
KSP2 Generated .class
files are not added to the classpath
#2365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you share more details on how / when the classes are generated and how / when they are loaded? E.g., are you loading the classes generated in a previous round, different Gradle tasks or different Gradle modules, etc. |
We use this call to write a class:
And we expect those classes to be present on the runtime classpath at the same module. Micronaut annotation processor processes beans definitions etc. and generates metadata bean definitions classes that are loaded at the runtime using the service loader feature to create the bean context. Currently the service loader META-INF definitions are present at the classpath but not the generated classes. |
@ting-yuan can you fix this please. This has completely broken Micronaut's KSP integration. |
If the generated class isn't needed within processing rounds, i.e., generated in round N and resolved in round N + K, a tentative fix is here. It'll be available in 2.0.1, or in the nightly build the day after the PR is merged. |
it is only needed at runtime in the application to my knowledge |
@ting-yuan We don't need to access the written class file in the annotation processor. We need to have it present at the runtime classpath. |
Thanks for clarifying. #2405 should fix this. Please reopen if it doesn't work for you. |
Uh oh!
There was an error while loading. Please reload this page.
I'm trying to migrate Micronaut to use use Kotlin 2 and KSP2.
I see the files are generated but classes cannot be loaded by
Class.forName
.Do you have any idea what can be wrong?
Reading the class as file
getClass().getClassLoader().getResource(className.replace('.', '/').concat(".class"))
doesn't work. It looks like classes are not included on the classpath but the resources are added.The text was updated successfully, but these errors were encountered: