From b5a7b127943279d034658e75a20ff7b3af14b188 Mon Sep 17 00:00:00 2001 From: ansgarz Date: Tue, 8 Oct 2024 17:16:37 +0200 Subject: [PATCH] improve serialization by using serializer() --- build.gradle | 6 +++--- .../provs/framework/core/YamlUtils.kt | 7 ++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index 798cbe7..84b0023 100644 --- a/build.gradle +++ b/build.gradle @@ -169,9 +169,9 @@ tasks.register('installbinaires') { dependsOn(uberjarServer, uberjarDesktop, uberjarSyspec) doLast { println "Building binaries ..." - exec { commandLine("sh", "-c", "cd build/libs/ && native-image -jar provs-desktop.jar") } - exec { commandLine("sh", "-c", "cd build/libs/ && native-image -jar provs-server.jar") } - exec { commandLine("sh", "-c", "cd build/libs/ && native-image -jar provs-syspec.jar") } + exec { commandLine("sh", "-c", "cd build/libs/ && native-image --no-fallback --initialize-at-build-time=kotlin.DeprecationLevel -jar provs-desktop.jar") } + exec { commandLine("sh", "-c", "cd build/libs/ && native-image --no-fallback --initialize-at-build-time=kotlin.DeprecationLevel -jar provs-server.jar") } + exec { commandLine("sh", "-c", "cd build/libs/ && native-image --no-fallback --initialize-at-build-time=kotlin.DeprecationLevel -jar provs-syspec.jar") } exec { commandLine("sh", "-c", "sudo cp $projectRoot/build/libs/provs-desktop /usr/local/bin/") } exec { commandLine("sh", "-c", "sudo cp $projectRoot/build/libs/provs-server /usr/local/bin/") } exec { commandLine("sh", "-c", "sudo cp $projectRoot/build/libs/provs-syspec /usr/local/bin/") } diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/YamlUtils.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/YamlUtils.kt index ccdf605..c92de07 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/YamlUtils.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/YamlUtils.kt @@ -2,7 +2,6 @@ package org.domaindrivenarchitecture.provs.framework.core import com.charleskorn.kaml.Yaml import com.charleskorn.kaml.YamlConfiguration -import kotlinx.serialization.InternalSerializationApi import kotlinx.serialization.serializer import java.io.BufferedReader import java.io.File @@ -18,15 +17,13 @@ fun writeToFile(fileName: String, text: String) { } -@OptIn(InternalSerializationApi::class) inline fun String.yamlToType() = Yaml(configuration = YamlConfiguration(strictMode = false)).decodeFromString( - T::class.serializer(), + serializer(), this ) -@OptIn(InternalSerializationApi::class) inline fun T.toYaml() = Yaml(configuration = YamlConfiguration(strictMode = false, encodeDefaults = false)).encodeToString( - T::class.serializer(), + serializer(), this )