diff --git a/src/fr/monlouyan/bakefile/CommandExecutor.java b/src/fr/monlouyan/bakefile/CommandExecutor.java index a4d6261..60664dc 100644 --- a/src/fr/monlouyan/bakefile/CommandExecutor.java +++ b/src/fr/monlouyan/bakefile/CommandExecutor.java @@ -76,6 +76,12 @@ public class CommandExecutor { // Enlever le @ si présent pour exécuter la commande correctement String actualCommand = silent ? command.substring(1) : command; + boolean ignoreErrors = actualCommand.startsWith("-"); + + if(ignoreErrors){ + actualCommand = actualCommand.substring(1).trim(); + } + if (isCircular){ if (!silent) { System.out.println(actualCommand); @@ -96,14 +102,25 @@ public class CommandExecutor { // Attendre la fin du processus int exitCode = process.waitFor(); - if (exitCode != 0) { - System.err.println("bake: *** [" + rule.getName() + "] Error " + exitCode); - System.exit(2); + if (exitCode != 0) { + if (ignoreErrors) { + System.err.println("bake: [" + rule.getName() + "] Error " + exitCode + " (ignored)"); + } else { + System.err.println("bake: *** [" + rule.getName() + "] Error " + exitCode); + System.exit(2); + } + } else if (exitCode != 0 && ignoreErrors && debug) { + System.out.println("Debug: Command failed with exit code " + exitCode + ", but errors are ignored"); } } catch (IOException | InterruptedException e) { - e.printStackTrace(); - System.exit(2); + if(!ignoreErrors){ + e.printStackTrace(); + System.exit(2); + } else if(debug){ + System.out.println("Debug: Command execution failed, but errors are ignored"); + e.printStackTrace(); + } } } } diff --git a/tests/tests-autres-groupes/amir/bake/Bakefile b/tests/tests-autres-groupes/amir/bake/Bakefile new file mode 100644 index 0000000..e1876d2 --- /dev/null +++ b/tests/tests-autres-groupes/amir/bake/Bakefile @@ -0,0 +1,9 @@ +all: main + +main: + echo "Compilation de main..." + touch main + +clean: + - rm main + @echo "Fichiers nettoyés." diff --git a/tests/tests-autres-groupes/amir/bake/main b/tests/tests-autres-groupes/amir/bake/main new file mode 100644 index 0000000..e69de29 diff --git a/tests/tests-autres-groupes/amir/make/Makefile b/tests/tests-autres-groupes/amir/make/Makefile new file mode 100644 index 0000000..e1876d2 --- /dev/null +++ b/tests/tests-autres-groupes/amir/make/Makefile @@ -0,0 +1,9 @@ +all: main + +main: + echo "Compilation de main..." + touch main + +clean: + - rm main + @echo "Fichiers nettoyés." diff --git a/tests/tests-autres-groupes/amir/make/main b/tests/tests-autres-groupes/amir/make/main new file mode 100644 index 0000000..e69de29