X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/4eaec8359423df351a2c978095419e65e8dbac49..e1f4dae5c20b2cb98975e6ba16bc73f2a45423e6:/build.gradle.kts diff --git a/build.gradle.kts b/build.gradle.kts index 052e3c22..3f728938 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,30 +3,58 @@ plugins { application eclipse `check-lib-versions` + id("org.graalvm.buildtools.native") version "0.10.5" } -version = "0.7.4" +allprojects { + group = "org.asamk" + version = "0.13.13-SNAPSHOT" +} java { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 + + if (!JavaVersion.current().isCompatibleWith(targetCompatibility)) { + toolchain { + languageVersion.set(JavaLanguageVersion.of(targetCompatibility.majorVersion)) + } + } } application { mainClass.set("org.asamk.signal.Main") } -repositories { - mavenLocal() - mavenCentral() +graalvmNative { + binaries { + this["main"].run { + buildArgs.add("--install-exit-handlers") + buildArgs.add("-Dfile.encoding=UTF-8") + buildArgs.add("-J-Dfile.encoding=UTF-8") + resources.autodetect() + configurationFileDirectories.from(file("graalvm-config-dir")) + if (System.getenv("GRAALVM_HOME") == null) { + toolchainDetection.set(true) + javaLauncher.set(javaToolchains.launcherFor { + languageVersion.set(JavaLanguageVersion.of(21)) + }) + } else { + toolchainDetection.set(false) + } + } + } } dependencies { - implementation("org.bouncycastle:bcprov-jdk15on:1.68") - implementation("net.sourceforge.argparse4j:argparse4j:0.8.1") - implementation("com.github.hypfvieh:dbus-java:3.2.4") - implementation("org.slf4j:slf4j-simple:1.7.30") - implementation(project(":lib")) + implementation(libs.bouncycastle) + implementation(libs.jackson.databind) + implementation(libs.argparse4j) + implementation(libs.dbusjava) + implementation(libs.slf4j.api) + implementation(libs.slf4j.jul) + implementation(libs.logback) + implementation(project(":libsignal-cli")) } configurations { @@ -35,6 +63,12 @@ configurations { } } + +tasks.withType().configureEach { + isPreserveFileTimestamps = false + isReproducibleFileOrder = true +} + tasks.withType { options.encoding = "UTF-8" } @@ -42,55 +76,25 @@ tasks.withType { tasks.withType { manifest { attributes( - "Implementation-Title" to project.name, - "Implementation-Version" to project.version, - "Main-Class" to application.mainClass.get() + "Implementation-Title" to project.name, + "Implementation-Version" to project.version, + "Main-Class" to application.mainClass.get() ) } } -tasks.withType { - val appArgs: String? by project - if (appArgs != null) { - // allow passing command-line arguments to the main application e.g.: - // $ gradle run -PappArgs="['-u', '+...', 'daemon', '--json']" - args = groovy.util.Eval.me(appArgs) as MutableList - } -} - -val assembleNativeImage by tasks.registering { - dependsOn("assemble") - - var graalVMHome = "" - doFirst { - graalVMHome = System.getenv("GRAALVM_HOME") - ?: throw GradleException("Required GRAALVM_HOME environment variable not set.") - } - - doLast { - val nativeBinaryOutputPath = "$buildDir/native-image" - val nativeBinaryName = "signal-cli" - - mkdir(nativeBinaryOutputPath) - - exec { - workingDir = File(".") - commandLine("$graalVMHome/bin/native-image", - "-H:Path=$nativeBinaryOutputPath", - "-H:Name=$nativeBinaryName", - "-H:JNIConfigurationFiles=graalvm-config-dir/jni-config.json", - "-H:DynamicProxyConfigurationFiles=graalvm-config-dir/proxy-config.json", - "-H:ResourceConfigurationFiles=graalvm-config-dir/resource-config.json", - "-H:ReflectionConfigurationFiles=graalvm-config-dir/reflect-config.json", - "--no-fallback", - "--allow-incomplete-classpath", - "--report-unsupported-elements-at-runtime", - "--enable-url-protocols=http,https", - "--enable-https", - "--enable-all-security-services", - "-cp", - sourceSets.main.get().runtimeClasspath.asPath, - application.mainClass.get()) - } - } +task("fatJar", type = Jar::class) { + archiveBaseName.set("${project.name}-fat") + exclude( + "META-INF/*.SF", + "META-INF/*.DSA", + "META-INF/*.RSA", + "META-INF/NOTICE*", + "META-INF/LICENSE*", + "META-INF/INDEX.LIST", + "**/module-info.class" + ) + duplicatesStrategy = DuplicatesStrategy.WARN + from(configurations.runtimeClasspath.get().map { if (it.isDirectory) it else zipTree(it) }) + with(tasks.jar.get()) }