From f13733d0aa3a8c6f1e4b25e6b17dce3f22a39309 Mon Sep 17 00:00:00 2001 From: Frank Viernau Date: Wed, 3 Jul 2024 11:00:45 +0200 Subject: [PATCH] refactor(stack): Migrate from Jackson to KxS Signed-off-by: Frank Viernau --- plugins/package-managers/stack/build.gradle.kts | 9 +++++---- .../package-managers/stack/src/main/kotlin/Model.kt | 12 ++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/plugins/package-managers/stack/build.gradle.kts b/plugins/package-managers/stack/build.gradle.kts index 04bcc8a13e167..32dc1ae7a1668 100644 --- a/plugins/package-managers/stack/build.gradle.kts +++ b/plugins/package-managers/stack/build.gradle.kts @@ -20,6 +20,9 @@ plugins { // Apply precompiled plugins. id("ort-library-conventions") + + // Apply third-party plugins. + alias(libs.plugins.kotlinSerialization) } dependencies { @@ -37,10 +40,8 @@ dependencies { implementation(projects.utils.ortUtils) implementation(projects.utils.spdxUtils) - implementation(libs.jackson.annotations) - implementation(libs.jackson.core) - implementation(libs.jackson.databind) - implementation(libs.jackson.module.kotlin) + implementation(libs.kotlinx.serialization.core) + implementation(libs.kotlinx.serialization.json) funTestImplementation(testFixtures(projects.analyzer)) } diff --git a/plugins/package-managers/stack/src/main/kotlin/Model.kt b/plugins/package-managers/stack/src/main/kotlin/Model.kt index f6bb551b16467..e89c813689e07 100644 --- a/plugins/package-managers/stack/src/main/kotlin/Model.kt +++ b/plugins/package-managers/stack/src/main/kotlin/Model.kt @@ -19,12 +19,12 @@ package org.ossreviewtoolkit.plugins.packagemanagers.stack -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.module.kotlin.readValue +import kotlinx.serialization.Serializable +import kotlinx.serialization.json.Json -import org.ossreviewtoolkit.model.jsonMapper +private val JSON = Json { ignoreUnknownKeys = true } -@JsonIgnoreProperties(ignoreUnknown = true) +@Serializable internal data class Location( val url: String, val type: String @@ -35,7 +35,7 @@ internal data class Location( } } -@JsonIgnoreProperties(ignoreUnknown = true) +@Serializable internal data class Dependency( val name: String, val version: String, @@ -44,4 +44,4 @@ internal data class Dependency( val dependencies: List = emptyList() ) -internal fun String.parseDependencies() = jsonMapper.readValue>(this) +internal fun String.parseDependencies() = JSON.decodeFromString>(this)