mirror of
https://github.com/apple/pkl.git
synced 2026-01-13 15:13:38 +01:00
[PR #196] [CLOSED] Implement support for KotlinX Serialization #442
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/apple/pkl/pull/196
Author: @sgammon
Created: 2/18/2024
Status: ❌ Closed
Base:
main← Head:feat/issue-186📝 Commits (3)
a89e910Fix droppedimplementSerializableflage9638ddAdd setting for Kotlin package to codegena1613a1Implement support for KotlinX Serialization📊 Changes
29 files changed (+874 additions, -228 deletions)
View changed files
📝
bench/gradle.lockfile(+22 -14)📝
buildSrc/build.gradle.kts(+1 -0)📝
buildSrc/src/main/kotlin/pklKotlinLibrary.gradle.kts(+1 -0)📝
docs/gradle.lockfile(+10 -10)📝
gradle/libs.versions.toml(+4 -3)📝
pkl-cli/gradle.lockfile(+45 -17)📝
pkl-codegen-java/gradle.lockfile(+41 -13)📝
pkl-codegen-kotlin/gradle.lockfile(+44 -13)📝
pkl-codegen-kotlin/pkl-codegen-kotlin.gradle.kts(+4 -0)📝
pkl-codegen-kotlin/src/main/kotlin/org/pkl/codegen/kotlin/CliKotlinCodeGeneratorOptions.kt(+15 -2)📝
pkl-codegen-kotlin/src/main/kotlin/org/pkl/codegen/kotlin/KotlinCodeGenerator.kt(+42 -6)📝
pkl-codegen-kotlin/src/test/kotlin/org/pkl/codegen/kotlin/KotlinCodeGeneratorTest.kt(+242 -4)📝
pkl-commons-cli/gradle.lockfile(+40 -12)📝
pkl-commons-test/gradle.lockfile(+39 -11)📝
pkl-commons/gradle.lockfile(+40 -12)📝
pkl-config-java/gradle.lockfile(+19 -11)📝
pkl-config-kotlin/gradle.lockfile(+44 -13)📝
pkl-core/gradle.lockfile(+18 -11)📝
pkl-doc/gradle.lockfile(+46 -26)📝
pkl-doc/pkl-doc.gradle.kts(+1 -1)...and 9 more files
📄 Description
This change adds support for a new code-gen argument,
implementKSerializable, which results in the annotationkotlinx.serialization.Serializablebeing added todataclasses during codegen.New discussion opened here
Approach
A new argument has been added to the Kotlin code generator and Gradle plugin, at
implementKSerializable. When set totrue, the code generator annotates data classes with@kotlinx.serialization.Serializable.If both JVM serialization and KotlinX serialization are enabled, the code generator properly qualifies with
java.io.Serializableandimport kotlinx.serialization.Serializable. The two are optional and usable independent of each other.For the moment, this is filed on top of these other PRs to avoid conflicts, since they all touch the code generator; these can be rebased away, though:
Transitive dependency needs
Users of this code will need to include the KotlinX Serialization compiler plugin in their build, with:
And a dependency on KotlinX Serialization Core, for the annotation, at version
1.5.0or greater:I stopped short of adding an
apidependency to Pkl's Kotlin runtime library to avoid adding it to consumer dependency graphs downstream. This could easily be added, though, if preferable. Gradle will generally select the newest available version in a user's build, but builds that don't include KotlinX Serialization already will have to download it if it is added this way, of course.IDEA and Kotlin warn appropriately if the compiler is not included.
Changelog
SerializableannotationimplementKSerializableargument🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.