Skip to content

Commit

Permalink
packaging: Dynamically set app name
Browse files Browse the repository at this point in the history
  • Loading branch information
alvasw committed Jun 24, 2024
1 parent 86871e9 commit a0564fc
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 9 deletions.
4 changes: 4 additions & 0 deletions apps/desktop/desktop-app-launcher/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ application {
mainClass.set("bisq.desktop_app_launcher.DesktopAppLauncher")
}

packaging {
name.set("Bisq 2")
}

javafx {
version = "17.0.1"
modules = listOf("javafx.controls", "javafx.media")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ abstract class JPackageTask : DefaultTask() {
@get:InputFile
abstract val licenseFile: RegularFileProperty

@get:Input
abstract val appName: Property<String>

@get:Input
abstract val appVersion: Property<String>

Expand All @@ -57,11 +60,12 @@ abstract class JPackageTask : DefaultTask() {
runtimeImageDirPath = runtimeImageDirectory.asFile.get().toPath(),

appConfig = JPackageAppConfig(
appVersion = appVersion.get(),
mainJarFileName = mainJarFile.asFile.get().name,
mainClassName = mainClassName.get(),
jvmArgs = jvmArgs.get(),
licenceFilePath = licenseFile.asFile.get().absolutePath
name = appName.get(),
appVersion = appVersion.get(),
mainJarFileName = mainJarFile.asFile.get().name,
mainClassName = mainClassName.get(),
jvmArgs = jvmArgs.get(),
licenceFilePath = licenseFile.asFile.get().absolutePath
),

packageFormatConfigs = getPackageFormatConfigs()
Expand All @@ -81,7 +85,7 @@ abstract class JPackageTask : DefaultTask() {

OS.MAC_OS -> {
val resourcesPath = packagePath.resolve("macosx")
MacPackage(resourcesPath)
MacPackage(resourcesPath, appName.get())
}

OS.LINUX -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import org.gradle.jvm.toolchain.JavaLanguageVersion
import org.gradle.jvm.toolchain.JavaToolchainService
import org.gradle.jvm.toolchain.JvmImplementation
import org.gradle.jvm.toolchain.JvmVendorSpec
import org.gradle.kotlin.dsl.create
import org.gradle.kotlin.dsl.findByType
import org.gradle.kotlin.dsl.register
import java.io.File
Expand All @@ -27,6 +28,8 @@ class PackagingPlugin @Inject constructor(private val javaToolchainService: Java
}

override fun apply(project: Project) {
val extension = project.extensions.create<PackagingPluginExtension>("packaging")

val installDistTask: TaskProvider<Sync> = project.tasks.named("installDist", Sync::class.java)

val generateHashesTask = project.tasks.register<Sha256HashTask>("generateHashes") {
Expand All @@ -51,6 +54,7 @@ class PackagingPlugin @Inject constructor(private val javaToolchainService: Java
jvmArgs.set(javaApplicationExtension.applicationDefaultJvmArgs)

licenseFile.set(File(project.projectDir.parentFile.parentFile.parentFile, "LICENSE"))
appName.set(extension.name)
appVersion.set(APP_VERSION)

val packageResourcesDirFile = File(project.projectDir, "package")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package bisq.gradle.packaging

import org.gradle.api.provider.Property

abstract class PackagingPluginExtension {
abstract val name: Property<String>
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package bisq.gradle.packaging.jpackage

data class JPackageAppConfig(
val name: String,
val appVersion: String,
val mainJarFileName: String,
val mainClassName: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class PackageFactory(private val jPackagePath: Path, private val jPackageConfig:
mutableListOf(
"--dest", jPackageConfig.outputDirPath.toAbsolutePath().toString(),

"--name", "Bisq 2",
"--name", appConfig.name,
"--copyright", "Copyright © 2013-${Year.now()} - The Bisq developers",
"--vendor", "Bisq",
"--license-file", appConfig.licenceFilePath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package bisq.gradle.packaging.jpackage.package_formats

import java.nio.file.Path

class MacPackage(private val resourcesPath: Path) : JPackagePackageFormatConfigs {
class MacPackage(private val resourcesPath: Path, private val appName: String) : JPackagePackageFormatConfigs {
override val packageFormats = setOf(PackageFormat.DMG)

override fun createArgumentsForJPackage(packageFormat: PackageFormat): List<String> =
mutableListOf(
"--resource-dir", resourcesPath.toAbsolutePath().toString(),
"--mac-package-name", "Bisq 2",
"--mac-package-name", appName,
"--icon", resourcesPath.resolve("Bisq2.icns").toAbsolutePath().toString(),
"--description", "A decentralized bitcoin exchange network.",
)
Expand Down

0 comments on commit a0564fc

Please sign in to comment.