File tree Expand file tree Collapse file tree 3 files changed +26
-1
lines changed
src/main/kotlin/org/bundleproject/libversion Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 11plugins {
22 kotlin(" jvm" ) version " 1.6.0"
3+ kotlin(" plugin.serialization" ) version " 1.6.0"
34 `java- library`
45 `maven- publish`
56}
67
78group = " org.bundleproject"
8- version = " 0.0.2 "
9+ version = " 0.0.3 "
910
1011repositories {
1112 mavenCentral()
1213}
1314
1415dependencies {
1516 api(kotlin(" stdlib-jdk8" , " 1.6.0" ))
17+ api(" org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.1" )
1618}
1719
1820tasks {
Original file line number Diff line number Diff line change 1+ package org.bundleproject.libversion
2+
3+ import kotlinx.serialization.KSerializer
4+ import kotlinx.serialization.descriptors.PrimitiveKind
5+ import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
6+ import kotlinx.serialization.descriptors.SerialDescriptor
7+ import kotlinx.serialization.encoding.Decoder
8+ import kotlinx.serialization.encoding.Encoder
9+
10+ class Serializer : KSerializer <Version > {
11+ override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor (" version" , PrimitiveKind .STRING )
12+
13+ override fun deserialize (decoder : Decoder ): Version {
14+ return Version .of(decoder.decodeString())
15+ }
16+
17+ override fun serialize (encoder : Encoder , value : Version ) {
18+ encoder.encodeString(value.toString())
19+ }
20+ }
Original file line number Diff line number Diff line change 11package org.bundleproject.libversion
22
3+ import kotlinx.serialization.Serializable
4+
5+ @Serializable(Serializer ::class )
36class Version (
47 val major : Int ,
58 val minor : Int = 0 ,
You can’t perform that action at this time.
0 commit comments