-
Notifications
You must be signed in to change notification settings - Fork 877
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
[Kotlin] Migrate kapt to ksp #3284
Comments
tschuchortdev/kotlin-compile-testing#302 (comment)
For those that want to use the new Kotlin compiler it seems like we may be out of luck until this is solved. |
https://blog.jetbrains.com/kotlin/2023/02/k2-kotlin-2-0/ looks like K2 will be stable in Kotlin 2.0! We'll have a problem when Kotlin 2.0 is released? |
The current state is very worrying indeed. KASP was 'just' very slow and throw constant warnings with QueryDSL, but with K2 it will appearently stop working alltogether. The problem might be, that the QueryDSL team is not willing to make any Kotlin-specific changes, with is perfectly understandable. But what is the strategy for dealing with this situation? Is there any? |
I can mentioned that i did end up writing a very short and simple QueryDSL symbol processor. https://github.com/querydsl/querydsl/tree/master/querydsl-kotlin-codegen/src/main/kotlin/com/querydsl/kotlin/codegen I wanted to see if i could try to contribute with my KSP skills. I don't know if i am the right person to write a feature-complete processor for QueryDSL, |
Ok, then we have a real problem here and should eventually really move away from QueryDSL. Looks like a dead-end. Was hoping, that KAPT -> KSP would be straight forward but if its that hard, than that's basically it. :( |
@jwgmeligmeyling Do you have anyone that could write a kotlin symbol processor? My vacation is coming up so i will have some time to spare, If i were to make an attempt at this then is there any place where i could get a full overview over all the features that i would need to support? |
You actually don’t need Q classes to use Querydsl (for example use query aliases) nor you have to rely on APT to generate Q classes for you.
No, haven’t had the need for it yet. I don’t use Kotlin in my data layers personally.
Codegen is well unit tested. I think you can just migrate the example domain types and expected generated code to kotlin and develop this in a TDD way. I am confident you’ll be very complete by the end of it 😄 Just having access to the classname, attribute names and types should get you pretty far. Its only with things like custom annotations (like QueryDelegate or QueryEntities) where things get a bit interesting. Mostly because here configuration from other source files affects the output of conversion from other source files, meaning special attention is needed for parallelization and partial compilation. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hi, |
Hey |
What is the estimated amount of work? |
What i currently have is a KSP project that finds all classes annotated with Entity and writes a Q class. I think that for something that will be used by more people i will need to support the existing available configurations in QueryDSL. I think the most viable approach here may be to copy querydsl-apt module and write something as close as possible to this implementation with ksp. If that becomes very time consuming or a lot more challenging that expected then i may opt for a simplified version that i write from scratch with more limited support and has its own set of configurations similar to what i'm using today. I'm spending the next few days to look into this now. |
Reached the first milestone now. I made an attempt to directly translate that code into Kotlin and replace APT stuff with KSP stuff, That attempt was abandoned for 3 reasons.
So i wrote big chunks of the logic in querydsl-apt from scratch. @jwgmeligmeyling Could this be submitted as a pull request?
|
Is there any movement in this issue? Or is there another issue or alternative solution? I'm on a project that is delaying Kotlin k2 upgrade because of this. Using querydsl with spring-data-rest for automatic dynamic filter queries. |
Hey, thanks for the message. I unburied the project now so i will take some time next week to try to fix it up into a state where it could be published. As i mentioned in my last message there is some challenges when it comes to porting this. Luckily my project will only deal with generating code so it should be easy to spot and report issues. If you are using settings from QueryDSL for the purpose of generating code then please list them here. |
Hello, @Almazon, I use the actual querydsl-apt with kotlin k2 |
Stupid question maybe, but if I generate Java Q-classes instead, are they any expected issues to use them from a Kotlin project? Does QueryDSL use any Kotlin enhancement (like direct support of lambdas etc.?) |
@IceBlizz6 Nice to see someone tackling the problem! Since this project is kind of inactive (or at least slow in movement), you should try to integrate the KSP handling to the OpenFeign fork instead. The development there is more than active. |
Thank you for the suggestion. i found that project here: I can probably start by creating KSP for the fork, then if someone needs it for this original querydsl project then i can probably do that too. |
@spyro2000 |
https://github.com/IceBlizz6/querydsl-ksp I got it working and have uploaded it to github. I made 2 separate attempts at this, the first attempt tried to use and apply all of the existing querydsl configurations like picking up serializers from the classpath, the second one was more of a implementation from scratch based on observation of how the kotlin serializer worked. It supports options for including/excluding classes and packages, prefixing and suffixing classes/packages. I will post here again when i get the upload working and have published the readme. |
Should be good now. I tested it on my own big project with hundreds of entities and a few other projects and it seems fine but there may be cases that aren't covered so please test it and tell me if things aren't working. |
Hi, thank you. I found some issues. I added it on github. |
@IceBlizz6 hi, would you be able to add your ksp annotation processing to https://github.com/OpenFeign/querydsl? This is a fork of querydsl that is being actively maintained |
Hey @JYC11 Could you check if my latest version works for you? |
On reading this again i realize i may have misunderstood, did you mean to add a pull request to add my code into the fork and cooperate with that author? |
@IceBlizz6 I'll check now if your project works with the fork! Yes I initially meant to ask if it's possible for you to add a pull request to the fork and cooperate with the author. Thanks for your contribution either way |
Why the new feature should be added
kapt is in maintenance mode, should move away from deprecated plugin - https://kotlinlang.org/docs/kapt.html
kapt is in maintenance mode. We are keeping it up-to-date with recent Kotlin and Java releases but have no plans to implement new features. Please use the [Kotlin Symbol Processing API (KSP)](https://kotlinlang.org/docs/ksp-overview.html) for annotation processing. [See the list of libraries supported by KSP](https://kotlinlang.org/docs/ksp-overview.html#supported-libraries).
Comparison/Benefits:
https://kotlinlang.org/docs/ksp-why-ksp.html#comparison-to-kapt
How the new feature should work
queryDSL kotlin is currently using kapt to generate the code, this feature will utilise KSP to generate code instead. Might have performance gain there too.
The text was updated successfully, but these errors were encountered: