diff --git a/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/library/processors/LoomNativeSupportLibraryProcessor.java b/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/library/processors/LoomNativeSupportLibraryProcessor.java index 4baf86a4e..3deb861ac 100644 --- a/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/library/processors/LoomNativeSupportLibraryProcessor.java +++ b/src/main/java/net/fabricmc/loom/configuration/providers/minecraft/library/processors/LoomNativeSupportLibraryProcessor.java @@ -50,6 +50,11 @@ public ApplicationResult getApplicationResult() { return ApplicationResult.MUST_APPLY; } + if (platform.getOperatingSystem().isMacOS() && context.isJava19OrLater() && !context.supportsJava19OrLater()) { + // Apply when LWJGL has been updated on MacOS to support Java 19 + return ApplicationResult.MUST_APPLY; + } + // A developer can opt into this return ApplicationResult.CAN_APPLY; } diff --git a/src/test/groovy/net/fabricmc/loom/test/unit/library/processors/LWJGL3UpgradeLibraryProcessorTest.groovy b/src/test/groovy/net/fabricmc/loom/test/unit/library/processors/LWJGL3UpgradeLibraryProcessorTest.groovy index 46530d573..d3a7d9cb4 100644 --- a/src/test/groovy/net/fabricmc/loom/test/unit/library/processors/LWJGL3UpgradeLibraryProcessorTest.groovy +++ b/src/test/groovy/net/fabricmc/loom/test/unit/library/processors/LWJGL3UpgradeLibraryProcessorTest.groovy @@ -50,7 +50,6 @@ class LWJGL3UpgradeLibraryProcessorTest extends LibraryProcessorTest { "1.12.2" || LibraryProcessor.ApplicationResult.DONT_APPLY // Not LWJGL 3 } - // TODO once Minecraft updates to LWJGL 3.3.2 add a new test for this that uses that mc version def "Apply when using Java 19 or later"() { when: def (_, context) = getLibs("1.19.4", PlatformTestUtils.WINDOWS_X64, version) @@ -66,6 +65,21 @@ class LWJGL3UpgradeLibraryProcessorTest extends LibraryProcessorTest { JavaVersion.VERSION_1_8 || LibraryProcessor.ApplicationResult.CAN_APPLY } + def "Dont apply when using Java 19 or later on supported LWJGL version"() { + when: + def (_, context) = getLibs("1.20.2", PlatformTestUtils.WINDOWS_X64, version) + def processor = new LWJGL3UpgradeLibraryProcessor(PlatformTestUtils.WINDOWS_X64, context) + then: + processor.applicationResult == result + + where: + version || result + JavaVersion.VERSION_20 || LibraryProcessor.ApplicationResult.CAN_APPLY + JavaVersion.VERSION_19 || LibraryProcessor.ApplicationResult.CAN_APPLY + JavaVersion.VERSION_17 || LibraryProcessor.ApplicationResult.CAN_APPLY + JavaVersion.VERSION_1_8 || LibraryProcessor.ApplicationResult.CAN_APPLY + } + def "Apply when adding macOS ARM64 support"() { when: def (_, context) = getLibs(id, PlatformTestUtils.MAC_OS_ARM64) diff --git a/src/test/groovy/net/fabricmc/loom/test/unit/library/processors/LoomNativeSupportLibraryProcessorTest.groovy b/src/test/groovy/net/fabricmc/loom/test/unit/library/processors/LoomNativeSupportLibraryProcessorTest.groovy index e8076d463..6f6ab65d5 100644 --- a/src/test/groovy/net/fabricmc/loom/test/unit/library/processors/LoomNativeSupportLibraryProcessorTest.groovy +++ b/src/test/groovy/net/fabricmc/loom/test/unit/library/processors/LoomNativeSupportLibraryProcessorTest.groovy @@ -24,6 +24,8 @@ package net.fabricmc.loom.test.unit.library.processors +import org.gradle.api.JavaVersion + import net.fabricmc.loom.configuration.providers.minecraft.library.Library import net.fabricmc.loom.configuration.providers.minecraft.library.LibraryProcessor import net.fabricmc.loom.configuration.providers.minecraft.library.processors.LoomNativeSupportLibraryProcessor @@ -48,6 +50,51 @@ class LoomNativeSupportLibraryProcessorTest extends LibraryProcessorTest { "1.12.2" || LibraryProcessor.ApplicationResult.DONT_APPLY // Not LWJGL 3 } + def "Apply when using Java 19 or later on macOS"() { + when: + def (_, context) = getLibs("1.19.4", PlatformTestUtils.MAC_OS_X64, version) + def processor = new LoomNativeSupportLibraryProcessor(PlatformTestUtils.MAC_OS_X64, context) + then: + processor.applicationResult == result + + where: + version || result + JavaVersion.VERSION_20 || LibraryProcessor.ApplicationResult.MUST_APPLY + JavaVersion.VERSION_19 || LibraryProcessor.ApplicationResult.MUST_APPLY + JavaVersion.VERSION_17 || LibraryProcessor.ApplicationResult.CAN_APPLY + JavaVersion.VERSION_1_8 || LibraryProcessor.ApplicationResult.CAN_APPLY + } + + def "Dont apply when using Java 19 or later on macOS with supported version"() { + when: + def (_, context) = getLibs("1.20.2", PlatformTestUtils.MAC_OS_X64, version) + def processor = new LoomNativeSupportLibraryProcessor(PlatformTestUtils.MAC_OS_X64, context) + then: + processor.applicationResult == result + + where: + version || result + JavaVersion.VERSION_20 || LibraryProcessor.ApplicationResult.CAN_APPLY + JavaVersion.VERSION_19 || LibraryProcessor.ApplicationResult.CAN_APPLY + JavaVersion.VERSION_17 || LibraryProcessor.ApplicationResult.CAN_APPLY + JavaVersion.VERSION_1_8 || LibraryProcessor.ApplicationResult.CAN_APPLY + } + + def "Can apply when using Java 19 or later on other platforms"() { + when: + def (_, context) = getLibs("1.19.4", PlatformTestUtils.WINDOWS_ARM64, version) + def processor = new LoomNativeSupportLibraryProcessor(PlatformTestUtils.WINDOWS_ARM64, context) + then: + processor.applicationResult == result + + where: + version || result + JavaVersion.VERSION_20 || LibraryProcessor.ApplicationResult.CAN_APPLY + JavaVersion.VERSION_19 || LibraryProcessor.ApplicationResult.CAN_APPLY + JavaVersion.VERSION_17 || LibraryProcessor.ApplicationResult.CAN_APPLY + JavaVersion.VERSION_1_8 || LibraryProcessor.ApplicationResult.CAN_APPLY + } + def "Can apply on other platforms"() { when: def (_, context) = getLibs(id, platform)