From f3539a4b2204d1e48019a48138e2133f28c78933 Mon Sep 17 00:00:00 2001 From: Alva Swanson Date: Tue, 29 Aug 2023 14:46:48 +0200 Subject: [PATCH] packaging: Implement JPackageTask The JPackageTask generates a package using a previously generated runtime image. --- .../bisq/gradle/packaging/JPackageTask.kt | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 build-logic/packaging/src/main/kotlin/bisq/gradle/packaging/JPackageTask.kt diff --git a/build-logic/packaging/src/main/kotlin/bisq/gradle/packaging/JPackageTask.kt b/build-logic/packaging/src/main/kotlin/bisq/gradle/packaging/JPackageTask.kt new file mode 100644 index 00000000000..8f705ed9d87 --- /dev/null +++ b/build-logic/packaging/src/main/kotlin/bisq/gradle/packaging/JPackageTask.kt @@ -0,0 +1,51 @@ +package bisq.gradle.packaging + +import org.gradle.api.DefaultTask +import org.gradle.api.file.DirectoryProperty +import org.gradle.api.provider.Property +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.InputDirectory +import org.gradle.api.tasks.OutputDirectory +import org.gradle.api.tasks.TaskAction +import java.util.concurrent.TimeUnit + +abstract class JPackageTask : DefaultTask() { + + @get:InputDirectory + abstract val jdkDirectory: DirectoryProperty + + @get:InputDirectory + abstract val jarsDirectory: DirectoryProperty + + @get:Input + abstract val mainJar: Property + + @get:Input + abstract val mainClassName: Property + + @get:InputDirectory + abstract val runtimeImageDirectory: DirectoryProperty + + @get:OutputDirectory + abstract val outputDirectory: DirectoryProperty + + @TaskAction + fun run() { + val jPackagePath = jdkDirectory.asFile.get().toPath().resolve("bin").resolve("jpackage") + val processBuilder = ProcessBuilder( + jPackagePath.toAbsolutePath().toString(), + "--dest", outputDirectory.asFile.get().absolutePath, + "--name", "Bisq", + + "--input", jarsDirectory.asFile.get().absolutePath, + "--main-jar", mainJar.get(), + "--main-class", mainClassName.get(), + + "--runtime-image", runtimeImageDirectory.asFile.get().absolutePath + ) + + processBuilder.inheritIO() + val process = processBuilder.start() + process.waitFor(15, TimeUnit.MINUTES) + } +}