Amélioration de la gestion des dépendances et ajout de la sortie des erreurs lors de l'exécution des commandes
This commit is contained in:
@@ -38,12 +38,39 @@ public class CommandExecutor {
|
||||
if (debug) System.out.println("Debug: Executing " + command);
|
||||
ProcessBuilder pb = new ProcessBuilder("sh", "-c", command);
|
||||
Process process = pb.start();
|
||||
|
||||
// Lire et afficher la sortie standard (stdout)
|
||||
new Thread(() -> {
|
||||
try (var reader = new java.io.BufferedReader(new java.io.InputStreamReader(process.getInputStream()))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
System.out.println(line);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
|
||||
// Lire et afficher la sortie d'erreur (stderr)
|
||||
new Thread(() -> {
|
||||
try (var reader = new java.io.BufferedReader(new java.io.InputStreamReader(process.getErrorStream()))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
System.err.println(line);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
|
||||
// Attendre la fin du processus
|
||||
int exitCode = process.waitFor();
|
||||
|
||||
|
||||
if (exitCode != 0) {
|
||||
System.err.println("Error executing " + rule.getName());
|
||||
System.exit(1);
|
||||
System.err.println("bake: *** [" + rule.getName() + "] Error " + exitCode);
|
||||
System.exit(exitCode);
|
||||
}
|
||||
|
||||
} catch (IOException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
|
||||
Reference in New Issue
Block a user