![JAR search and dependency download from the Maven repository](/logo.png)
org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMetadataLibrariesIndexFile.kt Maven / Gradle / Ivy
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.gradle.plugin.mpp
import com.google.gson.GsonBuilder
import com.google.gson.reflect.TypeToken
import org.jetbrains.kotlin.gradle.targets.native.internal.CInteropMetadataDependencyTransformationTask
import java.io.File
import java.io.FileReader
import java.io.FileWriter
private val gson = GsonBuilder().setLenient().setPrettyPrinting().serializeNulls().create()
data class TransformedMetadataLibraryRecord(
val moduleId: String,
val file: String,
val sourceSetName: String? = null
)
/**
* Files used by the [MetadataDependencyTransformationTask] and [CInteropMetadataDependencyTransformationTask] to
* store the resulting 'metadata path' in this index file.
*/
internal class KotlinMetadataLibrariesIndexFile(private val file: File) {
private val typeToken = object : TypeToken>() {}
fun read(): List = FileReader(file).use {
gson.fromJson>(it, typeToken.type).toList()
}
fun write(records: List) {
FileWriter(file).use {
gson.toJson(records, typeToken.type, it)
}
}
}
internal fun KotlinMetadataLibrariesIndexFile.readFiles() = read().map { File(it.file) }
© 2015 - 2025 Weber Informatics LLC | Privacy Policy