1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 00:17:11 -07:00

Generate kobaltw if possible.

This commit is contained in:
Cedric Beust 2015-11-17 03:08:08 -08:00
parent 7582a595ad
commit 0b5b437114

View file

@ -164,16 +164,33 @@ public class Main {
if (! noOverwrite && ! wrapperVersion.equals(version)) {
log(2, "Copying the wrapper files");
for (String file : FILES) {
Path from = Paths.get(zipOutputDir, file);
Path to = Paths.get(new File(".").getAbsolutePath(), file);
try {
if (isWindows() && to.toFile().exists()) {
log(1, "Windows detected, not overwriting " + to);
} else {
Files.copy(from, to, StandardCopyOption.REPLACE_EXISTING);
boolean extractFile = true;
if (file.equals("kobaltw")) {
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) {
Path from = Paths.get(zipOutputDir, file);
try {
if (isWindows() && to.toFile().exists()) {
log(1, "Windows detected, not overwriting " + to);
} else {
Files.copy(from, to, StandardCopyOption.REPLACE_EXISTING);
}
} catch (IOException ex) {
log(1, "Couldn't copy " + from + " to " + to + ": " + ex.getMessage());
}
} catch (IOException ex) {
log(1, "Couldn't copy " + from + " to " + to + ": " + ex.getMessage());
}
}