Last active
January 2, 2016 08:59
-
-
Save mosheeshel/8279903 to your computer and use it in GitHub Desktop.
Get App version from package manifest (for fatJar)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected Integer getBuildNumber() { | |
try { | |
final String version = App.class.getPackage().getImplementationVersion(); | |
if (StringUtils.isNotEmpty(version)) { | |
try { | |
return Integer.parseInt(version.substring(version.lastIndexOf(".") + 1)); | |
} catch (Exception exp) { | |
logger.error("Problem parsing buildnumber from package version, returning 0", exp); | |
} | |
} | |
} catch (Exception exp) { | |
logger.error("Problem Getting version from package, returning 0", exp); | |
} | |
return 0; | |
} | |
protected String getAppVersion() { | |
try { | |
final String version = App.class.getPackage().getImplementationVersion(); | |
if (StringUtils.isNotEmpty(version)) { | |
return version; | |
} | |
} catch (Exception exp) { | |
logger.error("Problem Getting version from package, returning 0", exp); | |
} | |
return "0"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment