Skip to content
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

Add build-time check for Kotlin compiler version and kotlinx.serialization plugin version compatibility #2393

Closed
SebastianAigner opened this issue Aug 3, 2023 · 7 comments
Labels

Comments

@SebastianAigner
Copy link
Member

What is your use-case and why do you need this feature?

Using incompatible versions between the Kotlin compiler and kotlinx.serialization plugin can result in obscure errors.

We recently encountered this in SebastianAigner/my-bird-app#2, which is a demo project accompanying one of our official YouTube videos:

While the video was using Kotlin 1.8.20, the template used was since been updated to Kotlin 1.9. Because at the time of writing, the installation snippets in the kx.serialization README still point to 1.8.20, it's easy to accidentally copy the wrong installation snippet, and end up in situations where you get error messages like io.ktor.serialization.JsonConvertException: Illegal input: Expected class kotlinx.serialization.json.JsonObject as the serialized body of kotlinx.serialization.Polymorphic<List>, but had class kotlinx.serialization.json.JsonArray.

Describe the solution you'd like

Build-time version equality check between the Kotlin and kx.serialization compiler plugin versions, and an error that contains information / instructions on how to address this (update the kx.serialization compiler plugin version).

@SebastianAigner
Copy link
Member Author

(initially brought up internally at https://jetbrains.slack.com/archives/C2WQKN6JV/p1690982388347429).

@ibrahimethemsen
Copy link

I ran into a similar issue and couldn't find an update for it. Any progress on this?

@smartkanak
Copy link

That's exactly why I landed here, was going to rebuild the demo project "my-bird" with Sebastian's Youtube video and googled for the error

@pdvrieze
Copy link
Contributor

This should probably be done in the compiler plugin (which I believe still uses youtrack)

@Ahtisham80005
Copy link

open -> gradle.properties and check Kotlin version Like this

kotlin.version=1.9.10

this version must same here
kotlin("plugin.serialization") version "1.9.10"

@pdvrieze
Copy link
Contributor

@Ahtisham80005 If you want to check this in gradle this would need to be done a bit more complex than looking at gradle.properties (there is no requirement to use that). The bigger challenge is to ensure that the library version is high enough that the plugin supports it.

@sandwwraith
Copy link
Member

Will be fixed by #2797

@sandwwraith sandwwraith closed this as not planned Won't fix, can't repro, duplicate, stale Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants