realm / realm-java

Realm is a mobile database: a replacement for SQLite & ORMs
http://realm.io
Apache License 2.0
11.45k stars 1.75k forks source link

Support Kotlin Symbol Processing (KSP) #7310

Closed mannodermaus closed 2 days ago

mannodermaus commented 3 years ago

Describe your problem or use case

Kotlin Symbol Processing (KSP) is a joint effort by Google & JetBrains and seeks to provide an API for building compiler plugins. Compared to KAPT, annotation processors that use KSP can run up to 2x faster.

Describe the solution you'd like

Introduce a sibling artifact to the realm-annotations-processor which leverages the performance and benefits of KSP over KAPT for Kotlin-based projects.

rorbech commented 3 years ago

@mannodermaus Thanks for the input. We are aware that KSP has been promoted to alpha, but have not yet evaluated/looked into replacing the current Realm annotation processor for Kotlin with it.

kzotin commented 2 years ago

Just FYI, KSP is now stable!👀

https://android-developers.googleblog.com/2021/09/accelerated-kotlin-build-times-with.html

mannodermaus commented 2 years ago

FWIW I was trying to help out here and look into a potential migration to KSP as an external contribution, but frankly I was unable to get Realm compiled on my machine. 🙈 Is there a rough roadmap or guidance of Realm regarding this feature?

mannodermaus commented 2 years ago

The Realm Kotlin SDK exists now. Is it safe to assume that KSP wouldn't be added for the older Java SDK, esp. since the new one seems to be built as a compiler plugin instead?

rorbech commented 2 years ago

Yes, we do not have any immediate plans to rewrite the code generation parts of realm-java with KSP. KSP would only work for Kotlin code and doesn't support transforming existing code, so wouldn't suffice for our full use case. This is also why we use compiler plugins in realm-kotlin.

Kardelio commented 4 months ago

Heyoooo <3 any updates on this front? Just curious as we are moving our entire project over to ksp and the last bit is the realm of it all. Not meant to be a pressure or pain, just curious if this work (realm to ksp instead of kapt) is going to happen at some point in the future?

Just for reference, i changed our module containing realm into ksp and got this error, after searching on the net i found that the underlying generation uses kapt, which led me here :)

An exception occurred applying plugin request [id: 'realm-android']
> Failed to apply plugin 'realm-android'.
   > Configuration with name 'kapt' not found.

For now the android docs say kapt and ksp can run in parralel together so ill add kapt plugin back to this module and keep an eye on this issue <3

Thank you all btw for your amazing work on realm, just needed to be said <3

sailorseashell commented 1 month ago

I'd like to add my voice to asking for updates on this. We are also trying to move our project completely over from kapt and this is the last holdout!

brucemax commented 1 month ago

As always, the only thing that slows down our project from innovation is the realm :(

Deni-H commented 1 month ago

Any update on this?

kzotin commented 2 days ago

Since the release of Kotlin 2.0, the importance of migration to KSP increases due to:

w: Kapt currently doesn't support language version 2.0+. Falling back to 1.9.

nirinchev commented 2 days ago

We don't have plans to add new features to realm-java and instead recommend that you migrate to our native kotlin SDK: https://github.com/realm/realm-kotlin.