mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Initial steps to be less aggressive overwriting kobalt-wrapper.jar.
This commit is contained in:
parent
1d39b74001
commit
83dfe4f5e4
1 changed files with 35 additions and 5 deletions
|
@ -143,7 +143,9 @@ public class Main {
|
||||||
return System.getProperty("os.name").contains("Windows");
|
return System.getProperty("os.name").contains("Windows");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String[] FILES = new String[] { KOBALTW, "kobalt/wrapper/" + FILE_NAME + "-wrapper.jar" };
|
private static final String OUT_DIR = "kobalt/wrapper/";
|
||||||
|
private static final String[] FILES = new String[] { KOBALTW, OUT_DIR + FILE_NAME + "-wrapper.jar" };
|
||||||
|
private static final String VERSION_TXT = "wrapper-version.txt";
|
||||||
|
|
||||||
private Path installDistribution() throws IOException {
|
private Path installDistribution() throws IOException {
|
||||||
String wrapperVersion;
|
String wrapperVersion;
|
||||||
|
@ -195,13 +197,30 @@ public class Main {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// If the user didn't specify --noOverwrite, compare the installed wrapper to the one
|
||||||
|
// we're trying to install and if they are the same, no need to overwrite
|
||||||
|
if (! noOverwrite) {
|
||||||
|
try (FileReader fw = new FileReader(new File(OUT_DIR, VERSION_TXT))) {
|
||||||
|
try (BufferedReader bw = new BufferedReader(fw)) {
|
||||||
|
String installedVersion = bw.readLine();
|
||||||
|
if (! wrapperVersion.equals(installedVersion)) {
|
||||||
|
log(2, " Trying to install a different version " + wrapperVersion + " != " + installedVersion
|
||||||
|
+ ", overwriting the installed wrapper");
|
||||||
|
} else {
|
||||||
|
log(2, " Trying to install the same version " + wrapperVersion + " == " + installedVersion
|
||||||
|
+ ", not overwriting the installed wrapper");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Copy the wrapper files in the current kobalt/wrapper directory
|
// Copy the wrapper files in the current kobalt/wrapper directory
|
||||||
//
|
//
|
||||||
|
|
||||||
if (! noOverwrite) {
|
if (! noOverwrite) {
|
||||||
log(2, "Copying the wrapper files");
|
for (String file : FILES) {
|
||||||
for (String file : FILES) {
|
|
||||||
Path to = Paths.get(file);
|
Path to = Paths.get(file);
|
||||||
to.toFile().getAbsoluteFile().getParentFile().mkdirs();
|
to.toFile().getAbsoluteFile().getParentFile().mkdirs();
|
||||||
|
|
||||||
|
@ -213,6 +232,7 @@ public class Main {
|
||||||
if (isWindows() && to.toFile().exists()) {
|
if (isWindows() && to.toFile().exists()) {
|
||||||
log(2, " Windows detected, not overwriting " + to);
|
log(2, " Windows detected, not overwriting " + to);
|
||||||
} else {
|
} else {
|
||||||
|
log(2, " Writing " + to);
|
||||||
Files.copy(from, to, StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(from, to, StandardCopyOption.REPLACE_EXISTING);
|
||||||
}
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
|
@ -220,6 +240,16 @@ public class Main {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Save wrapper-version.txt
|
||||||
|
//
|
||||||
|
log(2, " Writing version.txt");
|
||||||
|
try (FileWriter fw = new FileWriter(new File(OUT_DIR, VERSION_TXT))) {
|
||||||
|
try (BufferedWriter bw = new BufferedWriter(fw)) {
|
||||||
|
bw.write(wrapperVersion);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return kobaltJarFile;
|
return kobaltJarFile;
|
||||||
|
@ -240,7 +270,7 @@ public class Main {
|
||||||
if (envFile.exists()) {
|
if (envFile.exists()) {
|
||||||
content = "#!" + envFile.getAbsolutePath() + " bash\n";
|
content = "#!" + envFile.getAbsolutePath() + " bash\n";
|
||||||
}
|
}
|
||||||
log(2, "Generating " + KOBALTW + (envFile.exists() ? " with shebang" : "") + ".");
|
log(2, " Generating " + KOBALTW + (envFile.exists() ? " with shebang" : "") + ".");
|
||||||
|
|
||||||
content += "java -jar $(dirname $0)/kobalt/wrapper/kobalt-wrapper.jar $*\n";
|
content += "java -jar $(dirname $0)/kobalt/wrapper/kobalt-wrapper.jar $*\n";
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue