Skip to content

Instantly share code, notes, and snippets.

@mosheeshel
Last active January 2, 2016 08:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mosheeshel/8279903 to your computer and use it in GitHub Desktop.
Save mosheeshel/8279903 to your computer and use it in GitHub Desktop.
Get App version from package manifest (for fatJar)
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