Hello, I'd like to use Room in a Kotlin Toolchain ...
# kotlin-toolchain
l
Hello, I'd like to use Room in a Kotlin Toolchain project. I haven't found any examples online or in the repo, but this test project in Kotlin Toolchain sources, where the iOS project is disabled, vaguely referencing a KSP issue. It's more than 2 years old though… I have a hard time imagining that it wasn't addressed since then, but I don't know what the issue is even about (haven't tried yet). github.com/JetBrains/kotlin-toolchain/blob/…/project.yaml#… Is it possible to have a more precise reference to the issue (like a link) that prevents it from working on iOS with Kotlin Toolchain?
✅ 2
u
Hello, Louis! Coincidentally, I tried setting up the KMP project with Room an hour ago for completely different reasons 😄 I haven't encountered any issues with iOS from the get-go and managed to have a working sample app with the persistence backed by Room. I have used Room 3.0.3 and the Kotlin Toolchain 0.13.0. The issue referenced in the test is github.com/google/ksp/issues/1854 which was resolved almost 2 years ago. We'll actualize the test (thanks for bringing it to our attention) and most likely add the Room usage to our examples (and perhaps to the docs). For the time being, Room is actually used as an example in our KSP docs which might be of some help. Nevertheless, feel free to ask any questions and tell us about any problems that you might encounter along the way.
l
What a coincidence! Thank you, will try. BTW, do you know if this boilerplate is still required? github.com/JetBrains/kotlin-toolchain/blob/…/module.yaml#…
u
Yeah, I'm afraid it is required at the moment to avoid flaky builds. The reason for that is that Room schema is generated by each compilation in parallel and multiple KSP processes can try writing into the same file. We've seen it happening in our tests from time to time. Room Gradle plugin works it around by separating the outputs and then aggregating them via a single task. We'll try thinking whether we can improve this scenario.
👍🏼 1
l
Is the SQL auto-complete also missing on your end?
u
What kind of completion do you mean? In theory, it might be that we need to require something in the IntelliJ project.
l
For the SQL in the
@Query
annotations in DAOs
It's highlighted like a plain string on my end, unlike with Gradle projects
u
Hm, I didn't manage to get the highlighting for Gradle as well but I'll look into it, thanks!
blob thinking fast 1
Ah, I think there is no code insight support for Room 3 neither in IJ nor in Android Studio. I'm not sure it's easily fixable on our side—the changes should happen in the Android plugin for IntelliJ. If you use Room 2, then the SQL support seem to work for both Gradle and KTC.
l
Wow, right, we hadn't noticed, but yes, it's an Android Studio issue (Rabbit 1 on my end). We lost SQLite syntax highlighting + autocompletion for the Gradle project we migrated to Room 3.
😔 1
🙏 2
👍 1