-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
99 lines (83 loc) · 2.94 KB
/
build.gradle.kts
File metadata and controls
99 lines (83 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
@file:OptIn(ExperimentalWasmDsl::class)
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
plugins {
alias(libs.plugins.compose.hot.reload)
alias(libs.plugins.keelim.multiplatform)
}
kotlin {
androidLibrary {
namespace = "com.keelim.all"
}
sourceSets {
val desktopMain by getting
commonMain.dependencies {
implementation(projects.core.component)
}
desktopMain.dependencies {
implementation(compose.desktop.currentOs)
}
}
}
compose.desktop {
application {
mainClass = "com.keelim.all.Main.kt"
nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageName = "com.keelim.all"
packageVersion = "1.0.0"
macOS {
dockName = "all"
}
windows {
packageName = "all"
}
linux {
packageName = "all"
}
}
}
}
// From KotlinConf App
// https://github.com/JetBrains/kotlinconf-app/blob/c81492ee57a8da67390d84ad29f41b08128fe0e1/shared/build.gradle.kts#L193
val buildWebApp by tasks.registering(Copy::class) {
val wasmDist = "wasmJsBrowserDistribution"
from(tasks.named(wasmDist).get().outputs.files)
into(layout.buildDirectory.dir("webApp"))
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
val checkWasmBundleBudget by tasks.registering {
group = "verification"
description = "Checks composeApp and skiko wasm binaries against bundle size budgets."
dependsOn("wasmJsBrowserDistribution")
notCompatibleWithConfigurationCache("Reads generated wasm bundle files during execution.")
doLast {
val composeAppWasmBudgetBytes = 2_200_000L
val skikoWasmBudgetBytes = 9_000_000L
val composeAppWasm = layout.buildDirectory
.file("compileSync/wasmJs/main/productionExecutable/optimized/composeApp.wasm")
.get()
.asFile
val skikoWasm = layout.buildDirectory
.file("compose/skiko-runtime-processed-wasmjs/skiko.wasm")
.get()
.asFile
check(composeAppWasm.exists()) {
"Missing composeApp.wasm bundle at ${composeAppWasm.path}"
}
check(skikoWasm.exists()) {
"Missing skiko.wasm bundle at ${skikoWasm.path}"
}
val composeAppWasmSize = composeAppWasm.length()
val skikoWasmSize = skikoWasm.length()
check(composeAppWasmSize <= composeAppWasmBudgetBytes) {
"composeApp.wasm is ${composeAppWasmSize} bytes and exceeds budget ${composeAppWasmBudgetBytes} bytes."
}
check(skikoWasmSize <= skikoWasmBudgetBytes) {
"skiko.wasm is ${skikoWasmSize} bytes and exceeds budget ${skikoWasmBudgetBytes} bytes."
}
}
}
buildWebApp.configure {
dependsOn(checkWasmBundleBudget)
}