Skip to content

Commit

Permalink
Do not resolve legacy classpath task dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Technici4n committed Sep 16, 2024
1 parent 524ca06 commit 7798ca3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,7 @@ public void apply(Project project) {
writeLcp.setGroup(INTERNAL_TASK_GROUP);
writeLcp.setDescription("Writes the legacyClasspath file for the " + run.getName() + " Minecraft run, containing all dependencies that shouldn't be considered boot modules.");
writeLcp.getLegacyClasspathFile().convention(modDevBuildDir.map(dir -> dir.file(InternalModelHelper.nameOfRun(run, "", "legacyClasspath") + ".txt")));
writeLcp.getEntries().from(legacyClasspathConfiguration);
writeLcp.getEntries().from(createArtifacts.get().getResourcesArtifact());
writeLcp.addEntries(legacyClasspathConfiguration, createArtifacts.get().getResourcesArtifact());
});

var prepareRunTask = tasks.register(InternalModelHelper.nameOfRun(run, "prepare", "run"), PrepareRun.class, task -> {
Expand Down Expand Up @@ -692,8 +691,7 @@ private void setupTesting(Project project,
writeLcp.setGroup(INTERNAL_TASK_GROUP);
writeLcp.setDescription("Writes the legacyClasspath file for the test run, containing all dependencies that shouldn't be considered boot modules.");
writeLcp.getLegacyClasspathFile().convention(runArgsDir.map(dir -> dir.file("legacyClasspath.txt")));
writeLcp.getEntries().from(legacyClasspathConfiguration);
writeLcp.getEntries().from(createArtifacts.get().getResourcesArtifact());
writeLcp.addEntries(legacyClasspathConfiguration, createArtifacts.get().getResourcesArtifact());
});

var vmArgsFile = runArgsDir.map(dir -> dir.file("vmArgs.txt"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
import org.gradle.api.DefaultTask;
import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.provider.ListProperty;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.InputFiles;
import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.TaskAction;

import javax.inject.Inject;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.TreeSet;
Expand All @@ -18,8 +21,19 @@ abstract class WriteLegacyClasspath extends DefaultTask {
public WriteLegacyClasspath() {
}

@InputFiles
abstract ConfigurableFileCollection getEntries();
@Input
abstract ListProperty<String> getEntries();

void addEntries(Object... filesNotation) {
var files = getProject().files(filesNotation);
getEntries().addAll(getProject().provider(() -> {
// Use a provider indirection to remove task dependencies.
// Use file names only.
return files.getFiles().stream()
.map(File::getAbsolutePath)
.toList();
}));
}

@OutputFile
abstract RegularFileProperty getLegacyClasspathFile();
Expand All @@ -28,8 +42,8 @@ public WriteLegacyClasspath() {
public void writeLegacyClasspath() throws IOException {
var legacyClasspath = new StringBuilder();
// Copy the entries to a tree set to ensure deterministic order if we have to debug classpath problems...
for (var entry : new TreeSet<>(getEntries().getFiles())) {
legacyClasspath.append(entry.getAbsolutePath()).append(System.lineSeparator());
for (var entry : new TreeSet<>(getEntries().get())) {
legacyClasspath.append(entry).append(System.lineSeparator());
}

var destination = getLegacyClasspathFile().getAsFile().get().toPath();
Expand Down

0 comments on commit 7798ca3

Please sign in to comment.