1
1
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack
2
2
3
- val kotlinVersion = " 1.8.21"
4
- val serializationVersion = " 1.5.1"
3
+ val serializationVersion = " 1.6.2"
5
4
val ktorVersion = " 2.3.0"
6
5
val logbackVersion = " 1.2.11"
7
6
val kotlinWrappersVersion = " 1.0.0-pre.561"
8
7
val kmongoVersion = " 4.5.0"
9
8
10
9
plugins {
11
- kotlin(" multiplatform" ) version " 1.8 .21"
10
+ kotlin(" multiplatform" ) version " 1.9 .21"
12
11
application // to run JVM part
13
- kotlin(" plugin.serialization" ) version " 1.8.21"
12
+ kotlin(" plugin.serialization" ) version " 1.9.21"
13
+ id(" org.jetbrains.compose" ) version " 1.6.0-alpha01"
14
14
}
15
15
16
16
group = " org.example"
17
17
version = " 1.0-SNAPSHOT"
18
18
19
19
repositories {
20
20
mavenCentral()
21
+ maven(" https://maven.pkg.jetbrains.space/public/p/compose/dev" )
21
22
}
22
23
23
24
kotlin {
@@ -29,11 +30,15 @@ kotlin {
29
30
binaries.executable()
30
31
}
31
32
}
33
+ wasmJs {
34
+ browser {
35
+ binaries.executable()
36
+ }
37
+ }
32
38
sourceSets {
33
39
val commonMain by getting {
34
40
dependencies {
35
41
implementation(" org.jetbrains.kotlinx:kotlinx-serialization-json:$serializationVersion " )
36
- implementation(" io.ktor:ktor-client-core:$ktorVersion " )
37
42
}
38
43
}
39
44
@@ -46,6 +51,7 @@ kotlin {
46
51
47
52
val jvmMain by getting {
48
53
dependencies {
54
+ implementation(" io.ktor:ktor-client-core:$ktorVersion " )
49
55
implementation(" io.ktor:ktor-serialization:$ktorVersion " )
50
56
implementation(" io.ktor:ktor-server-content-negotiation:$ktorVersion " )
51
57
implementation(" io.ktor:ktor-serialization-kotlinx-json:$ktorVersion " )
@@ -60,6 +66,7 @@ kotlin {
60
66
61
67
val jsMain by getting {
62
68
dependencies {
69
+ implementation(" io.ktor:ktor-client-core:$ktorVersion " )
63
70
implementation(" io.ktor:ktor-client-js:$ktorVersion " )
64
71
implementation(" io.ktor:ktor-client-content-negotiation:$ktorVersion " )
65
72
implementation(" io.ktor:ktor-serialization-kotlinx-json:$ktorVersion " )
@@ -68,13 +75,28 @@ kotlin {
68
75
implementation(" org.jetbrains.kotlin-wrappers:kotlin-react-dom" )
69
76
}
70
77
}
78
+
79
+ val wasmJsMain by getting {
80
+ dependencies {
81
+ implementation(compose.runtime)
82
+ implementation(compose.ui)
83
+ implementation(compose.foundation)
84
+ implementation(compose.material3)
85
+ @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary ::class )
86
+ implementation(compose.components.resources)
87
+ }
88
+ }
71
89
}
72
90
}
73
91
74
92
application {
75
93
mainClass.set(" ServerKt" )
76
94
}
77
95
96
+ compose.experimental {
97
+ web.application {}
98
+ }
99
+
78
100
// include JS artifacts in any JAR we generate
79
101
tasks.named<Jar >(" jvmJar" ).configure {
80
102
val taskName = if (project.hasProperty(" isProduction" )
@@ -85,7 +107,9 @@ tasks.named<Jar>("jvmJar").configure {
85
107
" jsBrowserDevelopmentWebpack"
86
108
}
87
109
val webpackTask = tasks.named<KotlinWebpack >(taskName)
88
- from(webpackTask.map { File (it.destinationDirectory, it.outputFileName) }) // bring output file along into the JAR
110
+ from(webpackTask.map { it.outputDirectory }) // bring output file along into the JAR
111
+ into(" static" )
112
+ duplicatesStrategy = DuplicatesStrategy .EXCLUDE
89
113
}
90
114
91
115
tasks {
@@ -114,4 +138,4 @@ tasks.register("stage") {
114
138
115
139
tasks.named<JavaExec >(" run" ).configure {
116
140
classpath(tasks.named<Jar >(" jvmJar" )) // so that the JS artifacts generated by `jvmJar` can be found and served
117
- }
141
+ }
0 commit comments