-tasks.withType<JavaExec> {
- 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<String>
- }
-}
-
-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())