All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jetbrains.kotlinx.jupyter.config.runtimeProperties.kt Maven / Gradle / Ivy

Go to download

Implementation of REPL compiler and preprocessor for Jupyter dialect of Kotlin (IDE-compatible)

There is a newer version: 0.12.0-250
Show newest version
package org.jetbrains.kotlinx.jupyter.config

import org.jetbrains.kotlinx.jupyter.api.KotlinKernelVersion

fun String.parseIniConfig() =
    lineSequence().map { it.split('=') }.filter { it.count() == 2 }.map { it[0] to it[1] }.toMap()

fun readResourceAsIniFile(fileName: String) =
    readResourceAsIniFile(fileName, ClassLoader.getSystemClassLoader())

fun readResourceAsIniFile(fileName: String, classLoader: ClassLoader) =
    classLoader.getResource(fileName)?.readText()?.parseIniConfig().orEmpty()

private val runtimeProperties by lazy {
    readResourceAsIniFile("compiler.properties", KernelStreams::class.java.classLoader)
}

fun getFromRuntimeProperties(property: String, propertyDescription: String): String {
    return runtimeProperties[property] ?: error("Compiler artifact should contain $propertyDescription")
}

val currentKernelVersion by lazy {
    KotlinKernelVersion.from(
        getFromRuntimeProperties("version", "kernel version")
    )!!
}

val currentKotlinVersion by lazy {
    getFromRuntimeProperties("kotlinVersion", "Kotlin version")
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy