Skip to content

Commit

Permalink
Fix vanilla user transformer not detecting missing files and not runn…
Browse files Browse the repository at this point in the history
…ing.
  • Loading branch information
marchermans committed Oct 20, 2024
1 parent 91907c6 commit fa28bfb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import org.gradle.api.file.FileTree;
import org.gradle.api.tasks.TaskProvider;

import java.io.File;

public final class CommonRuntimeTaskUtils {

private CommonRuntimeTaskUtils() {
Expand All @@ -35,7 +33,7 @@ public static TaskProvider<? extends SourceInterfaceInjection> createSourceInter
});
}

public static TaskProvider<? extends BinaryAccessTransformer> createBinaryAccessTransformer(Definition<?> definition, String namePreFix, File workspaceDirectory, FileTree files) {
public static TaskProvider<? extends BinaryAccessTransformer> createBinaryAccessTransformer(Definition<?> definition, String namePreFix, FileTree files) {
return definition.getSpecification().getProject().getTasks().register(CommonRuntimeUtils.buildTaskName(definition.getSpecification(), String.format("apply%sAccessTransformer", StringCapitalizationUtils.capitalize(namePreFix))), BinaryAccessTransformer.class, task -> {
task.getTransformers().from(files);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,26 +165,28 @@ protected void bakeDefinition(VanillaRuntimeDefinition definition) {
)
);

task.configure((Runtime mcpRuntimeTask) -> configureCommonRuntimeTaskParameters(mcpRuntimeTask, step.getName(), spec, runtimeWorkingDirectory));

if (!spec.getPostTypeAdapters().containsKey(step.getName())) {
definition.getTasks().put(task.getName(), task);
} else {
int taskPostAdapterIndex = 0;
for (TaskTreeAdapter taskTreeAdapter : spec.getPostTypeAdapters().get(step.getName())) {
final AtomicInteger additionalPostAdapterTasks = new AtomicInteger(0);
final int currentPostAdapterIndex = taskPostAdapterIndex++;
final TaskProvider<? extends Runtime> taskProvider = taskTreeAdapter.adapt(definition, task, vanillaDirectory, definition.getGameArtifactProvidingTasks(), definition.getMappingVersionData(), dependentTaskProvider -> dependentTaskProvider.configure(additionalTask -> configureCommonRuntimeTaskParameters(additionalTask, step.getName() + "PostAdapter" + currentPostAdapterIndex + "-" + additionalPostAdapterTasks.getAndIncrement(), spec, runtimeWorkingDirectory)));
if (taskProvider != null) {
taskProvider.configure(adaptedTask -> configureCommonRuntimeTaskParameters(adaptedTask, step.getName() + "PostAdapter" + currentPostAdapterIndex + "-" + additionalPostAdapterTasks.getAndIncrement(), spec, runtimeWorkingDirectory));
task = taskProvider;
if (task != null) {
task.configure((Runtime mcpRuntimeTask) -> configureCommonRuntimeTaskParameters(mcpRuntimeTask, step.getName(), spec, runtimeWorkingDirectory));

if (!spec.getPostTypeAdapters().containsKey(step.getName())) {
definition.getTasks().put(task.getName(), task);
} else {
int taskPostAdapterIndex = 0;
for (TaskTreeAdapter taskTreeAdapter : spec.getPostTypeAdapters().get(step.getName())) {
final AtomicInteger additionalPostAdapterTasks = new AtomicInteger(0);
final int currentPostAdapterIndex = taskPostAdapterIndex++;
final TaskProvider<? extends Runtime> taskProvider = taskTreeAdapter.adapt(definition, task, vanillaDirectory, definition.getGameArtifactProvidingTasks(), definition.getMappingVersionData(), dependentTaskProvider -> dependentTaskProvider.configure(additionalTask -> configureCommonRuntimeTaskParameters(additionalTask, step.getName() + "PostAdapter" + currentPostAdapterIndex + "-" + additionalPostAdapterTasks.getAndIncrement(), spec, runtimeWorkingDirectory)));
if (taskProvider != null) {
taskProvider.configure(adaptedTask -> configureCommonRuntimeTaskParameters(adaptedTask, step.getName() + "PostAdapter" + currentPostAdapterIndex + "-" + additionalPostAdapterTasks.getAndIncrement(), spec, runtimeWorkingDirectory));
task = taskProvider;
}
}

definition.getTasks().put(task.getName(), task);
}

definition.getTasks().put(task.getName(), task);
currentInput = task;
}

currentInput = task;
}

final TaskProvider<? extends WithOutput> sourcesTask = Iterators.getLast(definition.getTasks().values().iterator());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ public TaskProvider<? extends Runtime> buildTask(VanillaRuntimeDefinition defini
final Minecraft minecraftExtension = definition.getSpecification().getProject().getExtensions().getByType(Minecraft.class);
final AccessTransformers accessTransformerFiles = minecraftExtension.getAccessTransformers();

if (accessTransformerFiles.getFiles().isEmpty()) {
return null;
}

final TaskProvider<? extends BinaryAccessTransformer> task = CommonRuntimeTaskUtils.createBinaryAccessTransformer(
definition,
"user",
workingDirectory,
accessTransformerFiles.getFiles().getAsFileTree()
);

Expand Down

0 comments on commit fa28bfb

Please sign in to comment.