9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-19 15:09:18 +00:00

make gradle setup print to console on failure

This commit is contained in:
Julian Krings
2025-10-04 13:40:47 +02:00
parent f3ef1ca2ae
commit b46c413f6b

View File

@@ -9,9 +9,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URI; import java.net.URI;
import java.util.HashMap; import java.util.*;
import java.util.Optional;
import java.util.Scanner;
public class Gradle { public class Gradle {
private static final boolean WINDOWS = System.getProperty("os.name").toLowerCase().contains("win"); private static final boolean WINDOWS = System.getProperty("os.name").toLowerCase().contains("win");
@@ -38,10 +36,15 @@ public class Gradle {
cmd[0] = gradle.getAbsolutePath(); cmd[0] = gradle.getAbsolutePath();
System.arraycopy(args, 0, cmd, 1, args.length); System.arraycopy(args, 0, cmd, 1, args.length);
var process = Runtime.getRuntime().exec(cmd, ENVIRONMENT, projectDir); var process = Runtime.getRuntime().exec(cmd, ENVIRONMENT, projectDir);
attach(process.getInputStream()); var lines = Collections.synchronizedList(new ArrayList<String>());
attach(process.getErrorStream()); attach(process.getInputStream(), lines);
attach(process.getErrorStream(), lines);
var code = process.waitFor(); var code = process.waitFor();
if (code == 0) return; if (code == 0) {
lines.forEach(Iris::debug);
return;
}
lines.forEach(Iris::error);
throw new RuntimeException("Gradle exited with code " + code); throw new RuntimeException("Gradle exited with code " + code);
} }
@@ -91,12 +94,12 @@ public class Gradle {
.orElseThrow(() -> new RuntimeException("Failed to find java home, please set java.home system property")); .orElseThrow(() -> new RuntimeException("Failed to find java home, please set java.home system property"));
} }
private static void attach(InputStream stream) { private static void attach(InputStream stream, List<String> list) {
Thread.ofVirtual().start(() -> { Thread.ofPlatform().start(() -> {
try (var in = new Scanner(stream)) { try (var in = new Scanner(stream)) {
while (in.hasNextLine()) { while (in.hasNextLine()) {
String line = in.nextLine(); String line = in.nextLine();
Iris.debug("[GRADLE] " + line); list.add(line);
} }
} }
}); });