From 3b4c3ac7a19c4486115897e4e70b46cedee06922 Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Tue, 25 Jun 2024 22:13:14 +0200 Subject: [PATCH] Fix test Fix idea sync detection Fix running of parchment via JST --- .../extensions/IdeManagementExtension.java | 2 +- .../extensions/NeoFormRuntimeExtension.java | 19 +++++++++++---- .../neoforged/gradle/platform/E2ETests.groovy | 2 +- .../vanilla/runtime/steps/ParchmentStep.java | 24 ++++++++++++------- 4 files changed, 31 insertions(+), 16 deletions(-) diff --git a/common/src/main/java/net/neoforged/gradle/common/extensions/IdeManagementExtension.java b/common/src/main/java/net/neoforged/gradle/common/extensions/IdeManagementExtension.java index 5a059be83..48de350fe 100644 --- a/common/src/main/java/net/neoforged/gradle/common/extensions/IdeManagementExtension.java +++ b/common/src/main/java/net/neoforged/gradle/common/extensions/IdeManagementExtension.java @@ -63,7 +63,7 @@ public IdeManagementExtension(Project project) { * @return whether this is an IntelliJ-based invocation */ public boolean isIdeaImport() { - return Boolean.getBoolean("idea.active"); + return Boolean.getBoolean("idea.sync.active"); } /** diff --git a/neoform/src/main/java/net/neoforged/gradle/neoform/runtime/extensions/NeoFormRuntimeExtension.java b/neoform/src/main/java/net/neoforged/gradle/neoform/runtime/extensions/NeoFormRuntimeExtension.java index 49eb916cd..ff66f36a3 100644 --- a/neoform/src/main/java/net/neoforged/gradle/neoform/runtime/extensions/NeoFormRuntimeExtension.java +++ b/neoform/src/main/java/net/neoforged/gradle/neoform/runtime/extensions/NeoFormRuntimeExtension.java @@ -436,7 +436,7 @@ protected void bakeDefinition(NeoFormRuntimeDefinition definition) { remapTask.configure(task -> configureMcpRuntimeTaskWithDefaults(spec, neoFormDirectory, symbolicDataSources, task)); TaskProvider recompileInput = maybeApplyParchment( - spec, + definition, remapTask, symbolicDataSources, neoFormDirectory, @@ -492,19 +492,19 @@ protected void bakeDefinition(NeoFormRuntimeDefinition definition) { }); } - private static TaskProvider maybeApplyParchment(NeoFormRuntimeSpecification spec, + private static TaskProvider maybeApplyParchment(NeoFormRuntimeDefinition runtimeDefinition, TaskProvider recompileInput, Map symbolicDataSources, File neoFormDirectory, Provider listLibrariesOutput) { - Project project = spec.getProject(); + Project project = runtimeDefinition.getSpecification().getProject(); Parchment parchment = project.getExtensions().getByType(Subsystems.class).getParchment(); Tools tools = project.getExtensions().getByType(Subsystems.class).getTools(); if (!parchment.getEnabled().get()) { return recompileInput; } - TaskProvider applyParchmentTask = project.getTasks().register(CommonRuntimeUtils.buildTaskName(spec, "applyParchment"), DefaultExecute.class, task -> { + TaskProvider applyParchmentTask = project.getTasks().register(CommonRuntimeUtils.buildTaskName(runtimeDefinition, "applyParchment"), DefaultExecute.class, task -> { // Provide the mappings via artifact File mappingFile = ToolUtilities.resolveTool(project, parchment.getParchmentArtifact().get()); String conflictPrefix = parchment.getConflictPrefix().get(); @@ -526,10 +526,19 @@ private static TaskProvider maybeApplyParchment(NeoFormRun task.getProgramArguments().add("{input}"); task.getProgramArguments().add("{output}"); + final StringBuilder builder = new StringBuilder(); + runtimeDefinition.getAllDependencies().forEach(f -> { + if (!builder.isEmpty()) { + builder.append(File.pathSeparator); + } + builder.append(f.getAbsolutePath()); + }); + task.getProgramArguments().add("--classpath=" + builder); + task.dependsOn(listLibrariesOutput); task.dependsOn(recompileInput); - configureCommonRuntimeTaskParameters(task, symbolicDataSources, "applyParchment", spec, neoFormDirectory); + configureCommonRuntimeTaskParameters(task, symbolicDataSources, "applyParchment", runtimeDefinition.getSpecification(), neoFormDirectory); }); return applyParchmentTask; diff --git a/platform/src/functionalTest/groovy/net/neoforged/gradle/platform/E2ETests.groovy b/platform/src/functionalTest/groovy/net/neoforged/gradle/platform/E2ETests.groovy index 52a960e33..fb7d651ff 100644 --- a/platform/src/functionalTest/groovy/net/neoforged/gradle/platform/E2ETests.groovy +++ b/platform/src/functionalTest/groovy/net/neoforged/gradle/platform/E2ETests.groovy @@ -549,7 +549,7 @@ class E2ETests extends BuilderBasedTestSpecification { } dependencies { - implementation 'net.neoforged:neoforge:1.0.0-published-userdev-can-be-loaded' + implementation 'net.neoforged:neoforge:1.0.0-published-userdev' } """) it.withToolchains() diff --git a/vanilla/src/main/java/net/neoforged/gradle/vanilla/runtime/steps/ParchmentStep.java b/vanilla/src/main/java/net/neoforged/gradle/vanilla/runtime/steps/ParchmentStep.java index 2fff73a37..041f49b74 100644 --- a/vanilla/src/main/java/net/neoforged/gradle/vanilla/runtime/steps/ParchmentStep.java +++ b/vanilla/src/main/java/net/neoforged/gradle/vanilla/runtime/steps/ParchmentStep.java @@ -12,10 +12,7 @@ import net.neoforged.gradle.dsl.common.util.CommonRuntimeUtils; import net.neoforged.gradle.dsl.common.util.GameArtifact; import net.neoforged.gradle.vanilla.runtime.VanillaRuntimeDefinition; -import net.neoforged.gradle.vanilla.runtime.spec.VanillaRuntimeSpecification; import org.gradle.api.Project; -import org.gradle.api.Transformer; -import org.gradle.api.artifacts.ResolvedArtifact; import org.gradle.api.file.RegularFile; import org.gradle.api.provider.Provider; import org.gradle.api.tasks.TaskProvider; @@ -34,28 +31,28 @@ public TaskProvider buildTask(VanillaRuntimeDefinition defini final TaskProvider collectLibraryInformationTask = pipelineTasks.get(CommonRuntimeUtils.buildTaskName(definition, "libraries")); return maybeApplyParchment( - definition.getSpecification(), + definition, inputProvidingTask, workingDirectory, collectLibraryInformationTask.flatMap(WithOutput::getOutput) ); } - private static TaskProvider maybeApplyParchment(VanillaRuntimeSpecification spec, + private static TaskProvider maybeApplyParchment(VanillaRuntimeDefinition definition, TaskProvider inputProvidingTask, File vanillaDirectory, Provider listLibrariesOutput) { - Project project = spec.getProject(); + Project project = definition.getSpecification().getProject(); Parchment parchment = project.getExtensions().getByType(Subsystems.class).getParchment(); Tools tools = project.getExtensions().getByType(Subsystems.class).getTools(); if (!parchment.getEnabled().get()) { - return project.getTasks().register(CommonRuntimeUtils.buildTaskName(spec, "applyParchmentNoop"), NoopRuntime.class, task -> { + return project.getTasks().register(CommonRuntimeUtils.buildTaskName(definition, "applyParchmentNoop"), NoopRuntime.class, task -> { task.getInput().set(inputProvidingTask.flatMap(WithOutput::getOutput)); }); } - return project.getTasks().register(CommonRuntimeUtils.buildTaskName(spec, "applyParchment"), DefaultExecute.class, task -> { + return project.getTasks().register(CommonRuntimeUtils.buildTaskName(definition, "applyParchment"), DefaultExecute.class, task -> { // Provide the mappings via artifact File mappingFile = ToolUtilities.resolveTool(project, parchment.getParchmentArtifact().get()); File toolExecutable = ToolUtilities.resolveTool(project, tools.getJST().get()); @@ -75,10 +72,19 @@ private static TaskProvider maybeApplyParchment(VanillaRuntim task.getProgramArguments().add("{input}"); task.getProgramArguments().add("{output}"); + final StringBuilder builder = new StringBuilder(); + definition.getAllDependencies().forEach(f -> { + if (!builder.isEmpty()) { + builder.append(File.pathSeparator); + } + builder.append(f.getAbsolutePath()); + }); + task.getProgramArguments().add("--classpath=" + builder); + task.dependsOn(inputProvidingTask); task.dependsOn(listLibrariesOutput); - configureCommonRuntimeTaskParameters(task, Maps.newHashMap(), "applyParchment", spec, vanillaDirectory); + configureCommonRuntimeTaskParameters(task, Maps.newHashMap(), "applyParchment", definition.getSpecification(), vanillaDirectory); }); }