From 8d2a943b183f1d8d86bf67f08aea5b8b1cd69211 Mon Sep 17 00:00:00 2001
From: 5peak2me <461260911@qq.com>
Date: Wed, 8 Jan 2025 15:52:35 +0800
Subject: [PATCH] Migrate to org.jetbrains.kotlin.multiplatform plugin.

---
 ruler-frontend-tests/build.gradle.kts         |  2 +-
 ruler-frontend/build.gradle.kts               | 40 +++++++++----------
 .../com/spotify/ruler/frontend/Formatting.kt  |  0
 .../kotlin/com/spotify/ruler/frontend/Main.kt |  0
 .../ruler/frontend/binding/ApexCharts.kt      |  0
 .../ruler/frontend/chart/BarChartConfig.kt    |  0
 .../ruler/frontend/chart/ChartConfig.kt       |  0
 .../ruler/frontend/chart/ChartUtils.kt        |  0
 .../ruler/frontend/components/Breakdown.kt    |  0
 .../ruler/frontend/components/Common.kt       |  0
 .../frontend/components/DynamicFeatures.kt    |  0
 .../ruler/frontend/components/Insights.kt     |  0
 .../ruler/frontend/components/Ownership.kt    |  0
 .../ruler/frontend/components/PageControl.kt  |  0
 .../{main => jsMain}/resources/favicon.svg    |  0
 .../src/{main => jsMain}/resources/index.html |  0
 .../src/{main => jsMain}/resources/style.css  |  0
 .../spotify/ruler/frontend/FormattingTest.kt  |  0
 ruler-gradle-plugin/build.gradle.kts          |  2 +-
 19 files changed, 22 insertions(+), 22 deletions(-)
 rename ruler-frontend/src/{main => jsMain}/kotlin/com/spotify/ruler/frontend/Formatting.kt (100%)
 rename ruler-frontend/src/{main => jsMain}/kotlin/com/spotify/ruler/frontend/Main.kt (100%)
 rename ruler-frontend/src/{main => jsMain}/kotlin/com/spotify/ruler/frontend/binding/ApexCharts.kt (100%)
 rename ruler-frontend/src/{main => jsMain}/kotlin/com/spotify/ruler/frontend/chart/BarChartConfig.kt (100%)
 rename ruler-frontend/src/{main => jsMain}/kotlin/com/spotify/ruler/frontend/chart/ChartConfig.kt (100%)
 rename ruler-frontend/src/{main => jsMain}/kotlin/com/spotify/ruler/frontend/chart/ChartUtils.kt (100%)
 rename ruler-frontend/src/{main => jsMain}/kotlin/com/spotify/ruler/frontend/components/Breakdown.kt (100%)
 rename ruler-frontend/src/{main => jsMain}/kotlin/com/spotify/ruler/frontend/components/Common.kt (100%)
 rename ruler-frontend/src/{main => jsMain}/kotlin/com/spotify/ruler/frontend/components/DynamicFeatures.kt (100%)
 rename ruler-frontend/src/{main => jsMain}/kotlin/com/spotify/ruler/frontend/components/Insights.kt (100%)
 rename ruler-frontend/src/{main => jsMain}/kotlin/com/spotify/ruler/frontend/components/Ownership.kt (100%)
 rename ruler-frontend/src/{main => jsMain}/kotlin/com/spotify/ruler/frontend/components/PageControl.kt (100%)
 rename ruler-frontend/src/{main => jsMain}/resources/favicon.svg (100%)
 rename ruler-frontend/src/{main => jsMain}/resources/index.html (100%)
 rename ruler-frontend/src/{main => jsMain}/resources/style.css (100%)
 rename ruler-frontend/src/{test => jsTest}/kotlin/com/spotify/ruler/frontend/FormattingTest.kt (100%)

