-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6837 from alvasw/implement_jpackage_task
packaging: Implement JPackageTask
- Loading branch information
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
build-logic/packaging/src/main/kotlin/bisq/gradle/packaging/JPackageTask.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String> | ||
|
||
@get:Input | ||
abstract val mainClassName: Property<String> | ||
|
||
@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) | ||
} | ||
} |