From 2fb3c2163eab2e4de51f245cbaeffb3079647eb9 Mon Sep 17 00:00:00 2001 From: Laurens Date: Thu, 10 Dec 2015 01:21:14 +0100 Subject: [PATCH 1/3] Always generate kobaltw file -- fix for issue with wrong line endings on unix systems --- .../java/com/beust/kobalt/wrapper/Main.java | 61 +++++++++++-------- 1 file changed, 34 insertions(+), 27 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 0735060a..1442ebdf 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 @@ -165,30 +165,15 @@ public class Main { log(2, "Copying the wrapper files"); for (String file : FILES) { Path to = Paths.get(new File(".").getAbsolutePath(), file); + + if (file.equals(KOBALTW)) { + generateKobaltW(to); + } + if (Files.exists(to)) { log(1, to + " already exists, not overwriting it"); continue; - } - boolean extractFile = true; - if (file.equals(KOBALTW)) { - // - // For kobaltw: try to generate it with the correct env shebang. If this fails, - // we'll extract the one from the zip file - // - File envFile = new File("/bin/env"); - if (!envFile.exists()) { - envFile = new File("/usr/bin/env"); - } - if (envFile.exists()) { - log(2, "Located " + envFile.getAbsolutePath() + ", generating " + file); - String content = "#!" + envFile.getAbsolutePath() + " bash\n" - + "java -jar $(dirname $0)/kobalt/wrapper/kobalt-wrapper.jar $*\n"; - Files.write(to, content.getBytes()); - extractFile = false; - } - } - - if (extractFile) { + } else { Path from = Paths.get(zipOutputDir, file); try { if (isWindows() && to.toFile().exists()) { @@ -201,17 +186,39 @@ public class Main { } } } - - if (!new File(KOBALTW).setExecutable(true)) { - if (!isWindows()) { - log(1, "Couldn't make " + KOBALTW + " executable"); - } - } } return kobaltJarFile; } + private void generateKobaltW(Path filePath) throws IOException { + // + // For kobaltw: try to generate it with the correct env shebang. If this fails, + // we'll generate it without the env shebang + // + File envFile = new File("/bin/env"); + if (!envFile.exists()) { + envFile = new File("/usr/bin/env"); + } + + String content = ""; + + if (envFile.exists()) { + content = "#!" + envFile.getAbsolutePath() + " bash\n"; + } + log(2, "Generating " + KOBALTW + (envFile.exists() ? " with shebang" : "") + "."); + + content += "java -jar $(dirname $0)/kobalt/wrapper/kobalt-wrapper.jar $*\n"; + + Files.write(filePath, content.getBytes()); + + if (!new File(KOBALTW).setExecutable(true)) { + if (!isWindows()) { + log(1, "Couldn't make " + KOBALTW + " executable"); + } + } + } + /** * Extract the zip file in ~/.kobalt/wrapper/dist/$version */ From e225110166f6f6aa01c53390d9ff79e1e75795e3 Mon Sep 17 00:00:00 2001 From: Laurens Date: Thu, 10 Dec 2015 01:29:59 +0100 Subject: [PATCH 2/3] remove current kobaltw file --- kobaltw | 2 -- 1 file changed, 2 deletions(-) delete mode 100755 kobaltw diff --git a/kobaltw b/kobaltw deleted file mode 100755 index 1fd228db..00000000 --- a/kobaltw +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bash -java -jar $(dirname $0)/kobalt/wrapper/kobalt-wrapper.jar $* From 8a80c095ac8efe7578c653494f27e3383d7b2df3 Mon Sep 17 00:00:00 2001 From: Laurens Muller Date: Thu, 10 Dec 2015 09:34:13 +0100 Subject: [PATCH 3/3] Revert "remove current kobaltw file" This reverts commit e225110166f6f6aa01c53390d9ff79e1e75795e3. --- kobaltw | 2 ++ 1 file changed, 2 insertions(+) create mode 100755 kobaltw diff --git a/kobaltw b/kobaltw new file mode 100755 index 00000000..1fd228db --- /dev/null +++ b/kobaltw @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +java -jar $(dirname $0)/kobalt/wrapper/kobalt-wrapper.jar $*