Skip to content

Commit

Permalink
refactor(stack): Migrate from Jackson to KxS
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Viernau <frank_viernau@epam.com>
  • Loading branch information
fviernau committed Jul 3, 2024
1 parent c0587e1 commit f13733d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
9 changes: 5 additions & 4 deletions plugins/package-managers/stack/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
plugins {
// Apply precompiled plugins.
id("ort-library-conventions")

// Apply third-party plugins.
alias(libs.plugins.kotlinSerialization)
}

dependencies {
Expand All @@ -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))
}
12 changes: 6 additions & 6 deletions plugins/package-managers/stack/src/main/kotlin/Model.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -35,7 +35,7 @@ internal data class Location(
}
}

@JsonIgnoreProperties(ignoreUnknown = true)
@Serializable
internal data class Dependency(
val name: String,
val version: String,
Expand All @@ -44,4 +44,4 @@ internal data class Dependency(
val dependencies: List<String> = emptyList()
)

internal fun String.parseDependencies() = jsonMapper.readValue<List<Dependency>>(this)
internal fun String.parseDependencies() = JSON.decodeFromString<List<Dependency>>(this)

0 comments on commit f13733d

Please sign in to comment.