Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
48 changes: 47 additions & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -251,6 +251,52 @@ 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)

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<Jar> {
mustRunAfter(changeJarTask, tasks.generateKeywordsSrc, processKDocsMain)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<KClass<*>>()

Expand Down
9 changes: 9 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -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"

Expand Down