79 lines
1.9 KiB
Kotlin
79 lines
1.9 KiB
Kotlin
plugins {
|
|
`java-library`
|
|
`maven-publish`
|
|
}
|
|
|
|
group = "dev.jlibghostty"
|
|
version = "0.1.0-SNAPSHOT"
|
|
|
|
java {
|
|
toolchain {
|
|
languageVersion.set(JavaLanguageVersion.of(25))
|
|
}
|
|
|
|
withSourcesJar()
|
|
}
|
|
|
|
val graalvmHome = providers.environmentVariable("GRAALVM_HOME")
|
|
.orElse(providers.systemProperty("java.home"))
|
|
val graalNativeImageJmod = graalvmHome.map {
|
|
file("$it/jmods/org.graalvm.nativeimage.jmod")
|
|
}
|
|
|
|
dependencies {
|
|
compileOnly(files(graalNativeImageJmod))
|
|
}
|
|
|
|
tasks.withType<JavaCompile>().configureEach {
|
|
options.release.set(22)
|
|
}
|
|
|
|
tasks.test {
|
|
jvmArgs("--enable-native-access=ALL-UNNAMED")
|
|
}
|
|
|
|
fun currentPlatform(): String {
|
|
val os = System.getProperty("os.name").lowercase()
|
|
val arch = System.getProperty("os.arch").lowercase()
|
|
|
|
val normalizedOs = when {
|
|
os.contains("linux") -> "linux"
|
|
os.contains("mac") || os.contains("darwin") -> "macos"
|
|
else -> error("Unsupported operating system for bundled libghostty-vt: $os")
|
|
}
|
|
|
|
val normalizedArch = when (arch) {
|
|
"amd64", "x86_64" -> "x86_64"
|
|
"aarch64", "arm64" -> "aarch64"
|
|
else -> error("Unsupported architecture for bundled libghostty-vt: $arch")
|
|
}
|
|
|
|
return "$normalizedOs-$normalizedArch"
|
|
}
|
|
|
|
val ghosttyNativeLib = providers
|
|
.gradleProperty("ghosttyNativeLib")
|
|
.orElse(providers.environmentVariable("JLIBGHOSTTY_LIBRARY"))
|
|
|
|
tasks.processResources {
|
|
ghosttyNativeLib.orNull?.let { nativeLib ->
|
|
from(nativeLib) {
|
|
into("dev/jlibghostty/native/${currentPlatform()}")
|
|
rename { System.mapLibraryName("ghostty-vt") }
|
|
}
|
|
}
|
|
}
|
|
|
|
publishing {
|
|
publications {
|
|
create<MavenPublication>("mavenJava") {
|
|
from(components["java"])
|
|
|
|
pom {
|
|
name.set("jlibghostty")
|
|
description.set("Java FFM bindings for libghostty-vt")
|
|
}
|
|
}
|
|
}
|
|
}
|