-
Notifications
You must be signed in to change notification settings - Fork 41.1k
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
Allow ConfigurationProcessor to work with Kotlin Symbol Processor #28046
Comments
Thanks for raising this.
My reading of that Kotlin issue is that KAPT does work with JDK 16+, but that it requires adding some JVM arguments to open up some of the JVM's internals to KAPT. Have I misunderstood the discussion? |
@wilkinsona You understood it better than I :) Yes, it's possible to break I know that adding an abstraction layer over processors can add in additional complexity, but it can also be a safer solution (also please note that KSP authors claim that it's up to 2x faster than java annotation processors). As with everything you should weigh your options as Spring maintainers. |
The underlying problem with KAPT has now been fixed and will be part of the Kotlin 1.6 release. Rather than supporting a third-party alternative which, to me at least, has an unclear relationship with Kotlin and JetBrains, I think we should focus our efforts on working via KAPT. Thanks anyway for the suggestion. |
Hi, @wilkinsona. |
@wilkinsona I asked about the relation of KSP and Kotlin: https://twitter.com/relizarov/status/1455452359669264384 So it looks like KSP is the way to go for Kotlin. |
Any updates? Kapt is horrible annotation processor, it will be great if spring will support ksp. I have all my backend on kotlin and I have to use Kapt and main problem is not even speed(but it's slow), kapt shadows errors constantly, invalidate build cache. |
Just for your information. |
When trying to update to Java 21, i run into an IllegalAccessError again
Since kapt keeps breaking every now and then, it would be really great if spring moved away from using it. |
I have been trying to use the usual workarounds on 21 with no success. If anyone has it working, please let me know. |
The fix will be backported to Kotlin 1.9.21, see https://youtrack.jetbrains.com/issue/KT-60507 |
Slightly offtopic: there is a chance you don't actually need the configuration annotation processor at all. If you use Intellij IDEA Ultimate (I don't think that Community ever supported Spring configuration code insight), starting from 2023.2 Intellij does not rely on the metadata generated by the Spring boot configuration annotation processor. Other IDEs still might require it. I want to share this, because I was completely unaware of this until today (despite working at JetBrains), and removing KAPT improved our clean build times by 36%, incremental build times by up to 50%. |
@AlexeyTsvetkov this still leaves the topic of the autoconfigure processor |
@deejay1 oh, I did not know about the autoconfigure processor. Still, the info above could be useful for those who only use the ConfigurationMetadataAnnotationProcessor ( |
I'd like to vote for some attention to this, it's already 3+ years since KAPT was deprecated. It's annoying to rely on this old, slow and error-prone processor. |
Also curious when we might expect to see support for KSP. |
I don't even think I can get configuration processor + KAPT working perfectly, it works to some extent but when I started to put nested config class and default values, didn't see what I expect. |
The problem:
Currently, ConfigurationProcessor is backed by Annotation Processing. In Kotlin annotation processors can be used thanks to KAPT. Sadly KAPT does not work with JDK 16+ ( https://youtrack.jetbrains.com/issue/KT-45545 ). For Kotlin there are other processors like KSP ( https://github.com/google/ksp ), yet they do not rely on Java Annotation processing.
Proposed solution:
Provide an abstraction layer on ConfigurationMetadataAnnotationProcessor that will allow plugging in other processors.
Additionally provide an adapter for KSP.
@sdeleuze
The text was updated successfully, but these errors were encountered: