UI improvements, CLI fallbacks
This commit is contained in:
@@ -10,6 +10,24 @@ plugins {
|
||||
alias(libs.plugins.composeMultiplatform)
|
||||
alias(libs.plugins.composeCompiler)
|
||||
alias(libs.plugins.serialization)
|
||||
alias(libs.plugins.buildconfig)
|
||||
}
|
||||
|
||||
version = "1.0.1"
|
||||
val versionDirectory = layout.buildDirectory.dir("generated/sources/version")
|
||||
|
||||
val generateVersion = tasks.register<Task>("clientVersion") {
|
||||
doFirst {
|
||||
val outFile = versionDirectory.get().file("com/jaytux/phoebench/client/Version.kt").asFile
|
||||
outFile.parentFile.mkdirs()
|
||||
outFile.writeText("""
|
||||
package com.jaytux.phoebench.client
|
||||
|
||||
object ClientVersion {
|
||||
const val VERSION="${rootProject.version}"
|
||||
}
|
||||
""".trimIndent())
|
||||
}
|
||||
}
|
||||
|
||||
kotlin {
|
||||
@@ -86,6 +104,20 @@ kotlin {
|
||||
wasmJsMain.dependencies {
|
||||
implementation(libs.ktor.client.js)
|
||||
}
|
||||
|
||||
commonMain {
|
||||
kotlin {
|
||||
srcDir(versionDirectory)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
targets.all {
|
||||
compilations.all {
|
||||
compileTaskProvider.configure {
|
||||
dependsOn(generateVersion)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +128,7 @@ compose.desktop {
|
||||
nativeDistributions {
|
||||
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
|
||||
packageName = "com.jaytux.phoebench.clients"
|
||||
packageVersion = rootProject.version.toString().split('-')[0]
|
||||
packageVersion = version.toString()
|
||||
|
||||
jvmArgs += listOf("--enable-native-access=ALL-UNNAMED")
|
||||
includeAllModules = true
|
||||
@@ -105,4 +137,33 @@ compose.desktop {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun envValue(key: String): String? {
|
||||
val fromEnv = providers.environmentVariable(key).orNull
|
||||
if(fromEnv != null) return fromEnv
|
||||
|
||||
val envFile = rootProject.file(".env")
|
||||
if(!envFile.exists()) return null
|
||||
|
||||
return envFile.useLines { lines ->
|
||||
lines.map { it.trim() }.filter { it.isNotBlank() && !it.startsWith('#') && '=' in it }
|
||||
.map { line ->
|
||||
val (k, v) = line.split('=', limit = 2)
|
||||
k.trim() to v.trim().removeSurrounding("\"").removeSurrounding("'")
|
||||
}
|
||||
.firstOrNull { it.first == key }?.second
|
||||
}
|
||||
}
|
||||
|
||||
buildConfig {
|
||||
sourceSets.getByName("wasmJsMain") {
|
||||
val serverUrl = envValue("WASM_SERVER_URL") ?:
|
||||
throw GradleException("MISSING CONFIGURATION: WASM_SERVER_URL. Please set it as environment variable or `.env` variable.")
|
||||
|
||||
className("WasmConfig")
|
||||
packageName("com.jaytux.phoebench.clients")
|
||||
useKotlinOutput()
|
||||
buildConfigField("SERVER_URL", serverUrl)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user