diff --git a/build.gradle b/build.gradle index f18e7bd..f7fcd8b 100644 --- a/build.gradle +++ b/build.gradle @@ -23,6 +23,19 @@ run { standardInput = System.in } +def getVersionName= { -> + def stdout = new ByteArrayOutputStream() + exec { + commandLine 'git', 'describe', '--tags', '--dirty' + standardOutput = stdout + } + return stdout.toString().trim() +} + +ant.propertyfile(file: "$project.rootDir/build/resources/main/build.properties") { + entry(key: "version", value: getVersionName()) +} + jar { manifest { attributes "Main-Class": "$mainClassName" diff --git a/src/main/java/de/fabianonline/telegram_backup/Config.java b/src/main/java/de/fabianonline/telegram_backup/Config.java index 7714d42..ea7da10 100644 --- a/src/main/java/de/fabianonline/telegram_backup/Config.java +++ b/src/main/java/de/fabianonline/telegram_backup/Config.java @@ -17,13 +17,16 @@ package de.fabianonline.telegram_backup; import java.io.File; +import java.io.IOException; +import java.io.FileInputStream; +import java.util.Properties; public class Config { public static final int APP_ID = 32860; public static final String APP_HASH = "16e4ff955cd0adfc058f95ca564f562d"; public static final String APP_MODEL = "Desktop"; public static final String APP_SYSVER = "1.0"; - public static final String APP_APPVER = "1.0.3"; + public static final String APP_APPVER; public static final String APP_LANG = "en"; public static String FILE_BASE = System.getProperty("user.home") + File.separatorChar + ".telegram_backup"; @@ -44,5 +47,15 @@ public class Config { public static int DELAY_AFTER_GET_FILE = 1000; public static final String SECRET_GMAPS = "AIzaSyBEtUDhCQKEH6i2Mn1GAiQ9M_tLN0vxHIs"; + + static { + Properties p = new Properties(); + try { + p.load(Config.class.getResourceAsStream("/build.properties")); + APP_APPVER = p.getProperty("version"); + } catch (IOException e) { + throw new RuntimeException(e); + } + } }