From defb288148fe1028c960a9edbf851edeafe6fafe Mon Sep 17 00:00:00 2001 From: Alva Swanson Date: Mon, 24 Jun 2024 17:08:38 +0000 Subject: [PATCH] packaging: Add JPackage arguments override support Bisq 2 requires a different `--description` on Windows for the OS notification. --- .../packaging/jpackage/PackageFactory.kt | 20 ++++++++++++++++++- .../jpackage/package_formats/LinuxPackages.kt | 2 -- .../jpackage/package_formats/MacPackage.kt | 1 - .../package_formats/WindowsPackage.kt | 1 - 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/build-logic/packaging/src/main/kotlin/bisq/gradle/packaging/jpackage/PackageFactory.kt b/build-logic/packaging/src/main/kotlin/bisq/gradle/packaging/jpackage/PackageFactory.kt index f15f732cf3..af628de275 100644 --- a/build-logic/packaging/src/main/kotlin/bisq/gradle/packaging/jpackage/PackageFactory.kt +++ b/build-logic/packaging/src/main/kotlin/bisq/gradle/packaging/jpackage/PackageFactory.kt @@ -21,8 +21,17 @@ class PackageFactory(private val jPackagePath: Path, private val jPackageConfig: val processBuilder = ProcessBuilder(absoluteBinaryPath) .inheritIO() + var commonArgs: Map = jPackageCommonArgs + + val osSpecificOverrideArgs = getOsSpecificOverrideArgs(filetypeAndCustomCommands.first) + if (osSpecificOverrideArgs.isNotEmpty()) { + val mutableMap: MutableMap = jPackageCommonArgs.toMutableMap() + mutableMap.putAll(osSpecificOverrideArgs) + commonArgs = mutableMap + } + val allCommands = processBuilder.command() - jPackageCommonArgs.forEach { (key, value) -> + commonArgs.forEach { (key, value) -> allCommands.add(key) allCommands.add(value) } @@ -44,6 +53,7 @@ class PackageFactory(private val jPackagePath: Path, private val jPackageConfig: "--dest" to jPackageConfig.outputDirPath.toAbsolutePath().toString(), "--name" to appConfig.name, + "--description" to "A decentralized bitcoin exchange network.", "--copyright" to "Copyright © 2013-${Year.now()} - The Bisq developers", "--vendor" to "Bisq", "--license-file" to appConfig.licenceFilePath, @@ -58,6 +68,14 @@ class PackageFactory(private val jPackagePath: Path, private val jPackageConfig: "--runtime-image" to jPackageConfig.runtimeImageDirPath.toAbsolutePath().toString() ) + private fun getOsSpecificOverrideArgs(fileType: String): Map = + if (jPackageConfig.appConfig.name == "Bisq" && fileType == "exe") { + // Needed for Windows OS notification support + mutableMapOf("--description" to "Bisq 2") + } else { + emptyMap() + } + private fun deleteFileOrDirectory(dir: File) { val files = dir.listFiles() if (files != null) { diff --git a/build-logic/packaging/src/main/kotlin/bisq/gradle/packaging/jpackage/package_formats/LinuxPackages.kt b/build-logic/packaging/src/main/kotlin/bisq/gradle/packaging/jpackage/package_formats/LinuxPackages.kt index 7d09d18672..3b040641db 100644 --- a/build-logic/packaging/src/main/kotlin/bisq/gradle/packaging/jpackage/package_formats/LinuxPackages.kt +++ b/build-logic/packaging/src/main/kotlin/bisq/gradle/packaging/jpackage/package_formats/LinuxPackages.kt @@ -11,8 +11,6 @@ class LinuxPackages(private val resourcesPath: Path, private val appName: String resourcesPath.resolve("icon.png") .toAbsolutePath().toString(), - "--description", "A decentralized bitcoin exchange network.", - "--linux-package-name", appName.toLowerCase().replace(" ", ""), "--linux-app-release", "1", diff --git a/build-logic/packaging/src/main/kotlin/bisq/gradle/packaging/jpackage/package_formats/MacPackage.kt b/build-logic/packaging/src/main/kotlin/bisq/gradle/packaging/jpackage/package_formats/MacPackage.kt index 4d92fcd4f3..78ea2dafea 100644 --- a/build-logic/packaging/src/main/kotlin/bisq/gradle/packaging/jpackage/package_formats/MacPackage.kt +++ b/build-logic/packaging/src/main/kotlin/bisq/gradle/packaging/jpackage/package_formats/MacPackage.kt @@ -10,6 +10,5 @@ class MacPackage(private val resourcesPath: Path, private val appName: String) : "--resource-dir", resourcesPath.toAbsolutePath().toString(), "--mac-package-name", appName, "--icon", resourcesPath.resolve("Bisq2.icns").toAbsolutePath().toString(), - "--description", "A decentralized bitcoin exchange network.", ) } diff --git a/build-logic/packaging/src/main/kotlin/bisq/gradle/packaging/jpackage/package_formats/WindowsPackage.kt b/build-logic/packaging/src/main/kotlin/bisq/gradle/packaging/jpackage/package_formats/WindowsPackage.kt index f67a01ea94..9e78798d9c 100644 --- a/build-logic/packaging/src/main/kotlin/bisq/gradle/packaging/jpackage/package_formats/WindowsPackage.kt +++ b/build-logic/packaging/src/main/kotlin/bisq/gradle/packaging/jpackage/package_formats/WindowsPackage.kt @@ -9,7 +9,6 @@ class WindowsPackage(private val resourcesPath: Path) : JPackagePackageFormatCon mutableListOf( // "--resource-dir", resourcesPath.toAbsolutePath().toString(), "--icon", resourcesPath.resolve("Bisq2.ico").toAbsolutePath().toString(), - "--description", "Bisq 2", "--win-dir-chooser", "--win-per-user-install",