From a26a09271a944ddcf44a7735971671e3652e0ae9 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 6 Feb 2024 22:24:16 +0300 Subject: [PATCH] Migrate to mpp project model --- build.gradle.kts | 4 +- examples/compose-demo/build.gradle.kts | 2 +- examples/js-demo/build.gradle.kts | 17 +++--- plotlykt-core/api/plotlykt-core.api | 61 ------------------- plotlykt-jupyter/build.gradle.kts | 9 ++- .../kscience/plotly/PlotlyIntegration.kt | 0 plotlykt-script/build.gradle.kts | 28 +++++---- .../kscience/plotly/script/PlotlyScript.kt | 4 +- .../space/kscience/plotly/script/builder.kt | 0 .../space/kscience/plotly/script/cli.kt | 2 +- ...ience.plotly.script.PlotlyScript.classname | 0 .../kscience/plotly/script/BuilderTest.kt | 0 .../resources/customPage.plotly.kts | 0 plotlykt-server/build.gradle.kts | 19 +++--- .../plotly/server/MetaChangeCollector.kt | 0 .../kscience/plotly/server/PlotlyServer.kt | 0 .../plotly/server/PlotlyServerIntegration.kt | 0 .../space/kscience/plotly/server/Update.kt | 0 18 files changed, 48 insertions(+), 98 deletions(-) rename plotlykt-jupyter/src/{main => jvmMain}/kotlin/space/kscience/plotly/PlotlyIntegration.kt (100%) rename plotlykt-script/src/{main => jvmMain}/kotlin/space/kscience/plotly/script/PlotlyScript.kt (89%) rename plotlykt-script/src/{main => jvmMain}/kotlin/space/kscience/plotly/script/builder.kt (100%) rename plotlykt-script/src/{main => jvmMain}/kotlin/space/kscience/plotly/script/cli.kt (95%) rename plotlykt-script/src/{main => jvmMain}/resources/META-INF/kotlin/script/templates/space.kscience.plotly.script.PlotlyScript.classname (100%) rename plotlykt-script/src/{test => jvmTest}/kotlin/space/kscience/plotly/script/BuilderTest.kt (100%) rename plotlykt-script/src/{test => jvmTest}/resources/customPage.plotly.kts (100%) rename plotlykt-server/src/{main => jvmMain}/kotlin/space/kscience/plotly/server/MetaChangeCollector.kt (100%) rename plotlykt-server/src/{main => jvmMain}/kotlin/space/kscience/plotly/server/PlotlyServer.kt (100%) rename plotlykt-server/src/{main => jvmMain}/kotlin/space/kscience/plotly/server/PlotlyServerIntegration.kt (100%) rename plotlykt-server/src/{main => jvmMain}/kotlin/space/kscience/plotly/server/Update.kt (100%) diff --git a/build.gradle.kts b/build.gradle.kts index 5a30d161..6b08110b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,11 +10,11 @@ val plotlyVersion by extra("2.29.0") allprojects { group = "space.kscience" - version = "0.7.0-dev-2" + version = "0.7.0" } apiValidation { - ignoredProjects.addAll(listOf("examples", "fx-demo", "js-demo")) + ignoredProjects.addAll(listOf("examples", "fx-demo", "js-demo", "compose-demo")) } ksciencePublish{ diff --git a/examples/compose-demo/build.gradle.kts b/examples/compose-demo/build.gradle.kts index 407d7fd3..d1d6f55a 100644 --- a/examples/compose-demo/build.gradle.kts +++ b/examples/compose-demo/build.gradle.kts @@ -2,7 +2,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { kotlin("multiplatform") - id("org.jetbrains.compose") version "1.5.12" + alias(spclibs.plugins.compose) } repositories { diff --git a/examples/js-demo/build.gradle.kts b/examples/js-demo/build.gradle.kts index dbef5c0e..a16944c3 100644 --- a/examples/js-demo/build.gradle.kts +++ b/examples/js-demo/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - kotlin("js") + kotlin("multiplatform") } repositories { @@ -12,13 +12,16 @@ kotlin { browser() binaries.executable() } -} - -dependencies { - implementation(projects.plotlyktCore) - implementation(spclibs.kotlinx.coroutines.core) + sourceSets{ + jsMain{ + dependencies{ + implementation(projects.plotlyktCore) + implementation(spclibs.kotlinx.coroutines.core) + } + } + } } tasks.withType { - kotlinOptions.freeCompilerArgs = kotlinOptions.freeCompilerArgs +"-Xopt-in=kotlin.RequiresOptIn" + kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn" } \ No newline at end of file diff --git a/plotlykt-core/api/plotlykt-core.api b/plotlykt-core/api/plotlykt-core.api index 14fb4c5e..c36b0b65 100644 --- a/plotlykt-core/api/plotlykt-core.api +++ b/plotlykt-core/api/plotlykt-core.api @@ -79,40 +79,6 @@ public final class space/kscience/plotly/PlotExtensionsKt { public static final fun violin (Lspace/kscience/plotly/Plot;Lkotlin/jvm/functions/Function1;)Lspace/kscience/plotly/models/Violin; } -public final class space/kscience/plotly/PlotGrid { - public fun ()V - public final fun get (Ljava/lang/String;)Lspace/kscience/plotly/PlotGrid$PlotCell; - public final fun getGrid ()Ljava/util/List; - public final fun plot (Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/String;ILkotlin/jvm/functions/Function1;)Lspace/kscience/plotly/Plot; - public final fun plot (Lspace/kscience/plotly/Plot;Ljava/lang/String;ILjava/lang/Integer;Ljava/lang/Integer;)Lspace/kscience/plotly/Plot; - public static synthetic fun plot$default (Lspace/kscience/plotly/PlotGrid;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/String;ILkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/plotly/Plot; - public static synthetic fun plot$default (Lspace/kscience/plotly/PlotGrid;Lspace/kscience/plotly/Plot;Ljava/lang/String;ILjava/lang/Integer;Ljava/lang/Integer;ILjava/lang/Object;)Lspace/kscience/plotly/Plot; -} - -public final class space/kscience/plotly/PlotGrid$PlotCell { - public fun (Ljava/lang/String;Lspace/kscience/plotly/Plot;III)V - public synthetic fun (Ljava/lang/String;Lspace/kscience/plotly/Plot;IIIILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun component1 ()Ljava/lang/String; - public final fun component2 ()Lspace/kscience/plotly/Plot; - public final fun component3 ()I - public final fun component4 ()I - public final fun component5 ()I - public final fun copy (Ljava/lang/String;Lspace/kscience/plotly/Plot;III)Lspace/kscience/plotly/PlotGrid$PlotCell; - public static synthetic fun copy$default (Lspace/kscience/plotly/PlotGrid$PlotCell;Ljava/lang/String;Lspace/kscience/plotly/Plot;IIIILjava/lang/Object;)Lspace/kscience/plotly/PlotGrid$PlotCell; - public fun equals (Ljava/lang/Object;)Z - public final fun getCol ()I - public final fun getId ()Ljava/lang/String; - public final fun getPlot ()Lspace/kscience/plotly/Plot; - public final fun getRow ()I - public final fun getWidth ()I - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class space/kscience/plotly/PlotGridKt { - public static final fun grid (Lspace/kscience/plotly/Plotly;Lkotlin/jvm/functions/Function1;)Lspace/kscience/plotly/PlotlyPage; -} - public final class space/kscience/plotly/PlotKt { public static final fun Plot (Lspace/kscience/dataforge/meta/Meta;)Lspace/kscience/plotly/Plot; public static final fun layout (Lspace/kscience/plotly/Plot;Lkotlin/jvm/functions/Function1;)V @@ -120,33 +86,6 @@ public final class space/kscience/plotly/PlotKt { public static final fun trace (Lspace/kscience/plotly/Plot;Lkotlin/jvm/functions/Function1;)Lspace/kscience/plotly/models/Trace; } -public final class space/kscience/plotly/PlotTabs { - public fun ()V - public final fun getTabs ()Ljava/util/List; - public final fun tab (Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function2;)V - public static synthetic fun tab$default (Lspace/kscience/plotly/PlotTabs;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)V -} - -public final class space/kscience/plotly/PlotTabs$Tab { - public fun (Ljava/lang/String;Ljava/lang/String;Lspace/kscience/plotly/PlotlyFragment;)V - public final fun component1 ()Ljava/lang/String; - public final fun component2 ()Ljava/lang/String; - public final fun component3 ()Lspace/kscience/plotly/PlotlyFragment; - public final fun copy (Ljava/lang/String;Ljava/lang/String;Lspace/kscience/plotly/PlotlyFragment;)Lspace/kscience/plotly/PlotTabs$Tab; - public static synthetic fun copy$default (Lspace/kscience/plotly/PlotTabs$Tab;Ljava/lang/String;Ljava/lang/String;Lspace/kscience/plotly/PlotlyFragment;ILjava/lang/Object;)Lspace/kscience/plotly/PlotTabs$Tab; - public fun equals (Ljava/lang/Object;)Z - public final fun getContent ()Lspace/kscience/plotly/PlotlyFragment; - public final fun getId ()Ljava/lang/String; - public final fun getTitle ()Ljava/lang/String; - public fun hashCode ()I - public fun toString ()Ljava/lang/String; -} - -public final class space/kscience/plotly/PlotTabsKt { - public static final fun tabs (Lspace/kscience/plotly/Plotly;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/plotly/PlotlyPage; - public static synthetic fun tabs$default (Lspace/kscience/plotly/Plotly;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/plotly/PlotlyPage; -} - public final class space/kscience/plotly/Plotly { public static final field INSTANCE Lspace/kscience/plotly/Plotly; public static final field PLOTLY_CDN Ljava/lang/String; diff --git a/plotlykt-jupyter/build.gradle.kts b/plotlykt-jupyter/build.gradle.kts index 7bfcfd41..847e7f93 100644 --- a/plotlykt-jupyter/build.gradle.kts +++ b/plotlykt-jupyter/build.gradle.kts @@ -1,13 +1,16 @@ plugins { - id("space.kscience.gradle.jvm") + id("space.kscience.gradle.mpp") kotlin("jupyter.api") `maven-publish` } val dataforgeVersion: String by rootProject.extra -dependencies { - api(projects.plotlyktCore) +kscience{ + jvm() + jvmMain{ + api(projects.plotlyktCore) + } } tasks.processJupyterApiResources{ diff --git a/plotlykt-jupyter/src/main/kotlin/space/kscience/plotly/PlotlyIntegration.kt b/plotlykt-jupyter/src/jvmMain/kotlin/space/kscience/plotly/PlotlyIntegration.kt similarity index 100% rename from plotlykt-jupyter/src/main/kotlin/space/kscience/plotly/PlotlyIntegration.kt rename to plotlykt-jupyter/src/jvmMain/kotlin/space/kscience/plotly/PlotlyIntegration.kt diff --git a/plotlykt-script/build.gradle.kts b/plotlykt-script/build.gradle.kts index 048d230f..09ee0a87 100644 --- a/plotlykt-script/build.gradle.kts +++ b/plotlykt-script/build.gradle.kts @@ -1,26 +1,28 @@ plugins { - id("space.kscience.gradle.jvm") + id("space.kscience.gradle.mpp") application `maven-publish` } -repositories { - maven("https://dl.bintray.com/kotlin/ktor/") -} - val ktorVersion: String by rootProject.extra val dataforgeVersion: String by rootProject.extra -dependencies { - api(projects.plotlyktCore) - api(spclibs.kotlinx.html) - api(kotlin("scripting-jvm-host")) - api(kotlin("scripting-jvm")) - api("io.github.microutils:kotlin-logging:3.0.5") - implementation(spclibs.logback.classic) - implementation(spclibs.kotlinx.cli) +kscience{ + jvm{ + withJava() + } + jvmMain{ + api(projects.plotlyktCore) + api(spclibs.kotlinx.html) + api(kotlin("scripting-jvm-host")) + api(kotlin("scripting-jvm")) + api("io.github.microutils:kotlin-logging:3.0.5") + implementation(spclibs.logback.classic) + implementation(spclibs.kotlinx.cli) + } } + application{ mainClass.set("space.kscience.plotly.script.CliKt") } \ No newline at end of file diff --git a/plotlykt-script/src/main/kotlin/space/kscience/plotly/script/PlotlyScript.kt b/plotlykt-script/src/jvmMain/kotlin/space/kscience/plotly/script/PlotlyScript.kt similarity index 89% rename from plotlykt-script/src/main/kotlin/space/kscience/plotly/script/PlotlyScript.kt rename to plotlykt-script/src/jvmMain/kotlin/space/kscience/plotly/script/PlotlyScript.kt index e84aaaa8..8a6b051d 100644 --- a/plotlykt-script/src/main/kotlin/space/kscience/plotly/script/PlotlyScript.kt +++ b/plotlykt-script/src/jvmMain/kotlin/space/kscience/plotly/script/PlotlyScript.kt @@ -11,10 +11,10 @@ import kotlin.script.experimental.jvm.jvm fileExtension = "plotly.kts", compilationConfiguration = PlotlyScriptCompilationConfiguration::class ) -abstract class PlotlyScript +public abstract class PlotlyScript -class PlotlyScriptCompilationConfiguration: ScriptCompilationConfiguration({ +public class PlotlyScriptCompilationConfiguration: ScriptCompilationConfiguration({ baseClass(PlotlyScript::class) implicitReceivers(FlowContent::class) defaultImports( diff --git a/plotlykt-script/src/main/kotlin/space/kscience/plotly/script/builder.kt b/plotlykt-script/src/jvmMain/kotlin/space/kscience/plotly/script/builder.kt similarity index 100% rename from plotlykt-script/src/main/kotlin/space/kscience/plotly/script/builder.kt rename to plotlykt-script/src/jvmMain/kotlin/space/kscience/plotly/script/builder.kt diff --git a/plotlykt-script/src/main/kotlin/space/kscience/plotly/script/cli.kt b/plotlykt-script/src/jvmMain/kotlin/space/kscience/plotly/script/cli.kt similarity index 95% rename from plotlykt-script/src/main/kotlin/space/kscience/plotly/script/cli.kt rename to plotlykt-script/src/jvmMain/kotlin/space/kscience/plotly/script/cli.kt index 5794ab62..1c188f46 100644 --- a/plotlykt-script/src/main/kotlin/space/kscience/plotly/script/cli.kt +++ b/plotlykt-script/src/jvmMain/kotlin/space/kscience/plotly/script/cli.kt @@ -10,7 +10,7 @@ import java.io.File import java.nio.file.Path @OptIn(UnstablePlotlyAPI::class) -fun main(args: Array) { +public fun main(args: Array) { val parser = ArgParser("plotlykt-script") val input by parser.argument(ArgType.String, description ="Input file path") val output by parser.argument(ArgType.String, description = "Output file path").optional() diff --git a/plotlykt-script/src/main/resources/META-INF/kotlin/script/templates/space.kscience.plotly.script.PlotlyScript.classname b/plotlykt-script/src/jvmMain/resources/META-INF/kotlin/script/templates/space.kscience.plotly.script.PlotlyScript.classname similarity index 100% rename from plotlykt-script/src/main/resources/META-INF/kotlin/script/templates/space.kscience.plotly.script.PlotlyScript.classname rename to plotlykt-script/src/jvmMain/resources/META-INF/kotlin/script/templates/space.kscience.plotly.script.PlotlyScript.classname diff --git a/plotlykt-script/src/test/kotlin/space/kscience/plotly/script/BuilderTest.kt b/plotlykt-script/src/jvmTest/kotlin/space/kscience/plotly/script/BuilderTest.kt similarity index 100% rename from plotlykt-script/src/test/kotlin/space/kscience/plotly/script/BuilderTest.kt rename to plotlykt-script/src/jvmTest/kotlin/space/kscience/plotly/script/BuilderTest.kt diff --git a/plotlykt-script/src/test/resources/customPage.plotly.kts b/plotlykt-script/src/jvmTest/resources/customPage.plotly.kts similarity index 100% rename from plotlykt-script/src/test/resources/customPage.plotly.kts rename to plotlykt-script/src/jvmTest/resources/customPage.plotly.kts diff --git a/plotlykt-server/build.gradle.kts b/plotlykt-server/build.gradle.kts index 2409750d..ac7f08e7 100644 --- a/plotlykt-server/build.gradle.kts +++ b/plotlykt-server/build.gradle.kts @@ -1,7 +1,7 @@ import space.kscience.gradle.KScienceVersions plugins { - id("space.kscience.gradle.jvm") + id("space.kscience.gradle.mpp") kotlin("jupyter.api") `maven-publish` } @@ -9,13 +9,16 @@ plugins { val dataforgeVersion: String by rootProject.extra val ktorVersion = KScienceVersions.ktorVersion -dependencies { - api(projects.plotlyktCore) - api("io.ktor:ktor-server-cio:$ktorVersion") - api("io.ktor:ktor-server-html-builder:$ktorVersion") - api("io.ktor:ktor-server-websockets:$ktorVersion") - api("io.ktor:ktor-server-cors:$ktorVersion") - api("space.kscience:dataforge-context:$dataforgeVersion") +kscience{ + jvm() + jvmMain{ + api(projects.plotlyktCore) + api("io.ktor:ktor-server-cio:$ktorVersion") + api("io.ktor:ktor-server-html-builder:$ktorVersion") + api("io.ktor:ktor-server-websockets:$ktorVersion") + api("io.ktor:ktor-server-cors:$ktorVersion") + api("space.kscience:dataforge-context:$dataforgeVersion") + } } tasks.processJupyterApiResources{ diff --git a/plotlykt-server/src/main/kotlin/space/kscience/plotly/server/MetaChangeCollector.kt b/plotlykt-server/src/jvmMain/kotlin/space/kscience/plotly/server/MetaChangeCollector.kt similarity index 100% rename from plotlykt-server/src/main/kotlin/space/kscience/plotly/server/MetaChangeCollector.kt rename to plotlykt-server/src/jvmMain/kotlin/space/kscience/plotly/server/MetaChangeCollector.kt diff --git a/plotlykt-server/src/main/kotlin/space/kscience/plotly/server/PlotlyServer.kt b/plotlykt-server/src/jvmMain/kotlin/space/kscience/plotly/server/PlotlyServer.kt similarity index 100% rename from plotlykt-server/src/main/kotlin/space/kscience/plotly/server/PlotlyServer.kt rename to plotlykt-server/src/jvmMain/kotlin/space/kscience/plotly/server/PlotlyServer.kt diff --git a/plotlykt-server/src/main/kotlin/space/kscience/plotly/server/PlotlyServerIntegration.kt b/plotlykt-server/src/jvmMain/kotlin/space/kscience/plotly/server/PlotlyServerIntegration.kt similarity index 100% rename from plotlykt-server/src/main/kotlin/space/kscience/plotly/server/PlotlyServerIntegration.kt rename to plotlykt-server/src/jvmMain/kotlin/space/kscience/plotly/server/PlotlyServerIntegration.kt diff --git a/plotlykt-server/src/main/kotlin/space/kscience/plotly/server/Update.kt b/plotlykt-server/src/jvmMain/kotlin/space/kscience/plotly/server/Update.kt similarity index 100% rename from plotlykt-server/src/main/kotlin/space/kscience/plotly/server/Update.kt rename to plotlykt-server/src/jvmMain/kotlin/space/kscience/plotly/server/Update.kt