insert native lib into jar

This commit is contained in:
mae
2025-11-16 20:34:38 -06:00
parent 96bb989ad5
commit aa3c3377d0
3 changed files with 29 additions and 3 deletions

View File

@@ -29,6 +29,11 @@ dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${kotlinCoroutinesVersion}")
}
sourceSets.main {
resources {
srcDirs("src/main/resources", "build/natives")
}
}
kotlin {
jvmToolchain(24)
}
@@ -36,4 +41,12 @@ kotlin {
tasks.test {
useJUnitPlatform()
}
project.layout.buildDirectory.set(file("../../build"))
tasks.register<Exec>("compileNativeLib") {
val java_home = System.getProperty("java.home")
environment("CGO_CFLAGS" to "-I$java_home/include -I$java_home/include/linux")
workingDir("src/main/go")
commandLine("go", "build", "-linkshared", "-buildmode=c-shared", "-o", layout.buildDirectory.get().dir("natives").file("pltbuild.so"))
}
tasks.processResources {
dependsOn += "compileNativeLib"
}