json configs
This commit is contained in:
@ -2,6 +2,7 @@ import org.gradle.internal.jvm.Jvm
|
||||
|
||||
plugins {
|
||||
kotlin("jvm") version "2.3.0"
|
||||
kotlin("plugin.serialization") version "2.0.0"
|
||||
}
|
||||
|
||||
group = "su.sonoma"
|
||||
@ -16,6 +17,7 @@ dependencies {
|
||||
implementation("io.ktor:ktor-network:3.1.3")
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.22")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.0")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
@ -46,16 +48,62 @@ tasks.test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
tasks.register("generateTestServerConfig") {
|
||||
|
||||
val outputFile = layout.buildDirectory.file("tmp/server.json")
|
||||
|
||||
outputs.file(outputFile)
|
||||
|
||||
doLast {
|
||||
|
||||
val file = outputFile.get().asFile
|
||||
|
||||
file.parentFile.mkdirs()
|
||||
|
||||
file.writeText("""
|
||||
{
|
||||
"type": "server",
|
||||
"address": "10.1.0.1",
|
||||
"port": 9093
|
||||
}
|
||||
""".trimIndent())
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("generateTestClientConfig") {
|
||||
|
||||
val outputFile = layout.buildDirectory.file("tmp/client.json")
|
||||
|
||||
outputs.file(outputFile)
|
||||
|
||||
doLast {
|
||||
|
||||
val file = outputFile.get().asFile
|
||||
|
||||
file.parentFile.mkdirs()
|
||||
|
||||
file.writeText("""
|
||||
{
|
||||
"type": "client",
|
||||
"host": "192.168.88.247",
|
||||
"address": "10.1.0.2",
|
||||
"port": 9093
|
||||
}
|
||||
""".trimIndent())
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register<JavaExec>("runServer") {
|
||||
group = "app"
|
||||
description = "Run server"
|
||||
classpath = sourceSets["main"].runtimeClasspath
|
||||
mainClass.set("su.sonoma.MainKt")
|
||||
args = listOf("server")
|
||||
args = listOf("${projectDir}/build/tmp/server.json")
|
||||
jvmArgs = listOf(
|
||||
"--add-opens=java.base/java.io=ALL-UNNAMED"
|
||||
)
|
||||
dependsOn("buildTunLib")
|
||||
dependsOn("generateTestServerConfig")
|
||||
|
||||
systemProperty(
|
||||
"java.library.path",
|
||||
@ -68,11 +116,12 @@ tasks.register<JavaExec>("runClient") {
|
||||
description = "Run client"
|
||||
classpath = sourceSets["main"].runtimeClasspath
|
||||
mainClass.set("su.sonoma.MainKt")
|
||||
args = listOf("client")
|
||||
args = listOf("${projectDir}/build/tmp/client.json")
|
||||
jvmArgs = listOf(
|
||||
"--add-opens=java.base/java.io=ALL-UNNAMED"
|
||||
)
|
||||
dependsOn("buildTunLib")
|
||||
dependsOn("generateTestClientConfig")
|
||||
|
||||
systemProperty(
|
||||
"java.library.path",
|
||||
|
||||
Reference in New Issue
Block a user