From 878405ac6a643186d576949a477ab3140df9eb13 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 12 Sep 2021 22:06:08 +0300 Subject: [PATCH] Replace `useJupyter` with `jupyterLibrary` --- gradle/libs.versions.toml | 10 +++++----- .../ru/mipt/npm/gradle/KScienceExtension.kt | 13 +++++++++++- .../mipt/npm/gradle/KScienceProjectPlugin.kt | 20 +++++++++---------- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d5e8579..1fae6ea 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,14 +1,14 @@ [versions] atomicfu = "0.16.2" -binary-compatibility-validator = "0.6.0" -changelog = "1.2.1" +binary-compatibility-validator = "0.7.1" +changelog = "1.3.0" dokka = "1.5.0" kotlin = "1.5.30" -kotlin-jupyter = "0.10.0-184" +kotlin-jupyter = "0.10.0-227" kotlinx-benchmark = "0.3.1" kotlinx-cli = "0.3.2" kotlinx-collections-immutable = "0.3.4" -kotlinx-coroutines = "1.5.1" +kotlinx-coroutines = "1.5.2" kotlinx-datetime = "0.2.1" kotlinx-html = "0.7.3" kotlinx-knit = "0.2.3" @@ -16,7 +16,7 @@ kotlinx-nodejs = "0.0.7" kotlinx-serialization = "1.3.0-RC" ktor = "1.6.3" tools = "0.10.3" -xmlutil = "0.82.0" +xmlutil = "0.83.0" yamlkt = "0.10.2" jsBom = "0.0.1-pre.243-kotlin-1.5.30" diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt index 2b71104..6c07f48 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt @@ -4,13 +4,13 @@ import kotlinx.atomicfu.plugin.gradle.AtomicFUGradlePlugin import org.gradle.api.Project import org.gradle.api.plugins.ApplicationPlugin import org.gradle.kotlin.dsl.apply -import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.findByType import org.gradle.kotlin.dsl.withType import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget +import org.jetbrains.kotlinx.jupyter.api.plugin.tasks.JupyterApiResourcesTask import ru.mipt.npm.gradle.internal.defaultPlatform import ru.mipt.npm.gradle.internal.useCommonDependency import ru.mipt.npm.gradle.internal.useFx @@ -135,10 +135,21 @@ public class KScienceExtension(public val project: Project) { /** * Apply jupyter plugin */ + @Deprecated("Use jupyterLibrary") public fun useJupyter() { project.apply("org.jetbrains.kotlin.jupyter.api") } + /** + * Apply jupyter plugin and add entry point for the jupyter library + */ + public fun jupyterLibrary(pluginClass: String, vararg additionalPluginClasses: String) { + project.apply("org.jetbrains.kotlin.jupyter.api") + project.tasks.named("processJupyterApiResources", JupyterApiResourcesTask::class.java) { + libraryProducers = listOf(pluginClass, *additionalPluginClasses) + } + } + /** * Mark this module as an application module. JVM application should be enabled separately */ diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt index 93467b7..cafd95a 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt @@ -65,15 +65,15 @@ public class KSciencePublishingExtension(public val project: Project) { * * @param githubProject the GitHub project. * @param githubOrg the GitHub user or organization. - * @param released whether publish packages in the `release` task to the GitHub repository. + * @param release whether publish packages in the `release` task to the GitHub repository. */ - public fun github(githubProject: String, githubOrg: String = "mipt-npm", released: Boolean = false, published: Boolean = true) { + public fun github(githubProject: String, githubOrg: String = "mipt-npm", release: Boolean = false, publish: Boolean = true) { // Automatically initialize VCS using GitHub if (!isVcsInitialized) git("https://github.com/$githubOrg/${githubProject}", "https://github.com/$githubOrg/${githubProject}.git") - if (published) project.addGithubPublishing(githubOrg, githubProject) - if (released) linkPublicationsToReleaseTask("github") + if (publish) project.addGithubPublishing(githubOrg, githubProject) + if (release) linkPublicationsToReleaseTask("github") } private val releaseTask by lazy { @@ -84,13 +84,13 @@ public class KSciencePublishingExtension(public val project: Project) { * Adds Space Packages Maven repository to publishing. * * @param spaceRepo the repository URL. - * @param released whether publish packages in the `release` task to the Space repository. + * @param release whether publish packages in the `release` task to the Space repository. */ - public fun space(spaceRepo: String = "https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven", released: Boolean = false) { + public fun space(spaceRepo: String = "https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven", release: Boolean = true) { require(isVcsInitialized) { "The project vcs is not set up use 'vcs' method to do so" } project.addSpacePublishing(spaceRepo) - if (released) linkPublicationsToReleaseTask("space") + if (release) linkPublicationsToReleaseTask("space") } // // Bintray publishing @@ -102,13 +102,13 @@ public class KSciencePublishingExtension(public val project: Project) { /** * Adds Sonatype Maven repository to publishing. * - * @param released whether publish packages in the `release` task to the Sonatype repository. + * @param release whether publish packages in the `release` task to the Sonatype repository. */ - public fun sonatype(released: Boolean = true) { + public fun sonatype(release: Boolean = true) { require(isVcsInitialized) { "The project vcs is not set up use 'vcs' method to do so" } project.addSonatypePublishing() - if (released) linkPublicationsToReleaseTask("sonatype") + if (release) linkPublicationsToReleaseTask("sonatype") } }