Skip to content

Commit

Permalink
Move serializers to package com.zhelenskiy.serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
zhelenskiy committed Apr 27, 2024
1 parent 1971a55 commit bb7a1b1
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ bin/
.DS_Store


src/ClassSerializer.kt
src/com/zhelenskiy/serialization/ClassSerializer.kt
6 changes: 5 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ fun generateClassSerializers() = buildString {
}
+"@file:Suppress(\"DuplicatedCode\")"
+""
+"package com.zhelenskiy.serialization"
+""
+"import kotlinx.serialization.ExperimentalSerializationApi"
+"import kotlinx.serialization.KSerializer"
+"import kotlinx.serialization.descriptors.SerialDescriptor"
Expand Down Expand Up @@ -124,9 +126,11 @@ fun generateClassSerializers() = buildString {
}
}

fun File.withCreatedParentDirectories() = apply { parentFile?.mkdirs() }

tasks.register("generateClassSerializers") {
val sourceFile = generateClassSerializers()
projectDir.resolve("src/ClassSerializer.kt").writeText(sourceFile)
projectDir.resolve("src/com/zhelenskiy/serialization/ClassSerializer.kt").withCreatedParentDirectories().writeText(sourceFile)
}

tasks.withType<KotlinCompile> {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
kotlin.daemon.jvmargs=-Xmx1G
kotlin.daemon.jvmargs=-Xmx4G
2 changes: 1 addition & 1 deletion module.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ settings:
jvm:
target: 1.8
kotlin:
serialization: json
serialization: json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package com.zhelenskiy.serialization

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.KSerializer
import kotlinx.serialization.descriptors.PrimitiveKind
Expand Down
3 changes: 3 additions & 0 deletions test/ClassTests.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import com.zhelenskiy.serialization.ClassKSerializer2
import com.zhelenskiy.serialization.Property
import com.zhelenskiy.serialization.classSerializer
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializable
import kotlinx.serialization.builtins.serializer
Expand Down
4 changes: 3 additions & 1 deletion test/DelegateTests.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.zhelenskiy.serialization.DelegatedKSerializer
import com.zhelenskiy.serialization.delegatedSerializer
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializable
import kotlinx.serialization.builtins.ListSerializer
Expand All @@ -10,7 +12,7 @@ import kotlin.test.assertEquals
class DelegateTests {
@Test
fun primitiveDelegate() {
val int2String = delegatedSerializer<Int, String>(
val int2String = delegatedSerializer(
delegate = String.Companion.serializer(),
descriptorName = "MyInt1",
save = { "-$it" },
Expand Down

0 comments on commit bb7a1b1

Please sign in to comment.