org.jetbrains.kotlinx.jupyter.dependencies.Dependency.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-jupyter-kernel Show documentation
Show all versions of kotlin-jupyter-kernel Show documentation
Kotlin Jupyter kernel published as artifact
package org.jetbrains.kotlinx.jupyter.dependencies
import jupyter.kotlin.DependsOn
enum class DependencyAssumption {
NO,
MAYBE,
YES,
}
data class Dependency(
val value: String,
val hasSources: DependencyAssumption = DependencyAssumption.MAYBE,
val isMultiplatform: DependencyAssumption = DependencyAssumption.MAYBE,
)
fun Dependency.shouldResolveSources(default: Boolean): Boolean {
return when (hasSources) {
DependencyAssumption.NO -> false
DependencyAssumption.YES, DependencyAssumption.MAYBE -> default
}
}
fun Iterable.shouldResolveSources(default: Boolean) = any { it.shouldResolveSources(default) }
fun Dependency.shouldResolveAsMultiplatform(default: Boolean): Boolean {
return when (isMultiplatform) {
DependencyAssumption.NO -> false
DependencyAssumption.MAYBE -> default
DependencyAssumption.YES -> true
}
}
fun Iterable.shouldResolveAsMultiplatform(default: Boolean) = any { it.shouldResolveAsMultiplatform(default) }
/**
* This is a temporary workaround: we consider these dependencies JVM-only
* and don't try to resolve module files for them that is very expensive with the current
* implementation of maven resolver
*/
private fun isDefinitelyJvmOnly(artifact: String): Boolean {
return when {
artifact.startsWith("org.jetbrains.kotlinx:dataframe") -> true
artifact.startsWith("org.jetbrains.kotlinx:kandy") -> true
artifact.startsWith("org.jetbrains.kotlinx:kotlin-statistics-jvm") -> true
else -> false
}
}
fun String.toDependency(): Dependency {
val value = this
return Dependency(
value,
isMultiplatform = if (isDefinitelyJvmOnly(value)) DependencyAssumption.NO else DependencyAssumption.MAYBE,
)
}
fun DependsOn.toDependency() = value.toDependency()
© 2015 - 2025 Weber Informatics LLC | Privacy Policy