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:
parent
7582a595ad
commit
0b5b437114
1 changed files with 25 additions and 8 deletions
|
@ -164,16 +164,33 @@ public class Main {
|
||||||
if (! noOverwrite && ! wrapperVersion.equals(version)) {
|
if (! noOverwrite && ! wrapperVersion.equals(version)) {
|
||||||
log(2, "Copying the wrapper files");
|
log(2, "Copying the wrapper files");
|
||||||
for (String file : FILES) {
|
for (String file : FILES) {
|
||||||
Path from = Paths.get(zipOutputDir, file);
|
|
||||||
Path to = Paths.get(new File(".").getAbsolutePath(), file);
|
Path to = Paths.get(new File(".").getAbsolutePath(), file);
|
||||||
try {
|
boolean extractFile = true;
|
||||||
if (isWindows() && to.toFile().exists()) {
|
if (file.equals("kobaltw")) {
|
||||||
log(1, "Windows detected, not overwriting " + to);
|
File envFile = new File("/bin/env");
|
||||||
} else {
|
if (!envFile.exists()) {
|
||||||
Files.copy(from, to, StandardCopyOption.REPLACE_EXISTING);
|
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());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue