103 lines
2.8 KiB
Kotlin
103 lines
2.8 KiB
Kotlin
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
|
|
|
plugins {
|
|
alias(libs.plugins.jvm)
|
|
application
|
|
alias(libs.plugins.serialization)
|
|
alias(libs.plugins.shadow)
|
|
alias(libs.plugins.buildconfig)
|
|
}
|
|
|
|
group = "com.jaytux.phoebench"
|
|
version = rootProject.version as PhoebenchVersion
|
|
|
|
if((version as PhoebenchVersion) < (rootProject.version as PhoebenchVersion))
|
|
throw GradleException("CLI Client version must be at least as high as protocol/common version")
|
|
|
|
val versionDirectory = layout.buildDirectory.dir("generated/sources/version")
|
|
val generateVersion = tasks.register<Task>("serverVersion") {
|
|
doFirst {
|
|
val outFile = versionDirectory.get().file("com/jaytux/phoebench/client/cli/Version.kt").asFile
|
|
outFile.parentFile.mkdirs()
|
|
outFile.writeText("""
|
|
package com.jaytux.phoebench.client.cli
|
|
|
|
object CliVersion {
|
|
const val VERSION="$version"
|
|
}
|
|
""".trimIndent())
|
|
}
|
|
}
|
|
|
|
val isDebug = envValue("PHOEBENCH_BUILD_RELEASE") == null
|
|
|
|
dependencies {
|
|
implementation(kotlin("stdlib"))
|
|
implementation(libs.clikt)
|
|
implementation(libs.ktor.client.core)
|
|
implementation(libs.ktor.client.auth)
|
|
implementation(libs.ktor.client.content.negotiation)
|
|
implementation(libs.ktor.client.websocket)
|
|
implementation(libs.kotlinx.datetime)
|
|
implementation(libs.kotlinx.serialization)
|
|
implementation(project(":common"))
|
|
implementation(kotlin("reflect"))
|
|
implementation(libs.ktor.client.okhttp)
|
|
implementation(libs.slf4j.simple)
|
|
implementation(libs.java.keystore)
|
|
implementation(libs.ktor.serialization.kotlinx.json)
|
|
implementation(libs.process)
|
|
}
|
|
|
|
application {
|
|
mainClass = "com.jaytux.phoebench.clients.cli.MainKt"
|
|
}
|
|
|
|
tasks.withType<Jar> {
|
|
manifest {
|
|
attributes["Main-Class"] = application.mainClass
|
|
}
|
|
}
|
|
|
|
kotlin {
|
|
jvmToolchain(21)
|
|
compilerOptions {
|
|
freeCompilerArgs.add("-Xcontext-parameters")
|
|
optIn.add("kotlin.uuid.ExperimentalUuidApi")
|
|
}
|
|
|
|
sourceSets {
|
|
val main by getting {
|
|
kotlin {
|
|
srcDir(versionDirectory)
|
|
}
|
|
}
|
|
}
|
|
|
|
tasks.compileKotlin {
|
|
dependsOn(generateVersion)
|
|
}
|
|
}
|
|
|
|
tasks.withType<ShadowJar> {
|
|
archiveFileName = if(isDebug) "phoebench-cli-debug.jar" else "phoebench-cli.jar"
|
|
}
|
|
|
|
buildConfig {
|
|
generateAtSync = false
|
|
useKotlinOutput { internalVisibility = false }
|
|
|
|
println("Source sets: ${kotlin.sourceSets.toList().map { it.name }}")
|
|
|
|
className("PersistenceConstants")
|
|
packageName("com.jaytux.phoebench.clients.cli")
|
|
|
|
if(isDebug) {
|
|
println("Using debug CLI service")
|
|
buildConfigField("SERVICE", "com.jaytux.phoebench.cli.debug")
|
|
}
|
|
else {
|
|
println("Using release CLI service")
|
|
buildConfigField("SERVICE", "com.jaytux.phoebench.cli")
|
|
}
|
|
} |