Fix JVM crashes on macOS

This commit is contained in:
Alva Swanson 2023-10-30 20:07:30 +01:00
parent 381e44ee14
commit 6203f4044e
No known key found for this signature in database
GPG Key ID: 004760E77F753090
2 changed files with 12 additions and 6 deletions

View File

@ -42,7 +42,7 @@ class PackagingPlugin @Inject constructor(private val javaToolchainService: Java
project.tasks.register<JPackageTask>("generateInstallers") {
dependsOn(generateHashesTask)
jdkDirectory.set(getJdk17Directory())
jdkDirectory.set(getJPackageJdkDirectory())
distDirFile.set(installDistTask.map { it.destinationDir })
mainJarFile.set(jarTask.flatMap { it.archiveFile })
@ -55,7 +55,11 @@ class PackagingPlugin @Inject constructor(private val javaToolchainService: Java
val packageResourcesDirFile = File(project.projectDir, "package")
packageResourcesDir.set(packageResourcesDirFile)
runtimeImageDirectory.set(getProjectJdkDirectory(project))
runtimeImageDirectory.set(
if (getOS() == OS.MAC_OS) getJPackageJdkDirectory()
else getProjectJdkDirectory(project)
)
outputDirectory.set(project.layout.buildDirectory.dir("packaging/jpackage/packages"))
}
}
@ -79,12 +83,13 @@ class PackagingPlugin @Inject constructor(private val javaToolchainService: Java
return projectLauncherProvider.map { it.metadata.installationPath }
}
private fun getJdk17Directory(): Provider<Directory> {
val jdk17LauncherProvider = javaToolchainService.launcherFor {
languageVersion.set(JavaLanguageVersion.of(17))
private fun getJPackageJdkDirectory(): Provider<Directory> {
val javaVersion = if (getOS() == OS.MAC_OS) 15 else 17
val launcherProvider = javaToolchainService.launcherFor {
languageVersion.set(JavaLanguageVersion.of(javaVersion))
vendor.set(JvmVendorSpec.AZUL)
implementation.set(JvmImplementation.VENDOR_SPECIFIC)
}
return jdk17LauncherProvider.map { it.metadata.installationPath }
return launcherProvider.map { it.metadata.installationPath }
}
}

View File

@ -37,6 +37,7 @@ abstract class BisqToolchainResolver : JavaToolchainResolver {
private fun getToolchainUrlForMacOs(javaVersion: Int): String? =
when (javaVersion) {
11 -> "https://cdn.azul.com/zulu/bin/zulu11.66.15_1-ca-jdk11.0.20-macosx_x64.tar.gz"
15 -> "https://cdn.azul.com/zulu/bin/zulu15.46.17-ca-jdk15.0.10-macosx_x64.tar.gz"
17 -> "https://cdn.azul.com/zulu/bin/zulu17.44.15_1-ca-jdk17.0.8-macosx_x64.tar.gz"
else -> null
}