-
Notifications
You must be signed in to change notification settings - Fork 636
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
1.7.2 builtin UUID serializer breaks compatibility with gradle #2803
Comments
Hm, normally, 1.7.x versions shouldn't work with Kotlin 1.9 because the compiler should reject them (release notes explain why. Does Gradle uses 2.0.20 compiler to compile buildscript, but then Kotlin 1.9 to run? Why there are no compiler errors about |
Good question. But regardless of what gradle compiles buildscripts with, gradle plugins can compile with serialization 1.7.X and kotlin 2.0.20 and run fine on gradle 8.8 until serialization 1.7.2. |
Minimal reproducer: import kotlinx.serialization.serializerOrNull
buildscript {
dependencies {
classpath("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.2")
}
repositories {
mavenCentral()
}
}
@OptIn(kotlinx.serialization.InternalSerializationApi::class)
println(Float::class.serializerOrNull())
I believe Gradle uses 1.9 to compile and forces 1.9 at runtime. Because there is n+1 forward compatibility, it compiles fine.
Looks like the error is triggered from the serialization compiler plugin? It might not be always applied. |
A very important thing to serialize is that in gradle |
same error kotlin 2.0.10 |
I have the same problem: |
I fixed it just by changing the version: org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0 |
@sandwwraith i try to use uuid with
[plugins] |
Gradle ships with a specific Kotlin version, and Gradle version 8.8 is the newest gradle version that is verified compatible with kotlin 2.0.20. However, Gradle 8.8 itself in its buildscript and settings script runs Kotlin version
1.9.22
as can be seen by printingKotlinVersion.CURRENT
in a build.gradle.kts script.If a gradle plugin author tries to include serialization plugin 1.7.1, everything works fine. But upon upgrading to 1.7.2, we are immediately hit with a runtime error during a gradle build:
This error is unavoidable, as the serialization plugin attempts to load the new kotlin UUID class regardless of whether or not the consumer is trying to serialize or deserialize a UUID.
To Reproduce
Expected behavior
I think its ok for consumers of get a runtime error if they try to serialize or deserialize a kotlin.uuid.UUID in a gradle build. In that case, of course the UUID class will not be available. But for this whole library to fail seems unnecessary. Making the loading of the UUID class conditional on whether or not it is used would retain backwards compatibility in the library.
The text was updated successfully, but these errors were encountered: