Skip to content

Commit 2467906

Browse files
committed
Fix overlapping task output for SlimeLauncherMetadata, Fixes #1086
1 parent 97cb57d commit 2467906

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

src/main/java/net/minecraftforge/gradle/internal/SlimeLauncherMetadata.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.io.IOException;
2525
import java.nio.charset.StandardCharsets;
2626
import java.nio.file.Files;
27+
import java.nio.file.StandardCopyOption;
2728

2829
@CacheableTask
2930
abstract class SlimeLauncherMetadata extends DefaultTask implements ForgeGradleTask {
@@ -48,10 +49,8 @@ static TaskProvider<SlimeLauncherMetadata> register(Project project, MinecraftDe
4849

4950
@Inject
5051
public SlimeLauncherMetadata() {
51-
this.getOutputDirectory().convention(this.getDefaultOutputDirectory());
52-
this.getRunsJson().convention(
53-
this.getOutputDirectory().map(d -> d.dir("launcher").file("runs.json"))
54-
);
52+
this.getOutputDirectory().convention(this.getDefaultOutputDirectory().map(d -> d.dir("metadata")));
53+
this.getRunsJson().convention(this.getOutputFile("runs.json"));
5554
}
5655

5756
@TaskAction
@@ -67,8 +66,12 @@ protected void exec() throws IOException {
6766
// Write an empty runs.json if it doesn't exist
6867
// This happens when using a 'vanilla' Minecraft dependency
6968
var json = this.getRunsJson().getAsFile().get().toPath();
70-
if (!Files.exists(json)) {
71-
Files.createDirectories(json.getParent());
69+
Files.createDirectories(json.getParent());
70+
71+
var extractedJson = outputDir.dir("launcher").file("runs.json").getAsFile().toPath();
72+
if (Files.exists(extractedJson)) {
73+
Files.copy(extractedJson, json, StandardCopyOption.REPLACE_EXISTING);
74+
} else {
7275
Files.writeString(json, "{}", StandardCharsets.UTF_8);
7376
}
7477
}

0 commit comments

Comments
 (0)