From 3202239129a53f750d4197cbd3e0c5e672effd92 Mon Sep 17 00:00:00 2001 From: nacro711072 Date: Mon, 29 Aug 2022 04:24:54 +0800 Subject: [PATCH] JvmArg not work for mac desktop:run. (#7681) * fix build bug. * add package gdx-lwjgl3-glfw-awt-macos for mac only. * use library with non-specify-platform. --- desktop/build.gradle.kts | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/desktop/build.gradle.kts b/desktop/build.gradle.kts index a722b84b8a..8c803df3b5 100644 --- a/desktop/build.gradle.kts +++ b/desktop/build.gradle.kts @@ -1,6 +1,8 @@ import com.badlogicgames.packr.Packr import com.badlogicgames.packr.PackrConfig import com.unciv.build.BuildConfig +import com.unciv.build.BuildConfig.gdxVersion +import org.apache.tools.ant.taskdefs.condition.Os plugins { id("kotlin") @@ -16,22 +18,18 @@ sourceSets { } } +dependencies { + // See https://libgdx.com/news/2021/07/devlog-7-lwjgl3#do-i-need-to-do-anything-else + api("com.badlogicgames.gdx:gdx-lwjgl3-glfw-awt-macos:$gdxVersion") +} + val mainClassName = "com.unciv.app.desktop.DesktopLauncher" val assetsDir = file("../android/assets") val discordDir = file("discord_rpc") val deployFolder = file("../deploy") -// See https://github.com/libgdx/libgdx/wiki/Starter-classes-and-configuration#common-issues -// and https://github.com/yairm210/Unciv/issues/5679 -val jvmArgsForMac = listOf("-XstartOnFirstThread", "-Djava.awt.headless=true") tasks.register("run") { - jvmArgs = mutableListOf() - if ("mac" in System.getProperty("os.name").toLowerCase()) - (jvmArgs as MutableList).addAll(jvmArgsForMac) - // These are non-standard, only available/necessary on Mac. - dependsOn(tasks.getByName("classes")) - mainClass.set(mainClassName) classpath = sourceSets.main.get().runtimeClasspath standardInput = System.`in` @@ -40,7 +38,6 @@ tasks.register("run") { } tasks.register("debug") { - jvmArgs = jvmArgsForMac dependsOn(tasks.getByName("classes")) mainClass.set(mainClassName) classpath = sourceSets.main.get().runtimeClasspath @@ -143,10 +140,6 @@ for (platform in PackrConfig.Platform.values()) { " --classpath $jarFile" + " --mainclass $mainClassName" + " --vmargs Xmx1G " + - (if (platform == PackrConfig.Platform.MacOS) jvmArgsForMac.joinToString(" ") { - it.removePrefix("-") - } - else "") + " --output ${config.outDir}" command.runCommand(rootDir) }