Skip to content

Commit 7cd480a

Browse files
committed
Don't fail entire process of extra step fails to serialize
1 parent 0248d77 commit 7cd480a

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/main/java/net/minecraftforge/mcmaven/cli/MCPTask.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,19 +244,29 @@ public static void run(String[] args) throws Exception {
244244
// TODO [Mavenizer][Extra MCPTask Files] do this better
245245
private static void writeFiles(MCPTaskFactory mcpTaskFactory, File output) {
246246
var files = new MCPSetupFiles();
247-
files.versionManifest = mcpTaskFactory.findStep("downloadManifest").execute().getAbsolutePath();
248-
files.versionJson = mcpTaskFactory.findStep("downloadJson").execute().getAbsolutePath();
249-
files.clientRaw = mcpTaskFactory.findStep("downloadClient").execute().getAbsolutePath();
250-
files.serverRaw = mcpTaskFactory.findStep("downloadServer").execute().getAbsolutePath();
251-
files.serverExtracted = mcpTaskFactory.findStep("extractServer").execute().getAbsolutePath();
247+
files.versionManifest = getTaskPath(mcpTaskFactory, "downloadManifest");
248+
files.versionJson = getTaskPath(mcpTaskFactory, "downloadJson");
249+
files.clientRaw = getTaskPath(mcpTaskFactory, "downloadClient");
250+
files.serverRaw = getTaskPath(mcpTaskFactory, "downloadServer");
251+
files.serverExtracted = getTaskPath(mcpTaskFactory, "extractServer");
252252
files.clientMappings = mcpTaskFactory.downloadClientMappings().execute().getAbsolutePath();
253253
files.serverMappings = mcpTaskFactory.downloadServerMappings().execute().getAbsolutePath();
254-
files.librariesList = mcpTaskFactory.findStep("listLibraries").execute().getAbsolutePath();
254+
files.librariesList = getTaskPath(mcpTaskFactory, "listLibraries");
255255

256256
try {
257257
JsonData.toJson(files, output);
258258
} catch (IOException e) {
259259
throw new RuntimeException("Failed to write extra files data: " + output.getPath(), e);
260260
}
261261
}
262+
263+
// TODO Do this better
264+
private static @Nullable String getTaskPath(MCPTaskFactory mcpTaskFactory, String step) {
265+
try {
266+
return mcpTaskFactory.findStep(step).execute().getAbsolutePath();
267+
} catch (Exception e) {
268+
LOGGER.error("Cannot serialize output path for MCP step: " + step);
269+
return null;
270+
}
271+
}
262272
}

0 commit comments

Comments
 (0)