diff --git a/.gitignore b/.gitignore index b1775d2..13840fd 100644 --- a/.gitignore +++ b/.gitignore @@ -46,4 +46,5 @@ bin/ *.db .env -.idea/ \ No newline at end of file +.idea/ +artifacts/ \ No newline at end of file diff --git a/build-all.sh b/build-all.sh new file mode 100755 index 0000000..118e979 --- /dev/null +++ b/build-all.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -e + +./gradlew :clients:cli:shadowJar +./gradlew :clients:compose:createDistributable +./gradlew :clients:compose:wasmJsBrowserProductionWebpack +./gradlew :server:installDist + +mkdir -p artifacts +cp clients/cli/build/libs/phoebench-cli.jar artifacts/ + +(cd clients/compose/build/compose/binaries/main/app/com.jaytux.phoebench.clients && zip phoebench-linux.zip -r bin/ lib/) +cp clients/compose/build/compose/binaries/main/app/com.jaytux.phoebench.clients/phoebench-linux.zip artifacts/ + +mkdir -p artifacts/wasm +cp clients/compose/build/kotlin-webpack/wasmJs/productionExecutable/* clients/compose/src/wasmJsMain/resources/* artifacts/wasm +(cd artifacts/wasm && zip phoebench-wasm.zip -r ./*) +mv artifacts/wasm/phoebench-wasm.zip artifacts/ +rm -fr artifacts/wasm + +(cd server/build/install/server/ && zip phoebench-server.zip -r bin/ lib/) +cp server/build/install/server/phoebench-server.zip artifacts \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 9174dce..8698354 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,4 +12,4 @@ repositories { mavenCentral() } -version = "0.2.0-dev" \ No newline at end of file +version = "1.0.0-dev" \ No newline at end of file diff --git a/clients/cli/build.gradle.kts b/clients/cli/build.gradle.kts index efa9788..ca81f90 100644 --- a/clients/cli/build.gradle.kts +++ b/clients/cli/build.gradle.kts @@ -1,3 +1,5 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + plugins { alias(libs.plugins.jvm) application @@ -40,4 +42,8 @@ kotlin { freeCompilerArgs.add("-Xcontext-parameters") optIn.add("kotlin.uuid.ExperimentalUuidApi") } +} + +tasks.withType { + archiveFileName = "phoebench-cli.jar" } \ No newline at end of file diff --git a/clients/compose/build.gradle.kts b/clients/compose/build.gradle.kts index 9a161b7..0c0c330 100644 --- a/clients/compose/build.gradle.kts +++ b/clients/compose/build.gradle.kts @@ -97,6 +97,12 @@ compose.desktop { targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) packageName = "com.jaytux.phoebench.clients" packageVersion = rootProject.version.toString().split('-')[0] + + jvmArgs += listOf("--enable-native-access=ALL-UNNAMED") + includeAllModules = true + buildTypes.release.proguard { + configurationFiles.from(file("proguard-rules.pro")) + } } } } \ No newline at end of file diff --git a/clients/compose/proguard-rules.pro b/clients/compose/proguard-rules.pro new file mode 100644 index 0000000..f5a880d --- /dev/null +++ b/clients/compose/proguard-rules.pro @@ -0,0 +1,11 @@ +-keep class com.github.javakeyring.** { *; } +-dontwarn com.github.javakeyring.** + +-keep class com.sun.jna.** { *; } +-dontwarn com.sun.jna.** +-keepclassmembers class * extends com.sun.jna.Structure { + *** *; +} +-keepclassmembers class * extends com.sun.jna.Callback { + *** *; +} \ No newline at end of file diff --git a/server/build.gradle.kts b/server/build.gradle.kts index f287f2c..f7285b6 100644 --- a/server/build.gradle.kts +++ b/server/build.gradle.kts @@ -1,3 +1,5 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + plugins { alias(libs.plugins.jvm) alias(libs.plugins.ktor) @@ -5,7 +7,6 @@ plugins { } group = "com.jaytux.phoebench" -//version = "1.0-SNAPSHOT" repositories { mavenCentral() @@ -65,12 +66,22 @@ kotlin { } application { - mainClass.set("com.jaytux.phoebench.server.MainKt") + mainClass = "io.ktor.server.netty.EngineMain" } tasks.withType { manifest { attributes["Main-Class"] = application.mainClass } - duplicatesStrategy = DuplicatesStrategy.EXCLUDE + duplicatesStrategy = DuplicatesStrategy.WARN +} + +ktor { + fatJar { + } +} + +tasks.withType { + mergeServiceFiles() + append("reference.conf") } \ No newline at end of file diff --git a/server/src/main/kotlin/com/jaytux/phoebench/server/Main.kt b/server/src/main/kotlin/com/jaytux/phoebench/server/Main.kt index fc97236..317fd30 100644 --- a/server/src/main/kotlin/com/jaytux/phoebench/server/Main.kt +++ b/server/src/main/kotlin/com/jaytux/phoebench/server/Main.kt @@ -10,7 +10,6 @@ import io.ktor.serialization.kotlinx.json.* import io.ktor.server.application.* import io.ktor.server.auth.* import io.ktor.server.auth.jwt.* -import io.ktor.server.netty.* import io.ktor.server.plugins.autohead.* import io.ktor.server.plugins.calllogging.* import io.ktor.server.plugins.contentnegotiation.* @@ -24,12 +23,10 @@ import kotlinx.serialization.json.Json import org.jetbrains.exposed.v1.jdbc.transactions.transaction import kotlin.uuid.Uuid -fun main(args: Array) { - DB.db - EngineMain.main(args) -} - fun Application.module() { + DB.db + println("Entering module...") + install(ContentNegotiation) { json() } @@ -147,22 +144,22 @@ fun Application.module() { get("{...}") { println("Fallback for GET ${call.request.path()} triggered.") - call.respond(HttpStatusCode.NotFound, ErrorResponse("Could not find ${call.request.path()}")) + call.respondText(status = HttpStatusCode.NotFound, text = Json.encodeToString(ErrorResponse("Could not find ${call.request.path()}")), contentType = ContentType.Application.Json) } post("{...}") { println("Fallback for POST ${call.request.path()} triggered.") - call.respond(HttpStatusCode.NotFound, ErrorResponse("Could not find ${call.request.path()}")) + call.respondText(status = HttpStatusCode.NotFound, text = Json.encodeToString(ErrorResponse("Could not find ${call.request.path()}")), contentType = ContentType.Application.Json) } delete("{...}") { println("Fallback for DELETE ${call.request.path()} triggered.") - call.respond(HttpStatusCode.NotFound, ErrorResponse("Could not find ${call.request.path()}")) + call.respondText(status = HttpStatusCode.NotFound, text = Json.encodeToString(ErrorResponse("Could not find ${call.request.path()}")), contentType = ContentType.Application.Json) } patch("{...}") { println("Fallback for PATCH ${call.request.path()} triggered.") - call.respond(HttpStatusCode.NotFound, ErrorResponse("Could not find ${call.request.path()}")) + call.respondText(status = HttpStatusCode.NotFound, text = Json.encodeToString(ErrorResponse("Could not find ${call.request.path()}")), contentType = ContentType.Application.Json) } } } \ No newline at end of file diff --git a/server/src/main/resources/application.conf b/server/src/main/resources/application.conf index aacf71b..b56c2b0 100644 --- a/server/src/main/resources/application.conf +++ b/server/src/main/resources/application.conf @@ -1,18 +1,23 @@ ktor { deployment { - port = ${PORT} + port = 8080 + port = ${?PORT} } application { modules = [com.jaytux.phoebench.server.MainKt.module] } jwt { - secret = ${JWT_SECRET} - issuer = ${JWT_ISSUER} - audience = ${JWT_AUDIENCE} - realm = ${JWT_REALM} + secret = "NO_SECRET_SET!" + secret = ${?JWT_SECRET} + issuer = "http://0.0.0.0" + issuer = ${?JWT_ISSUER} + audience = "http://0.0.0.0" + audience = ${?JWT_AUDIENCE} + realm = "phoebench" + realm = ${?JWT_REALM} } cors { - enableLocalhostOn = ${PHOEBENCH_DEV_CLIENT_PORT} + enableLocalhostOn = ${?PHOEBENCH_DEV_CLIENT_PORT} browserOrigin = ${?PHOEBENCH_SAFE_CLIENT} }