mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
--noOverwrite
This commit is contained in:
parent
d93975d426
commit
b31da8fa49
2 changed files with 30 additions and 16 deletions
|
@ -27,23 +27,34 @@ public class Main {
|
||||||
private final Properties wrapperProperties = new Properties();
|
private final Properties wrapperProperties = new Properties();
|
||||||
|
|
||||||
private static int logLevel = 1;
|
private static int logLevel = 1;
|
||||||
|
private boolean noOverwrite = false;
|
||||||
|
|
||||||
private void installAndLaunchMain(String[] argv) throws IOException, InterruptedException {
|
private void installAndLaunchMain(String[] argv) throws IOException, InterruptedException {
|
||||||
|
List<String> kobaltArgv = new ArrayList<>();
|
||||||
boolean noLaunch = false;
|
boolean noLaunch = false;
|
||||||
for (int i = 0; i < argv.length; i++) {
|
for (int i = 0; i < argv.length; i++) {
|
||||||
|
boolean passToKobalt = true;
|
||||||
switch(argv[i]) {
|
switch(argv[i]) {
|
||||||
case "--no-launch":
|
case "--noOverwrite":
|
||||||
|
noOverwrite = true;
|
||||||
|
passToKobalt = false;
|
||||||
|
break;
|
||||||
|
case "--noLaunch":
|
||||||
noLaunch = true;
|
noLaunch = true;
|
||||||
break;
|
break;
|
||||||
case "--log":
|
case "--log":
|
||||||
logLevel = Integer.parseInt(argv[i + 1]);
|
logLevel = Integer.parseInt(argv[i + 1]);
|
||||||
|
kobaltArgv.add(argv[i]);
|
||||||
i++;
|
i++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (passToKobalt) {
|
||||||
|
kobaltArgv.add(argv[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Path kobaltJarFile = installJarFile();
|
Path kobaltJarFile = installJarFile();
|
||||||
if (! noLaunch) {
|
if (! noLaunch) {
|
||||||
launchMain(kobaltJarFile, argv);
|
launchMain(kobaltJarFile, kobaltArgv.toArray(new String[kobaltArgv.size()]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,24 +142,26 @@ public class Main {
|
||||||
//
|
//
|
||||||
// Extract all the zip files
|
// Extract all the zip files
|
||||||
//
|
//
|
||||||
int retries = 0;
|
if (! noOverwrite) {
|
||||||
while (retries < 2) {
|
int retries = 0;
|
||||||
try {
|
while (retries < 2) {
|
||||||
extractZipFile(localZipFile, zipOutputDir);
|
try {
|
||||||
break;
|
extractZipFile(localZipFile, zipOutputDir);
|
||||||
} catch (ZipException e) {
|
break;
|
||||||
retries++;
|
} catch (ZipException e) {
|
||||||
error("Couldn't open zip file " + localZipFile + ": " + e.getMessage());
|
retries++;
|
||||||
error("The file is probably corrupt, downloading it again");
|
error("Couldn't open zip file " + localZipFile + ": " + e.getMessage());
|
||||||
Files.delete(localZipFile);
|
error("The file is probably corrupt, downloading it again");
|
||||||
download(localZipFile.toFile(), wrapperVersion);
|
Files.delete(localZipFile);
|
||||||
|
download(localZipFile.toFile(), wrapperVersion);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Copy the wrapper files in the current kobalt/wrapper directory
|
// Copy the wrapper files in the current kobalt/wrapper directory
|
||||||
//
|
//
|
||||||
if (! 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 from = Paths.get(zipOutputDir, file);
|
||||||
|
@ -175,6 +188,7 @@ public class Main {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void extractZipFile(Path localZipFile, String zipOutputDir) throws IOException {
|
private void extractZipFile(Path localZipFile, String zipOutputDir) throws IOException {
|
||||||
|
log(2, "Extracting " + localZipFile);
|
||||||
try (ZipFile zipFile = new ZipFile(localZipFile.toFile())) {
|
try (ZipFile zipFile = new ZipFile(localZipFile.toFile())) {
|
||||||
Enumeration<? extends ZipEntry> entries = zipFile.entries();
|
Enumeration<? extends ZipEntry> entries = zipFile.entries();
|
||||||
while (entries.hasMoreElements()) {
|
while (entries.hasMoreElements()) {
|
||||||
|
|
|
@ -134,9 +134,9 @@ private class Main @Inject constructor(
|
||||||
if (args.init) {
|
if (args.init) {
|
||||||
//
|
//
|
||||||
// --init: create a new build project and install the wrapper
|
// --init: create a new build project and install the wrapper
|
||||||
// Make sure the wrapper won't call us back with --no-launch
|
// Make sure the wrapper won't call us back with --noLaunch
|
||||||
//
|
//
|
||||||
com.beust.kobalt.wrapper.Main.main(arrayOf("--no-launch") + argv)
|
com.beust.kobalt.wrapper.Main.main(arrayOf("--noLaunch") + argv)
|
||||||
projectGenerator.run(args)
|
projectGenerator.run(args)
|
||||||
} else if (args.usage) {
|
} else if (args.usage) {
|
||||||
jc.usage()
|
jc.usage()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue