diff --git a/plugins/package-managers/conan/build.gradle.kts b/plugins/package-managers/conan/build.gradle.kts index 80b56d94cfbfd..af71c27846c9a 100644 --- a/plugins/package-managers/conan/build.gradle.kts +++ b/plugins/package-managers/conan/build.gradle.kts @@ -20,6 +20,9 @@ plugins { // Apply precompiled plugins. id("ort-library-conventions") + + // Apply third-party plugins. + alias(libs.plugins.kotlinSerialization) } dependencies { @@ -42,5 +45,8 @@ dependencies { implementation(libs.jackson.dataformat.yaml) 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/conan/src/main/kotlin/PackageInfo.kt b/plugins/package-managers/conan/src/main/kotlin/PackageInfo.kt index d85e5d5d7c7bb..c6b6176304a4b 100644 --- a/plugins/package-managers/conan/src/main/kotlin/PackageInfo.kt +++ b/plugins/package-managers/conan/src/main/kotlin/PackageInfo.kt @@ -19,19 +19,20 @@ package org.ossreviewtoolkit.plugins.packagemanagers.conan -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import com.fasterxml.jackson.databind.PropertyNamingStrategies -import com.fasterxml.jackson.module.kotlin.readValue - import java.io.File -import org.ossreviewtoolkit.model.jsonMapper +import kotlinx.serialization.Serializable +import kotlinx.serialization.json.Json +import kotlinx.serialization.json.JsonNamingStrategy -private val mapper = jsonMapper.copy().setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE) +private val JSON = Json { + ignoreUnknownKeys = true + namingStrategy = JsonNamingStrategy.SnakeCase +} -internal fun parsePackageInfos(file: File): List = mapper.readValue>(file) +internal fun parsePackageInfos(file: File): List = JSON.decodeFromString(file.readText()) -@JsonIgnoreProperties(ignoreUnknown = true) +@Serializable internal data class PackageInfo( val reference: String? = null, val author: String? = null,