diff --git a/ruler-frontend-tests/build.gradle.kts b/ruler-frontend-tests/build.gradle.kts
index 5e7114a4..552f164b 100644
--- a/ruler-frontend-tests/build.gradle.kts
+++ b/ruler-frontend-tests/build.gradle.kts
@@ -32,7 +32,7 @@ tasks.withType<Test> {
     useJUnitPlatform()
 
     // Make development report available
-    dependsOn(":ruler-frontend:browserDevelopmentWebpack")
+    dependsOn(":ruler-frontend:jsBrowserDevelopmentWebpack")
 }
 
 kotlin {
diff --git a/ruler-frontend/build.gradle.kts b/ruler-frontend/build.gradle.kts
index acc198e3..2e08c3b8 100644
--- a/ruler-frontend/build.gradle.kts
+++ b/ruler-frontend/build.gradle.kts
@@ -15,7 +15,7 @@
  */
 
 plugins {
-    id("org.jetbrains.kotlin.js")
+    id("org.jetbrains.kotlin.multiplatform")
     id("io.gitlab.arturbosch.detekt")
 }
 
@@ -33,39 +33,39 @@ kotlin {
 }
 
 dependencies {
-    implementation(project(":ruler-models"))
+    "jsMainImplementation"(project(":ruler-models"))
 
-    implementation(Dependencies.KOTLIN_REACT)
-    implementation(Dependencies.KOTLIN_REACT_DOM)
-    implementation(Dependencies.KOTLIN_REACT_ROUTER)
-    implementation(Dependencies.KOTLIN_JS_EXTENSIONS)
-    implementation(Dependencies.KOTLINX_SERIALIZATION_JSON)
+    "jsMainImplementation"(Dependencies.KOTLIN_REACT)
+    "jsMainImplementation"(Dependencies.KOTLIN_REACT_DOM)
+    "jsMainImplementation"(Dependencies.KOTLIN_REACT_ROUTER)
+    "jsMainImplementation"(Dependencies.KOTLIN_JS_EXTENSIONS)
+    "jsMainImplementation"(Dependencies.KOTLINX_SERIALIZATION_JSON)
 
-    implementation(npm(Dependencies.REACT, Dependencies.Versions.REACT))
-    implementation(npm(Dependencies.REACT_DOM, Dependencies.Versions.REACT))
-    implementation(npm(Dependencies.BOOTSTRAP, Dependencies.Versions.BOOTSTRAP))
-    implementation(npm(Dependencies.APEX_CHARTS, Dependencies.Versions.APEX_CHARTS))
+    "jsMainImplementation"(npm(Dependencies.REACT, Dependencies.Versions.REACT))
+    "jsMainImplementation"(npm(Dependencies.REACT_DOM, Dependencies.Versions.REACT))
+    "jsMainImplementation"(npm(Dependencies.BOOTSTRAP, Dependencies.Versions.BOOTSTRAP))
+    "jsMainImplementation"(npm(Dependencies.APEX_CHARTS, Dependencies.Versions.APEX_CHARTS))
 
-    testImplementation(kotlin("test-js"))
+    "jsTestImplementation"(kotlin("test-js"))
 }
 
-val browserDist by configurations.creating {
+val browserDist: Configuration by configurations.creating {
     isCanBeConsumed = true
     isCanBeResolved = false
 }
 
 artifacts {
-    add(browserDist.name, tasks.named("browserDistribution").map { it.outputs.files.files.single() })
+    add(browserDist.name, tasks.named("jsBrowserDistribution").map { it.outputs.files.files.single() })
 }
 
-tasks.named("browserDevelopmentRun") {
-    dependsOn("developmentExecutableCompileSync")
+tasks.named("jsBrowserDevelopmentRun") {
+    dependsOn("jsDevelopmentExecutableCompileSync")
 }
 
-tasks.named("browserDevelopmentWebpack") {
-    dependsOn("productionExecutableCompileSync")
+tasks.named("jsBrowserDevelopmentWebpack") {
+    dependsOn("jsProductionExecutableCompileSync")
 }
 
-tasks.named("browserProductionWebpack") {
-    dependsOn("developmentExecutableCompileSync")
+tasks.named("jsBrowserProductionWebpack") {
+    dependsOn("jsDevelopmentExecutableCompileSync")
 }
diff --git a/ruler-frontend/src/main/kotlin/com/spotify/ruler/frontend/Formatting.kt b/ruler-frontend/src/jsMain/kotlin/com/spotify/ruler/frontend/Formatting.kt
similarity index 100%
rename from ruler-frontend/src/main/kotlin/com/spotify/ruler/frontend/Formatting.kt
rename to ruler-frontend/src/jsMain/kotlin/com/spotify/ruler/frontend/Formatting.kt
diff --git a/ruler-frontend/src/main/kotlin/com/spotify/ruler/frontend/Main.kt b/ruler-frontend/src/jsMain/kotlin/com/spotify/ruler/frontend/Main.kt
similarity index 100%
rename from ruler-frontend/src/main/kotlin/com/spotify/ruler/frontend/Main.kt
rename to ruler-frontend/src/jsMain/kotlin/com/spotify/ruler/frontend/Main.kt
diff --git a/ruler-frontend/src/main/kotlin/com/spotify/ruler/frontend/binding/ApexCharts.kt b/ruler-frontend/src/jsMain/kotlin/com/spotify/ruler/frontend/binding/ApexCharts.kt
similarity index 100%
rename from ruler-frontend/src/main/kotlin/com/spotify/ruler/frontend/binding/ApexCharts.kt
rename to ruler-frontend/src/jsMain/kotlin/com/spotify/ruler/frontend/binding/ApexCharts.kt
diff --git a/ruler-frontend/src/main/kotlin/com/spotify/ruler/frontend/chart/BarChartConfig.kt b/ruler-frontend/src/jsMain/kotlin/com/spotify/ruler/frontend/chart/BarChartConfig.kt
similarity index 100%
rename from ruler-frontend/src/main/kotlin/com/spotify/ruler/frontend/chart/BarChartConfig.kt
rename to ruler-frontend/src/jsMain/kotlin/com/spotify/ruler/frontend/chart/BarChartConfig.kt
diff --git a/ruler-frontend/src/main/kotlin/com/spotify/ruler/frontend/chart/ChartConfig.kt b/ruler-frontend/src/jsMain/kotlin/com/spotify/ruler/frontend/chart/ChartConfig.kt
similarity index 100%
rename from ruler-frontend/src/main/kotlin/com/spotify/ruler/frontend/chart/ChartConfig.kt
rename to ruler-frontend/src/jsMain/kotlin/com/spotify/ruler/frontend/chart/ChartConfig.kt
diff --git a/ruler-frontend/src/main/kotlin/com/spotify/ruler/frontend/chart/ChartUtils.kt b/ruler-frontend/src/jsMain/kotlin/com/spotify/ruler/frontend/chart/ChartUtils.kt
similarity index 100%
rename from ruler-frontend/src/main/kotlin/com/spotify/ruler/frontend/chart/ChartUtils.kt
rename to ruler-frontend/src/jsMain/kotlin/com/spotify/ruler/frontend/chart/ChartUtils.kt
diff --git a/ruler-frontend/src/main/kotlin/com/spotify/ruler/frontend/components/Breakdown.kt b/ruler-frontend/src/jsMain/kotlin/com/spotify/ruler/frontend/components/Breakdown.kt
similarity index 100%
rename from ruler-frontend/src/main/kotlin/com/spotify/ruler/frontend/components/Breakdown.kt
rename to ruler-frontend/src/jsMain/kotlin/com/spotify/ruler/frontend/components/Breakdown.kt
diff --git a/ruler-frontend/src/main/kotlin/com/spotify/ruler/frontend/components/Common.kt b/ruler-frontend/src/jsMain/kotlin/com/spotify/ruler/frontend/components/Common.kt
similarity index 100%
rename from ruler-frontend/src/main/kotlin/com/spotify/ruler/frontend/components/Common.kt
rename to ruler-frontend/src/jsMain/kotlin/com/spotify/ruler/frontend/components/Common.kt
diff --git a/ruler-frontend/src/main/kotlin/com/spotify/ruler/frontend/components/DynamicFeatures.kt b/ruler-frontend/src/jsMain/kotlin/com/spotify/ruler/frontend/components/DynamicFeatures.kt
similarity index 100%
rename from ruler-frontend/src/main/kotlin/com/spotify/ruler/frontend/components/DynamicFeatures.kt
rename to ruler-frontend/src/jsMain/kotlin/com/spotify/ruler/frontend/components/DynamicFeatures.kt
diff --git a/ruler-frontend/src/main/kotlin/com/spotify/ruler/frontend/components/Insights.kt b/ruler-frontend/src/jsMain/kotlin/com/spotify/ruler/frontend/components/Insights.kt
similarity index 100%
rename from ruler-frontend/src/main/kotlin/com/spotify/ruler/frontend/components/Insights.kt
rename to ruler-frontend/src/jsMain/kotlin/com/spotify/ruler/frontend/components/Insights.kt
diff --git a/ruler-frontend/src/main/kotlin/com/spotify/ruler/frontend/components/Ownership.kt b/ruler-frontend/src/jsMain/kotlin/com/spotify/ruler/frontend/components/Ownership.kt
similarity index 100%
rename from ruler-frontend/src/main/kotlin/com/spotify/ruler/frontend/components/Ownership.kt
rename to ruler-frontend/src/jsMain/kotlin/com/spotify/ruler/frontend/components/Ownership.kt
diff --git a/ruler-frontend/src/main/kotlin/com/spotify/ruler/frontend/components/PageControl.kt b/ruler-frontend/src/jsMain/kotlin/com/spotify/ruler/frontend/components/PageControl.kt
similarity index 100%
rename from ruler-frontend/src/main/kotlin/com/spotify/ruler/frontend/components/PageControl.kt
rename to ruler-frontend/src/jsMain/kotlin/com/spotify/ruler/frontend/components/PageControl.kt
diff --git a/ruler-frontend/src/main/resources/favicon.svg b/ruler-frontend/src/jsMain/resources/favicon.svg
similarity index 100%
rename from ruler-frontend/src/main/resources/favicon.svg
rename to ruler-frontend/src/jsMain/resources/favicon.svg
diff --git a/ruler-frontend/src/main/resources/index.html b/ruler-frontend/src/jsMain/resources/index.html
similarity index 100%
rename from ruler-frontend/src/main/resources/index.html
rename to ruler-frontend/src/jsMain/resources/index.html
diff --git a/ruler-frontend/src/main/resources/style.css b/ruler-frontend/src/jsMain/resources/style.css
similarity index 100%
rename from ruler-frontend/src/main/resources/style.css
rename to ruler-frontend/src/jsMain/resources/style.css
diff --git a/ruler-frontend/src/test/kotlin/com/spotify/ruler/frontend/FormattingTest.kt b/ruler-frontend/src/jsTest/kotlin/com/spotify/ruler/frontend/FormattingTest.kt
similarity index 100%
rename from ruler-frontend/src/test/kotlin/com/spotify/ruler/frontend/FormattingTest.kt
rename to ruler-frontend/src/jsTest/kotlin/com/spotify/ruler/frontend/FormattingTest.kt
diff --git a/ruler-gradle-plugin/build.gradle.kts b/ruler-gradle-plugin/build.gradle.kts
index caacc59c..686fb5ba 100644
--- a/ruler-gradle-plugin/build.gradle.kts
+++ b/ruler-gradle-plugin/build.gradle.kts
@@ -70,7 +70,7 @@ dependencies {
 
 // Include the output of the frontend JS compilation in the plugin resources
 sourceSets.main {
-    resources.srcDir(project(":ruler-frontend").tasks.named("browserDistribution"))
+    resources.srcDir(project(":ruler-frontend").tasks.named("jsBrowserDistribution"))
 }
 
 tasks.withType<Test> {