73 lines
1.4 KiB
Plaintext
73 lines
1.4 KiB
Plaintext
import org.gradle.internal.jvm.Jvm
|
|
|
|
plugins {
|
|
kotlin("jvm") version "2.3.0"
|
|
}
|
|
|
|
group = "su.sonoma"
|
|
version = "1.0-SNAPSHOT"
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
|
|
dependencies {
|
|
testImplementation(kotlin("test"))
|
|
implementation("io.ktor:ktor-network:3.1.3")
|
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2")
|
|
}
|
|
|
|
kotlin {
|
|
jvmToolchain(25)
|
|
}
|
|
|
|
tasks.test {
|
|
useJUnitPlatform()
|
|
}
|
|
|
|
tasks.register<JavaExec>("runServer") {
|
|
group = "app"
|
|
description = "Run server"
|
|
classpath = sourceSets["main"].runtimeClasspath
|
|
mainClass.set("su.sonoma.MainKt")
|
|
args = listOf("server")
|
|
}
|
|
|
|
tasks.register<JavaExec>("runClient") {
|
|
group = "app"
|
|
description = "Run client"
|
|
classpath = sourceSets["main"].runtimeClasspath
|
|
mainClass.set("su.sonoma.MainKt")
|
|
args = listOf("client")
|
|
jvmArgs = listOf(
|
|
"--add-opens=java.base/java.io=ALL-UNNAMED"
|
|
)
|
|
dependsOn("buildTunLib")
|
|
}
|
|
|
|
val javaHome = Jvm.current().javaHome.absolutePath
|
|
|
|
tasks.register<Exec>("buildTunLib") {
|
|
group = "build"
|
|
|
|
val outputDir = layout.buildDirectory.dir("native").get().asFile
|
|
|
|
doFirst {
|
|
outputDir.mkdirs()
|
|
}
|
|
|
|
commandLine(
|
|
"gcc",
|
|
"-shared",
|
|
"-fPIC",
|
|
"-z", "noexecstack",
|
|
|
|
"-o",
|
|
"${outputDir.absolutePath}/libtun.so",
|
|
|
|
"src/main/c/tun.c",
|
|
|
|
"-I$javaHome/include",
|
|
"-I$javaHome/include/linux"
|
|
)
|
|
} |