Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
Fix idea sync detection
Fix running of parchment via JST
  • Loading branch information
marchermans committed Jun 25, 2024
1 parent 5de4aac commit 3b4c3ac
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ protected void bakeDefinition(NeoFormRuntimeDefinition definition) {
remapTask.configure(task -> configureMcpRuntimeTaskWithDefaults(spec, neoFormDirectory, symbolicDataSources, task));

TaskProvider<? extends WithOutput> recompileInput = maybeApplyParchment(
spec,
definition,
remapTask,
symbolicDataSources,
neoFormDirectory,
Expand Down Expand Up @@ -492,19 +492,19 @@ protected void bakeDefinition(NeoFormRuntimeDefinition definition) {
});
}

private static TaskProvider<? extends WithOutput> maybeApplyParchment(NeoFormRuntimeSpecification spec,
private static TaskProvider<? extends WithOutput> maybeApplyParchment(NeoFormRuntimeDefinition runtimeDefinition,
TaskProvider<? extends WithOutput> recompileInput,
Map<String, String> symbolicDataSources,
File neoFormDirectory,
Provider<RegularFile> 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<? extends Runtime> applyParchmentTask = project.getTasks().register(CommonRuntimeUtils.buildTaskName(spec, "applyParchment"), DefaultExecute.class, task -> {
TaskProvider<? extends Runtime> 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();
Expand All @@ -526,10 +526,19 @@ private static TaskProvider<? extends WithOutput> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,28 +31,28 @@ public TaskProvider<? extends Runtime> buildTask(VanillaRuntimeDefinition defini
final TaskProvider<? extends WithOutput> collectLibraryInformationTask = pipelineTasks.get(CommonRuntimeUtils.buildTaskName(definition, "libraries"));

return maybeApplyParchment(
definition.getSpecification(),
definition,
inputProvidingTask,
workingDirectory,
collectLibraryInformationTask.flatMap(WithOutput::getOutput)
);
}

private static TaskProvider<? extends Runtime> maybeApplyParchment(VanillaRuntimeSpecification spec,
private static TaskProvider<? extends Runtime> maybeApplyParchment(VanillaRuntimeDefinition definition,
TaskProvider<? extends WithOutput> inputProvidingTask,
File vanillaDirectory,
Provider<RegularFile> 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());
Expand All @@ -75,10 +72,19 @@ private static TaskProvider<? extends Runtime> 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);
});
}

Expand Down

0 comments on commit 3b4c3ac

Please sign in to comment.