From 60f2069e175588a7058be0e3b93c756123b7e09b Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Wed, 14 Aug 2024 10:00:03 +0200 Subject: [PATCH] Fix parchment not enabled detection Add test to cover parchment usage --- .../subsystems/SubsystemsExtension.java | 2 +- .../gradle/userdev/ParchmentTests.groovy | 59 +++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ParchmentTests.groovy diff --git a/common/src/main/java/net/neoforged/gradle/common/extensions/subsystems/SubsystemsExtension.java b/common/src/main/java/net/neoforged/gradle/common/extensions/subsystems/SubsystemsExtension.java index 665eda93..c5dbd252 100644 --- a/common/src/main/java/net/neoforged/gradle/common/extensions/subsystems/SubsystemsExtension.java +++ b/common/src/main/java/net/neoforged/gradle/common/extensions/subsystems/SubsystemsExtension.java @@ -147,7 +147,7 @@ public ParchmentExtensions(Project project) { + ":" + DEFAULT_PARCHMENT_ARTIFACT_PREFIX + minecraftVersion + ":" + mappingVersion + "@zip"; - }) + }).orElse("") ) ); getConflictPrefix().convention("p_"); diff --git a/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ParchmentTests.groovy b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ParchmentTests.groovy new file mode 100644 index 00000000..1dec2bd5 --- /dev/null +++ b/userdev/src/functionalTest/groovy/net/neoforged/gradle/userdev/ParchmentTests.groovy @@ -0,0 +1,59 @@ +package net.neoforged.gradle.userdev + +import net.neoforged.trainingwheels.gradle.functional.BuilderBasedTestSpecification +import org.gradle.testkit.runner.TaskOutcome + +class ParchmentTests extends BuilderBasedTestSpecification { + + @Override + protected void configurePluginUnderTest() { + pluginUnderTest = "net.neoforged.gradle.neoform"; + injectIntoAllProject = true; + } + + def "parchment can be used"() { + given: + def project = create("parchment_can_be_used", { + it.property("neogradle.subsystems.parchment.minecraftVersion", "1.21") + it.property("neogradle.subsystems.parchment.mappingsVersion", "2024.07.28") + it.build(""" + plugins { + id 'net.neoforged.gradle.userdev' + } + + java { + toolchain { + languageVersion = JavaLanguageVersion.of(21) + } + } + + dependencies { + implementation 'net.neoforged:neoforge:+' + } + """) + it.file("src/main/java/net/neoforged/gradle/userdev/ConfigurationCacheTests.java", """ + package net.neoforged.gradle.userdev; + + import net.minecraft.client.Minecraft; + + public class ConfigurationCacheTests { + public static void main(String[] args) { + System.out.println(Minecraft.getInstance().getClass().toString()); + } + } + """) + it.withToolchains() + it.withGlobalCacheDirectory(tempDir) + }) + + when: + def run = project.run { + it.tasks('compileJava') + it.arguments('--warning-mode', 'fail', '--stacktrace') + } + + then: + run.task(':compileJava').outcome == TaskOutcome.SUCCESS + run.task(':neoFormApplyParchment').outcome == TaskOutcome.SUCCESS + } +}