-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
195 lines (168 loc) · 7.67 KB
/
build.gradle.kts
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
import com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer
import org.gradle.kotlin.dsl.support.listFilesOrdered
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockMismatchReport
import org.jetbrains.kotlin.gradle.targets.js.yarn.yarn
plugins {
kotlin("multiplatform") version "1.9.0"
kotlin("plugin.serialization") version "1.9.0"
application
id("com.github.johnrengelman.shadow") version "8.1.1"
}
group = "com.bkahlert.netmon"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
kotlin {
// scanner component
// not using native, because the target "linuxArm32Hfp" (required for Raspberry Pi Zero)
// is no longer supported in Kotlin 1.9.20
jvm {
compilations.all {
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
}
}
}
// viewer component
js(IR) {
browser {
commonWebpackConfig(Action<KotlinWebpackConfig> {
devServer = devServer?.copy(open = false)
})
}
yarn.apply {
ignoreScripts = false // suppress "warning Ignored scripts due to flag." warning
yarnLockMismatchReport = YarnLockMismatchReport.NONE
reportNewYarnLock = true // true
yarnLockAutoReplace = true // true
}
}.binaries.executable()
sourceSets {
val commonMain by getting {
dependencies {
implementation(platform("com.bkahlert.kommons:kommons-bom:2.8.0"))
implementation("com.bkahlert.kommons:kommons-time")
implementation(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.7.1"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core")
implementation(platform("org.jetbrains.kotlinx:kotlinx-serialization-bom:1.5.1"))
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
implementation(platform("io.kotest:kotest-bom:5.6.2"))
implementation("io.kotest:kotest-common")
implementation("io.kotest:kotest-assertions-core")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test")
}
}
val jvmMain by getting {
dependencies {
implementation("com.bkahlert.kommons:kommons-logging-core")
implementation("com.bkahlert.kommons:kommons-logging-logback")
implementation("com.bkahlert.kommons:kommons-exec") { because("CommandLine, ShellScript") }
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-slf4j")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-debug")
implementation("com.hivemq:hivemq-mqtt-client:1.3.0") { because("publish scans") }
implementation(platform("com.hivemq:hivemq-mqtt-client-websocket:1.3.0"))
implementation("org.jmdns:jmdns:3.5.8") { because("mDNS / Bonjour based hostname resolution") }
}
languageSettings.optIn("kotlin.io.path.ExperimentalPathApi")
}
val jvmTest by getting {
dependencies {
implementation("io.kotest:kotest-assertions-json")
implementation(platform("org.testcontainers:testcontainers-bom:1.19.6"))
implementation("org.testcontainers:testcontainers")
}
languageSettings.optIn("kotlin.io.path.ExperimentalPathApi")
}
val jsMain by getting {
dependencies {
implementation("com.bkahlert.kommons:kommons-uri")
val fritz2Version = "1.0-RC6"
implementation("dev.fritz2:core:$fritz2Version")
implementation("dev.fritz2:headless:$fritz2Version")
// tailwind
implementation(npm("tailwindcss", "^3.3.3")) { because("low-level CSS classes") }
// optional tailwind plugins
implementation(devNpm("@tailwindcss/typography", "^0.5")) { because("prose classes to format arbitrary text") }
implementation(devNpm("tailwind-heropatterns", "^0.0.8")) { because("hero-pattern like striped backgrounds") }
// webpack
implementation(devNpm("postcss", "^8.4.17")) { because("CSS post transformation, e.g. auto-prefixing") }
implementation(devNpm("postcss-loader", "^7.0.1")) { because("Loader to process CSS with PostCSS") }
implementation(devNpm("postcss-import", "^15.1")) { because("@import support") }
implementation(devNpm("autoprefixer", "10.4.12")) { because("auto-prefixing by PostCSS") }
implementation(devNpm("css-loader", "6.7.1"))
implementation(devNpm("style-loader", "3.3.1"))
implementation(devNpm("cssnano", "5.1.13")) { because("CSS minification by PostCSS") }
}
}
all {
languageSettings.optIn("kotlin.RequiresOptIn")
languageSettings.optIn("kotlin.ExperimentalStdlibApi")
languageSettings.optIn("kotlin.ExperimentalUnsignedTypes")
languageSettings.optIn("kotlin.io.encoding.ExperimentalEncodingApi")
languageSettings.optIn("kotlin.time.ExperimentalTime")
languageSettings.optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
languageSettings.optIn("kotlinx.coroutines.FlowPreview")
languageSettings.optIn("kotlinx.serialization.ExperimentalSerializationApi")
}
}
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
// verify by passing "--info" to gradle, and
// look for: [KOTLIN] Kotlin compilation 'jdkHome' argument:
// see https://kotlinlang.org/docs/gradle-configure-project.html#gradle-java-toolchains-support
}
}
application {
mainClass.set("com.bkahlert.netmon.Application")
}
tasks {
withType<Jar> {
archiveVersion.set("")
}
shadowJar {
archiveVersion.set("")
configurations = listOf(
project.configurations["jvmRuntimeClasspath"],
project.configurations["jvmTestRuntimeClasspath"], // don't know why, but doesn't find "com.bkahlert.netmon.Application" otherwise
)
mergeServiceFiles()
transform(Log4j2PluginsCacheFileTransformer::class.java)
}
assemble {
finalizedBy(shadowJar)
}
}
tasks {
val removalPattern = listOf(
Regex("\\.(json)\$"),
Regex("\\.(jpe?g|png|gif|svg)\$"),
Regex("\\.(woff|woff2|eot|ttf|otf)\$"),
Regex("mqtt(\\.min)?\\.js\$"),
Regex("\\.(css)\$"),
)
val removalFilter: (File) -> Boolean = { file ->
removalPattern.any { it.containsMatchIn(file.name) }
}
val productionBuilds = withType<KotlinWebpack>().matching { it.name.endsWith("ProductionWebpack") }
val cleanUpProductionBuild by registering(Delete::class) {
mustRunAfter(productionBuilds)
doLast {
productionBuilds
.flatMap { task -> task.outputs.files.filter { it.isDirectory } }
.forEach { distDir -> distDir.listFilesOrdered(removalFilter).forEach { it.delete() } }
}
}
productionBuilds.configureEach { finalizedBy(cleanUpProductionBuild) }
}