2424import java .io .IOException ;
2525import java .nio .charset .StandardCharsets ;
2626import java .nio .file .Files ;
27+ import java .nio .file .StandardCopyOption ;
2728
2829@ CacheableTask
2930abstract 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