Remove build.version dependency
- Read version only from JAR manifest (Implementation-Version) - Remove all VERSION_FILE references from Bootstrap - Remove build.version from scanLocalFiles() and update methods
This commit is contained in:
@@ -12,7 +12,6 @@ import java.util.jar.Attributes;
|
|||||||
import java.util.jar.Manifest;
|
import java.util.jar.Manifest;
|
||||||
|
|
||||||
public class Bootstrap {
|
public class Bootstrap {
|
||||||
private static final String VERSION_FILE = "build.version";
|
|
||||||
private static final String JAR_NAME = "zernmclauncher.jar";
|
private static final String JAR_NAME = "zernmclauncher.jar";
|
||||||
private static final String BASE_URL = "http://87.120.187.36:1582";
|
private static final String BASE_URL = "http://87.120.187.36:1582";
|
||||||
private static final int BUFFER_SIZE = 8192;
|
private static final int BUFFER_SIZE = 8192;
|
||||||
@@ -85,12 +84,6 @@ public class Bootstrap {
|
|||||||
}
|
}
|
||||||
} catch (Exception ignored) {}
|
} catch (Exception ignored) {}
|
||||||
|
|
||||||
// Fallback: из build.version
|
|
||||||
Path f = baseDir.resolve(VERSION_FILE);
|
|
||||||
try {
|
|
||||||
if (Files.exists(f)) return Files.readString(f).trim();
|
|
||||||
} catch (Exception ignored) {}
|
|
||||||
|
|
||||||
return "0.0.0";
|
return "0.0.0";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,8 +200,7 @@ public class Bootstrap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. Записываем новую версию
|
// 6. Версия уже в манифесте JAR
|
||||||
Files.writeString(baseDir.resolve(VERSION_FILE), serverVersion);
|
|
||||||
log("Обновлено до v" + serverVersion);
|
log("Обновлено до v" + serverVersion);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -336,7 +328,6 @@ public class Bootstrap {
|
|||||||
// Сканируем основную директорию
|
// Сканируем основную директорию
|
||||||
try (DirectoryStream<Path> stream = Files.newDirectoryStream(baseDir)) {
|
try (DirectoryStream<Path> stream = Files.newDirectoryStream(baseDir)) {
|
||||||
for (Path p : stream) {
|
for (Path p : stream) {
|
||||||
if (p.getFileName().toString().equals("build.version")) continue;
|
|
||||||
if (p.getFileName().toString().equals("logs")) continue;
|
if (p.getFileName().toString().equals("logs")) continue;
|
||||||
if (p.getFileName().toString().equals("data")) continue;
|
if (p.getFileName().toString().equals("data")) continue;
|
||||||
|
|
||||||
@@ -502,7 +493,7 @@ public class Bootstrap {
|
|||||||
Files.move(tmp, jarFile, StandardCopyOption.REPLACE_EXISTING);
|
Files.move(tmp, jarFile, StandardCopyOption.REPLACE_EXISTING);
|
||||||
if (Files.exists(backup)) Files.delete(backup);
|
if (Files.exists(backup)) Files.delete(backup);
|
||||||
|
|
||||||
Files.writeString(baseDir.resolve(VERSION_FILE), newVersion);
|
// Версия уже в манифесте JAR
|
||||||
log("Обновлено до v" + newVersion + " (JAR метод)");
|
log("Обновлено до v" + newVersion + " (JAR метод)");
|
||||||
} else {
|
} else {
|
||||||
throw new IOException("Сервер вернул код: " + conn.getResponseCode());
|
throw new IOException("Сервер вернул код: " + conn.getResponseCode());
|
||||||
|
|||||||
Reference in New Issue
Block a user