@@ -3,7 +3,7 @@ import com.google.devtools.ksp.gradle.KspTaskJvm
3
3
import io.github.devcrocod.korro.KorroTask
4
4
import nl.jolanrensen.kodex.gradle.creatingRunKodexTask
5
5
import org.gradle.jvm.tasks.Jar
6
- import org.gradle.kotlin.dsl.withType
6
+ import org.intellij.lang.annotations.Language
7
7
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
8
8
9
9
plugins {
@@ -251,6 +251,53 @@ val changeJarTask by tasks.registering {
251
251
}
252
252
}
253
253
254
+ // generateLibrariesJson makes sure a META-INF/kotlin-jupyter-libraries/libraries.json file is generated
255
+ // This file allows loading dataframe-jupyter when dataframe-core is present on its own in a Kotlin Notebook.
256
+ val generatedJupyterResourcesDir = layout.buildDirectory.dir(" generated/jupyter" )
257
+ val generateLibrariesJson by tasks.registering {
258
+ val outDir = generatedJupyterResourcesDir.get().asFile.resolve(" META-INF/kotlin-jupyter-libraries" )
259
+ val outFile = outDir.resolve(" libraries.json" )
260
+ outputs.file(outFile)
261
+ inputs.property(" version" , project.version)
262
+
263
+ doLast {
264
+ outDir.mkdirs()
265
+ @Language(" json" )
266
+ val content =
267
+ """
268
+ {
269
+ "descriptors": [
270
+ {
271
+ "init": [
272
+ "USE { dependencies(\"org.jetbrains.kotlinx:dataframe-jupyter:${project.version} \") }"
273
+ ]
274
+ }
275
+ ]
276
+ }
277
+ """ .trimIndent()
278
+
279
+ outFile.delete()
280
+ outFile.writeText(content)
281
+ logger.lifecycle(" generated META-INF/kotlin-jupyter-libraries/libraries.json for :core" )
282
+ }
283
+ }
284
+
285
+ // If `includeCoreLibrariesJson` is set, modify the processResources task such that it includes
286
+ // a META-INF libraries.json file.
287
+ // This file allows loading dataframe-jupyter when dataframe-core is present on its own in a Kotlin Notebook.
288
+ // This is usually only done when publishing.
289
+ tasks.processResources {
290
+ if (project.hasProperty(" includeCoreLibrariesJson" )) {
291
+ dependsOn(generateLibrariesJson)
292
+ from(generatedJupyterResourcesDir) {
293
+ into(" " ) // keep META-INF/... structure as generated
294
+ }
295
+ doLast {
296
+ logger.lifecycle(" $this includes generated META-INF/kotlin-jupyter-libraries/libraries.json" )
297
+ }
298
+ }
299
+ }
300
+
254
301
// if `processKDocsMain` runs, the Jar tasks must run after it so the generated-sources are there
255
302
tasks.withType<Jar > {
256
303
mustRunAfter(changeJarTask, tasks.generateKeywordsSrc, processKDocsMain)
@@ -386,17 +433,6 @@ kotlinPublications {
386
433
}
387
434
}
388
435
389
- val instrumentedJars: Configuration by configurations.creating {
390
- isCanBeConsumed = true
391
- isCanBeResolved = false
392
- }
393
-
394
- artifacts {
395
- add(" instrumentedJars" , tasks.jar.get().archiveFile) {
396
- builtBy(tasks.jar)
397
- }
398
- }
399
-
400
436
// Disable and enable if updating plugin breaks the build
401
437
dataframes {
402
438
schema {
0 commit comments