mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
Избавление от formatVars
This commit is contained in:
parent
f8853ff353
commit
d14564f54e
4 changed files with 17 additions and 18 deletions
|
@ -30,6 +30,7 @@
|
|||
import java.util.zip.CRC32;
|
||||
|
||||
import ru.gravit.launcher.LauncherAPI;
|
||||
import ru.gravit.launcher.LauncherVersion;
|
||||
import ru.gravit.launcher.hasher.HashedDir;
|
||||
import ru.gravit.utils.helper.CommonHelper;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
|
@ -195,9 +196,9 @@ private ExeConf(BlockConfigEntry block) {
|
|||
trademarks = block.hasEntry("trademarks") ? block.getEntryValue("trademarks", StringConfigEntry.class)
|
||||
: "This product is licensed under MIT License";
|
||||
txtFileVersion = block.hasEntry("txtFileVersion") ? block.getEntryValue("txtFileVersion", StringConfigEntry.class)
|
||||
: CommonHelper.formatVars("$VERSION$, build $BUILDNUMBER$");
|
||||
: String.format("%s, build %d", LauncherVersion.getVersion().getVersionString(),LauncherVersion.getVersion().build);
|
||||
txtProductVersion = block.hasEntry("txtProductVersion") ? block.getEntryValue("txtProductVersion", StringConfigEntry.class)
|
||||
: CommonHelper.formatVars("$VERSION$, build $BUILDNUMBER$");
|
||||
: String.format("%s, build %d", LauncherVersion.getVersion().getVersionString(),LauncherVersion.getVersion().build);
|
||||
}
|
||||
}
|
||||
private final class ProfilesFileVisitor extends SimpleFileVisitor<Path> {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
import java.nio.file.Path;
|
||||
|
||||
import ru.gravit.launcher.LauncherAPI;
|
||||
import ru.gravit.launcher.LauncherVersion;
|
||||
import ru.gravit.utils.helper.CommonHelper;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
@ -91,15 +92,15 @@ private void setConfig() {
|
|||
// Prepare version info (product)
|
||||
VersionInfo info = new VersionInfo();
|
||||
info.setProductName(server.config.launch4j.productName);
|
||||
info.setProductVersion(CommonHelper.formatVars(server.config.launch4j.productVer));
|
||||
info.setProductVersion(formatVars(server.config.launch4j.productVer));
|
||||
info.setFileDescription(server.config.launch4j.fileDesc);
|
||||
info.setFileVersion(CommonHelper.formatVars(server.config.launch4j.fileVer));
|
||||
info.setFileVersion(formatVars(server.config.launch4j.fileVer));
|
||||
info.setCopyright(server.config.launch4j.copyright);
|
||||
info.setTrademarks(server.config.launch4j.trademarks);
|
||||
info.setInternalName(CommonHelper.formatVars(server.config.launch4j.internalName));
|
||||
info.setInternalName(formatVars(server.config.launch4j.internalName));
|
||||
// Prepare version info (file)
|
||||
info.setTxtFileVersion(CommonHelper.formatVars(server.config.launch4j.txtFileVersion));
|
||||
info.setTxtProductVersion(CommonHelper.formatVars(server.config.launch4j.txtProductVersion));
|
||||
info.setTxtFileVersion(formatVars(server.config.launch4j.txtFileVersion));
|
||||
info.setTxtProductVersion(formatVars(server.config.launch4j.txtProductVersion));
|
||||
// Prepare version info (misc)
|
||||
info.setOriginalFilename(binaryFile.getFileName().toString());
|
||||
info.setLanguage(LanguageID.RUSSIAN);
|
||||
|
@ -113,4 +114,10 @@ private void setConfig() {
|
|||
// Return prepared config
|
||||
ConfigPersister.getInstance().setAntConfig(config, null);
|
||||
}
|
||||
private static String VERSION = LauncherVersion.getVersion().getVersionString();
|
||||
private static int BUILD = LauncherVersion.getVersion().build;
|
||||
public static String formatVars(String mask)
|
||||
{
|
||||
return String.format(mask, VERSION, BUILD);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,8 +63,8 @@ launch4J: {
|
|||
copyright: "© sashok724 LLC";
|
||||
trademarks: "This product is licensed under MIT License";
|
||||
# version and build number
|
||||
txtFileVersion: "%VERSION%, build %BUILDNUMBER%";
|
||||
txtProductVersion: "%VERSION%, build %BUILDNUMBER%";
|
||||
txtFileVersion: "%s, build %d";
|
||||
txtProductVersion: "%s, build %d";
|
||||
};
|
||||
|
||||
# Compress files when updating using Inflate algorithm
|
||||
|
|
|
@ -12,20 +12,11 @@
|
|||
import ru.gravit.launcher.LauncherVersion;
|
||||
|
||||
public final class CommonHelper {
|
||||
@LauncherAPI
|
||||
public static final String VERSIONREPLACE = "VERSION";
|
||||
@LauncherAPI
|
||||
public static final String BUILDREPLACE = "BUILDNUMBER";
|
||||
@LauncherAPI
|
||||
public static final ScriptEngineManager scriptManager = new ScriptEngineManager();
|
||||
@LauncherAPI
|
||||
public static final ScriptEngineFactory nashornFactory = getEngineFactories(scriptManager);
|
||||
|
||||
@LauncherAPI
|
||||
public static String formatVars(String in) {
|
||||
return replace(in, VERSIONREPLACE , LauncherVersion.getVersion().getVersionString(), BUILDREPLACE, Integer.toString(LauncherVersion.BUILD));
|
||||
}
|
||||
|
||||
private static ScriptEngineFactory getEngineFactories(ScriptEngineManager manager) {
|
||||
// Метод похож на костыль но таковым не является, ибо единоразовое получение фактории быстрее, чем её переполучение на ходу.
|
||||
for (ScriptEngineFactory fact : manager.getEngineFactories())
|
||||
|
|
Loading…
Reference in a new issue