diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cf270cb0d5..50e34cf3e2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -112,6 +112,9 @@ This library is built with Gradle. making local publishing faster: `./gradlew publishToMavenLocal -PskipKodex`. This, however, publishes the library with "broken" KDocs, so it's only meant for faster iterations during development. +* The parameter `-PincludeCoreLibrariesJson` makes the build include the `libraries.json` file in the `:core` module. + This file allows loading dataframe-jupyter when dataframe-core is present on its own in a Kotlin Notebook. + Usually only done when publishing. You can import this project into IDEA, but you have to delegate the build actions to Gradle (in Preferences -> Build, Execution, Deployment -> Build Tools -> Gradle -> Runner) diff --git a/core/build.gradle.kts b/core/build.gradle.kts index f47415e438..a64920b943 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -3,7 +3,7 @@ import com.google.devtools.ksp.gradle.KspTaskJvm import io.github.devcrocod.korro.KorroTask import nl.jolanrensen.kodex.gradle.creatingRunKodexTask import org.gradle.jvm.tasks.Jar -import org.gradle.kotlin.dsl.withType +import org.intellij.lang.annotations.Language import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { @@ -251,6 +251,53 @@ val changeJarTask by tasks.registering { } } +// generateLibrariesJson makes sure a META-INF/kotlin-jupyter-libraries/libraries.json file is generated +// This file allows loading dataframe-jupyter when dataframe-core is present on its own in a Kotlin Notebook. +val generatedJupyterResourcesDir = layout.buildDirectory.dir("generated/jupyter") +val generateLibrariesJson by tasks.registering { + val outDir = generatedJupyterResourcesDir.get().asFile.resolve("META-INF/kotlin-jupyter-libraries") + val outFile = outDir.resolve("libraries.json") + outputs.file(outFile) + inputs.property("version", project.version) + + doLast { + outDir.mkdirs() + @Language("json") + val content = + """ + { + "descriptors": [ + { + "init": [ + "USE { dependencies(\"org.jetbrains.kotlinx:dataframe-jupyter:${project.version}\") }" + ] + } + ] + } + """.trimIndent() + + outFile.delete() + outFile.writeText(content) + logger.lifecycle("generated META-INF/kotlin-jupyter-libraries/libraries.json for :core") + } +} + +// If `includeCoreLibrariesJson` is set, modify the processResources task such that it includes +// a META-INF libraries.json file. +// This file allows loading dataframe-jupyter when dataframe-core is present on its own in a Kotlin Notebook. +// This is usually only done when publishing. +tasks.processResources { + if (project.hasProperty("includeCoreLibrariesJson")) { + dependsOn(generateLibrariesJson) + from(generatedJupyterResourcesDir) { + into("") // keep META-INF/... structure as generated + } + doLast { + logger.lifecycle("$this includes generated META-INF/kotlin-jupyter-libraries/libraries.json") + } + } +} + // if `processKDocsMain` runs, the Jar tasks must run after it so the generated-sources are there tasks.withType { mustRunAfter(changeJarTask, tasks.generateKeywordsSrc, processKDocsMain) diff --git a/dataframe-jupyter/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/Integration.kt b/dataframe-jupyter/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/Integration.kt index 16d1f8b390..66c2661882 100644 --- a/dataframe-jupyter/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/Integration.kt +++ b/dataframe-jupyter/src/main/kotlin/org/jetbrains/kotlinx/dataframe/jupyter/Integration.kt @@ -56,7 +56,7 @@ import kotlin.reflect.KType import kotlin.reflect.full.isSubtypeOf /** Users will get an error if their Kotlin Jupyter kernel is older than this version. */ -private const val MIN_KERNEL_VERSION = "0.11.0.198" +private const val MIN_KERNEL_VERSION = "0.15.0.606" internal val newDataSchemas = mutableListOf>() diff --git a/gradle.properties b/gradle.properties index d0a31b511c..47de21bfd9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -22,3 +22,12 @@ ksp.useKSP2=false kotlin.dataframe.debug=false kotlin.incremental=false + +# Can speed up build time but stops KDocs from being preprocessed. +# It can also be turned on from the command line with `-PskipKodex` +# skipKodex=true + +# If `true`, builds include the core/src/main/resources/META-INF/kotlin-jupyter-libraries/libraries.json file. +# This file allows loading dataframe-jupyter when dataframe-core is present on its own in a Kotlin Notebook. +# This is usually only done when publishing and can be turned on from the command line with `-PincludeCoreLibrariesJson` +# includeCoreLibrariesJson=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 97d6819f48..6ad75deed5 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] ksp = "2.2.20-2.0.2" -kotlinJupyter = "0.15.0-587" +kotlinJupyter = "0.15.0-629" ktlint = "12.3.0"