From 0e87a9e00c7f50d47015cf8b665a34ddacd23f2e Mon Sep 17 00:00:00 2001 From: Alva Swanson Date: Mon, 24 Jun 2024 17:11:03 +0000 Subject: [PATCH] packaging: Add Bisq 1 JDK support --- .../bisq/gradle/packaging/PackagingPlugin.kt | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/build-logic/packaging/src/main/kotlin/bisq/gradle/packaging/PackagingPlugin.kt b/build-logic/packaging/src/main/kotlin/bisq/gradle/packaging/PackagingPlugin.kt index ae91a73527..4480561867 100644 --- a/build-logic/packaging/src/main/kotlin/bisq/gradle/packaging/PackagingPlugin.kt +++ b/build-logic/packaging/src/main/kotlin/bisq/gradle/packaging/PackagingPlugin.kt @@ -5,7 +5,6 @@ import org.gradle.api.Project import org.gradle.api.file.Directory import org.gradle.api.file.RegularFile import org.gradle.api.plugins.JavaApplication -import org.gradle.api.plugins.JavaPluginExtension import org.gradle.api.provider.Provider import org.gradle.api.tasks.Sync import org.gradle.api.tasks.TaskProvider @@ -44,7 +43,7 @@ class PackagingPlugin @Inject constructor(private val javaToolchainService: Java project.tasks.register("generateInstallers") { dependsOn(generateHashesTask) - jdkDirectory.set(getJPackageJdkDirectory()) + jdkDirectory.set(getJPackageJdkDirectory(extension)) distDirFile.set(installDistTask.map { it.destinationDir }) mainJarFile.set(jarTask.flatMap { it.archiveFile }) @@ -60,8 +59,7 @@ class PackagingPlugin @Inject constructor(private val javaToolchainService: Java packageResourcesDir.set(packageResourcesDirFile) runtimeImageDirectory.set( - if (getOS() == OS.MAC_OS) getJPackageJdkDirectory() - else getJPackageJdkDirectory() + getJPackageJdkDirectory(extension) ) outputDirectory.set(project.layout.buildDirectory.dir("packaging/jpackage/packages")) @@ -86,21 +84,23 @@ class PackagingPlugin @Inject constructor(private val javaToolchainService: Java } } - private fun getProjectJdkDirectory(project: Project): Provider { - val javaExtension = project.extensions.findByType() - checkNotNull(javaExtension) { "Can't find JavaPluginExtension extension." } - - val toolchain = javaExtension.toolchain - val projectLauncherProvider = javaToolchainService.launcherFor(toolchain) - return projectLauncherProvider.map { it.metadata.installationPath } - } - - private fun getJPackageJdkDirectory(): Provider { + private fun getJPackageJdkDirectory(extension: PackagingPluginExtension): Provider { val launcherProvider = javaToolchainService.launcherFor { - languageVersion.set(JavaLanguageVersion.of(17)) + languageVersion.set(getJavaLanguageVersion(extension)) vendor.set(JvmVendorSpec.AZUL) implementation.set(JvmImplementation.VENDOR_SPECIFIC) } return launcherProvider.map { it.metadata.installationPath } } + + private fun getJavaLanguageVersion(extension: PackagingPluginExtension): Provider { + val javaVersion = extension.name.map { appName -> + if (appName == "Bisq" && getOS() == OS.MAC_OS) { + 15 + } else { + 17 + } + } + return javaVersion.map { JavaLanguageVersion.of(it) } + } }