kotools / types

Explicit types for Kotlin Multiplatform.
https://types.kotools.org
MIT License
90 stars 6 forks source link

πŸŽ‰ New `kotlinx-serialization` Gradle subproject #602

Closed LVMVRQUXL closed 7 months ago

LVMVRQUXL commented 8 months ago

πŸ“ Description

We want to extract our integration with the kotlinx.serialization library from the root Gradle project to a new types-kotlinx-serialization subproject. This subproject should document clearly our consumers should use it (here's an example on another Kotlin library).

Basically, consumers should be able to configure the serialization of types from Kotools Types with minimum effort by:

  1. Adding the dependency in the Gradle build script of their project. Here's an example using the Kotlin DSL in Gradle:
implementation("org.kotools:types-kotlinx-serialization:0.1.0") // The version is fictive.
  1. Importing the serializers module needed from Kotools Types when configuring the serialization format. Here's an example of using all serializers from Kotools Types using the JavaScript Object Notation (JSON) format from kotlinx.serialization:
val format: StringFormat = Json { serializersModule = KotoolsTypesSerializers.all }
val encoded: String = format.encodeToString(Zero)
println(encoded) // 0
val decoded: Zero = format.decodeFromString(encoded)
println(Zero === decoded) // true

After resolving this issue, the Application Programming Interface (API) should at least provide a KotoolsTypesSerializers type with the following structure:

object KotoolsTypesSerializers {
    val all: SerializersModule
    // More specific modules...
}

βœ… Checklist

LVMVRQUXL commented 7 months ago

Instead of moving serializers to this new subproject for existing types, we will introduce new serializers in this subproject only for new types defined in the org.kotools.types package. This way, we will introduce changes incrementally without breaking the old API.

LVMVRQUXL commented 7 months ago

For including this new Gradle subproject in the API reference with a version selector, we need to regenerate it for each version... This is out of scope of this issue and should be done in an another one.