From 5b95f47e9b767269c214e6255233fb7fef4501d7 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 16 Feb 2016 21:59:41 -0800 Subject: [PATCH] Bubble up the return code correctly. --- .../main/java/com/beust/kobalt/wrapper/Main.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/wrapper/src/main/java/com/beust/kobalt/wrapper/Main.java b/modules/wrapper/src/main/java/com/beust/kobalt/wrapper/Main.java index 5c74f6c2..e5ef2062 100644 --- a/modules/wrapper/src/main/java/com/beust/kobalt/wrapper/Main.java +++ b/modules/wrapper/src/main/java/com/beust/kobalt/wrapper/Main.java @@ -12,7 +12,8 @@ import java.util.zip.ZipFile; //@com.beust.apt.processor.Version("1.3") public class Main { public static void main(String[] argv) throws IOException, InterruptedException { - new Main().installAndLaunchMain(argv); + int exitCode = new Main().installAndLaunchMain(argv); + System.exit(exitCode); } private static final String KOBALT_PROPERTIES = "kobalt.properties"; @@ -29,7 +30,7 @@ public class Main { private static int logLevel = 1; private boolean noOverwrite = false; - private void installAndLaunchMain(String[] argv) throws IOException, InterruptedException { + private int installAndLaunchMain(String[] argv) throws IOException, InterruptedException { List kobaltArgv = new ArrayList<>(); boolean noLaunch = false; for (int i = 0; i < argv.length; i++) { @@ -53,9 +54,11 @@ public class Main { } } Path kobaltJarFile = installDistribution(); + int result = 0; if (! noLaunch) { - launchMain(kobaltJarFile, kobaltArgv.toArray(new String[kobaltArgv.size()])); + result = launchMain(kobaltJarFile, kobaltArgv.toArray(new String[kobaltArgv.size()])); } + return result; } private void readProperties(Properties properties, InputStream ins) throws IOException { @@ -375,7 +378,7 @@ public class Main { System.out.println("[Wrapper error] *** " + s); } - private void launchMain(Path kobaltJarFile, String[] argv) throws IOException, InterruptedException { + private int launchMain(Path kobaltJarFile, String[] argv) throws IOException, InterruptedException { List args = new ArrayList<>(); args.add("java"); args.add("-jar"); @@ -386,8 +389,7 @@ public class Main { pb.inheritIO(); log(2, "Launching " + args); Process process = pb.start(); - process.waitFor(); - + return process.waitFor(); } } \ No newline at end of file