|
1 |
| -@file:Suppress("OPT_IN_USAGE") |
2 |
| - |
3 | 1 | import korlibs.korge.gradle.BuildVersions
|
4 |
| -import korlibs.korge.gradle.coroutinesVersion |
5 |
| -import korlibs.korge.gradle.kdsVersion |
6 |
| -import korlibs.korge.gradle.klockVersion |
7 |
| -import korlibs.korge.gradle.kmemVersion |
8 |
| -import korlibs.korge.gradle.korauVersion |
9 |
| -import korlibs.korge.gradle.korgwVersion |
10 |
| -import korlibs.korge.gradle.korimVersion |
11 |
| -import korlibs.korge.gradle.korioVersion |
12 |
| -import korlibs.korge.gradle.kormaVersion |
13 |
| -import korlibs.korge.gradle.kryptoVersion |
14 |
| -import korlibs.korge.gradle.util.staticHttpServer |
15 |
| -import kotlinx.benchmark.gradle.BenchmarksExtension |
16 |
| -import kotlinx.benchmark.gradle.KotlinJvmBenchmarkTarget |
17 |
| -import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsTargetDsl |
| 2 | +import korlibs.korge.gradle.korge |
18 | 3 |
|
19 | 4 | plugins {
|
20 |
| - id("com.soywiz.korge") |
21 |
| - id("org.jetbrains.kotlin.plugin.allopen") |
22 |
| - id("org.jetbrains.kotlinx.benchmark") |
23 |
| -} |
24 |
| - |
25 |
| -val korgeVersion: String by project |
26 |
| - |
27 |
| -allOpen { |
28 |
| - annotation("org.openjdk.jmh.annotations.State") |
| 5 | + alias(libs.plugins.korge) |
29 | 6 | }
|
30 | 7 |
|
31 |
| -val benchmarksExtension: BenchmarksExtension = the<BenchmarksExtension>() |
32 |
| - |
33 | 8 | korge {
|
34 |
| - id = "io.github.smaugfm.game2048" |
35 |
| - name = "game2048" |
36 |
| - esbuildVersion = "0.17.18" |
37 |
| - jvmMainClassName = "io.github.smaugfm.game2048.MainKt" |
| 9 | + id = "io.github.smaugfm.game2048" |
| 10 | + name = "game2048" |
| 11 | + skipDeps = true |
| 12 | + |
| 13 | + jvmMainClassName = "io.github.smaugfm.game2048.MainKt" |
| 14 | + entrypoint("main", "io.github.smaugfm.game2048.MainKt") |
38 | 15 |
|
39 |
| - targetJvm() |
40 |
| - targetJs() |
| 16 | + targetJvm() |
| 17 | +// targetJs() |
| 18 | +// targetWasmJs() |
| 19 | + serializationJson() |
41 | 20 | }
|
42 | 21 |
|
43 | 22 | afterEvaluate {
|
44 |
| - project.configurations |
45 |
| - .filter { it.name.startsWith("commonMain") } |
46 |
| - .forEach { conf -> |
47 |
| - conf.dependencies |
48 |
| - .removeIf { |
49 |
| - it.group?.startsWith("com.soywiz") == true || |
50 |
| - it.group?.startsWith("korlibs") == true || |
51 |
| - (it.group == "org.jetbrains.kotlinx" && it.name == "kotlinx-coroutines-core") || |
52 |
| - (it.group == "org.jetbrains.kotlinx" && it.name == "kotlinx-serialization-json") |
53 |
| - } |
| 23 | + project.configurations |
| 24 | + .filter { it.name.startsWith("commonMain") } |
| 25 | + .forEach { conf -> |
| 26 | + conf.dependencies |
| 27 | + .removeIf { |
| 28 | + it.group?.startsWith("com.soywiz") == true || |
| 29 | + it.group?.startsWith("korlibs") == true || |
| 30 | + (it.group == "org.jetbrains.kotlinx" && it.name == "kotlinx-coroutines-core") || |
| 31 | + (it.group == "org.jetbrains.kotlinx" && it.name == "kotlinx-serialization-json") |
54 | 32 | }
|
| 33 | + } |
55 | 34 | }
|
56 | 35 |
|
57 | 36 | kotlin {
|
58 |
| - targets { |
59 |
| - jvm { |
60 |
| - val benchmarkCompilation = compilations |
61 |
| - .create("benchmark") |
62 |
| - |
63 |
| - benchmarksExtension.targets.add( |
64 |
| - KotlinJvmBenchmarkTarget( |
65 |
| - extension = benchmarksExtension, |
66 |
| - name = "jvm", |
67 |
| - compilation = benchmarkCompilation |
68 |
| - ).apply { |
69 |
| - val jmhVersion: String by project |
70 |
| - this.jmhVersion = jmhVersion |
71 |
| - } |
72 |
| - ) |
73 |
| - } |
74 |
| - fun KotlinJsTargetDsl.configureJsOrWasm() { |
75 |
| - fun snakeToDashes(s: String) = |
76 |
| - s.replace("\\B[A-Z]".toRegex()) { |
77 |
| - "-${it.value}" |
78 |
| - }.toLowerCase() |
79 |
| - |
80 |
| - binaries.executable() |
81 |
| - val targetName = this@configureJsOrWasm.name |
82 |
| - browser { |
83 |
| - webpackTask { |
84 |
| - outputFileName = "${snakeToDashes(targetName)}.js" |
85 |
| - } |
86 |
| - distribution { |
87 |
| - name = targetName |
88 |
| - } |
89 |
| - } |
90 |
| - } |
91 |
| - wasm("wasmTest") { |
92 |
| - configureJsOrWasm() |
93 |
| - } |
94 |
| - js("jsWorker", IR) { |
95 |
| - configureJsOrWasm() |
96 |
| - } |
97 |
| - wasm("wasmWorker") { |
98 |
| - configureJsOrWasm() |
99 |
| - } |
| 37 | + sourceSets { |
| 38 | + val commonMain by getting |
| 39 | + val commonKorge by creating { |
| 40 | + dependsOn(commonMain) |
| 41 | + dependencies { |
| 42 | + implementation("com.soywiz.korge:korge-core:${BuildVersions.KORGE}") |
| 43 | + implementation("com.soywiz.korge:korge:${BuildVersions.KORGE}") |
| 44 | + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:${BuildVersions.KOTLIN_SERIALIZATION}") |
| 45 | + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${BuildVersions.COROUTINES}") |
| 46 | + } |
100 | 47 | }
|
101 |
| - sourceSets { |
102 |
| - all { |
103 |
| - languageSettings.optIn("kotlin.ExperimentalUnsignedTypes") |
104 |
| - languageSettings.optIn("kotlin.time.ExperimentalTime") |
105 |
| - } |
106 |
| - val commonMain by getting |
107 |
| - val commonKorge by creating { |
108 |
| - dependsOn(commonMain) |
109 |
| - dependencies { |
110 |
| - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:${BuildVersions.KOTLIN_SERIALIZATION}") |
111 |
| - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") |
112 |
| - implementation("com.soywiz.korlibs.klock:klock:${klockVersion}") |
113 |
| - implementation("com.soywiz.korlibs.kmem:kmem:${kmemVersion}") |
114 |
| - implementation("com.soywiz.korlibs.kds:kds:${kdsVersion}") |
115 |
| - implementation("com.soywiz.korlibs.krypto:krypto:${kryptoVersion}") |
116 |
| - implementation("com.soywiz.korlibs.korge2:korge:${korgeVersion}") |
117 |
| - implementation("com.soywiz.korlibs.korma:korma:${kormaVersion}") |
118 |
| - implementation("com.soywiz.korlibs.korio:korio:${korioVersion}") |
119 |
| - implementation("com.soywiz.korlibs.korim:korim:${korimVersion}") |
120 |
| - implementation("com.soywiz.korlibs.korau:korau:${korauVersion}") |
121 |
| - implementation("com.soywiz.korlibs.korgw:korgw:${korgwVersion}") |
122 |
| - } |
123 |
| - } |
124 |
| - val commonBenchmark by creating { |
125 |
| - dependsOn(commonMain) |
126 |
| - dependencies { |
127 |
| - implementation("org.jetbrains.kotlinx:kotlinx-benchmark-runtime:0.4.7") |
128 |
| - } |
129 |
| - } |
130 |
| - val jsMain by getting { |
131 |
| - dependsOn(commonKorge) |
132 |
| - // Make gradle to copy the *.js and *.wasm files to the output dir for the |
133 |
| - // main js target |
134 |
| - resources.srcDirs("./build/jsWorker") |
135 |
| - resources.srcDirs("./build/wasmWorker") |
136 |
| - resources.srcDirs("./build/wasmTest") |
137 |
| - } |
138 |
| - val jvmMain by getting { |
139 |
| - dependsOn(commonKorge) |
140 |
| - } |
141 |
| - val jvmBenchmark by getting { |
142 |
| - dependsOn(commonBenchmark) |
143 |
| - dependsOn(jvmMain) |
144 |
| - } |
145 |
| - val jsWorkerMain by getting |
146 |
| - val wasmWorkerMain by getting { |
147 |
| - dependencies { |
148 |
| - // For the hacks to work. |
149 |
| - // See ./webpack.config.d/wasm-worker.webpack.config.js |
150 |
| - implementation(npm("copy-webpack-plugin", "11.0.0")) |
151 |
| - implementation(npm("string-replace-loader", "3.1.0")) |
152 |
| - } |
153 |
| - } |
154 |
| - val wasmTestMain by getting { |
155 |
| - dependencies { |
156 |
| - implementation(npm("copy-webpack-plugin", "11.0.0")) |
157 |
| - implementation(npm("string-replace-loader", "3.1.0")) |
158 |
| - } |
159 |
| - } |
| 48 | + val jvmMain by getting { |
| 49 | + dependsOn(commonKorge) |
160 | 50 | }
|
| 51 | + } |
161 | 52 | }
|
162 | 53 |
|
163 |
| -tasks { |
164 |
| - // Make main js target be dependent on wasm targets |
165 |
| - getByName("jsProcessResources") |
166 |
| - .dependsOn( |
167 |
| - "jsWorkerBrowserDistribution", |
168 |
| - "wasmWorkerBrowserDistribution", |
169 |
| - "wasmTestBrowserDistribution" |
170 |
| - ) |
171 |
| - getByName("jsBrowserProductionWebpack") |
172 |
| - .dependsOn( |
173 |
| - "jsWorkerBrowserProductionWebpack", |
174 |
| - "wasmWorkerBrowserProductionWebpack", |
175 |
| - "wasmTestBrowserProductionWebpack" |
176 |
| - ) |
177 |
| - getByName("jsBrowserDevelopmentWebpack") |
178 |
| - .dependsOn( |
179 |
| - "jsWorkerBrowserDevelopmentWebpack", |
180 |
| - "wasmWorkerBrowserDevelopmentWebpack", |
181 |
| - "wasmTestBrowserDevelopmentWebpack" |
182 |
| - ) |
183 |
| -} |
184 |
| - |
185 |
| -benchmark { |
186 |
| - configurations { |
187 |
| - register("findBestMove") { |
188 |
| - include(".*FindBestMoveBenchmark.*") |
189 |
| - } |
190 |
| - register("moveBoard") { |
191 |
| - include(".*MoveBoardBenchmark.*") |
192 |
| - } |
193 |
| - } |
194 |
| -} |
0 commit comments