org.bidib.wizard.api.version.ApiVersion Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bidibwizard-api Show documentation
Show all versions of bidibwizard-api Show documentation
jBiDiB BiDiB Wizard API POM
package org.bidib.wizard.api.version;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class ApiVersion {
private static final Logger LOGGER = LoggerFactory.getLogger(ApiVersion.class);
public static String getVersion() {
// Implementation-Version: 2.0-SNAPSHOT (3473, refactoring-servo)
String versionInfo =
StringUtils.defaultString(ApiVersion.class.getPackage().getImplementationVersion(), "(3646, development)");
LOGGER.info("Get the system info, versionInfo: {}", versionInfo);
return versionInfo;
}
public static String getBuildNumber() {
String versionNumber = "0";
try {
String versionInfo = getVersion();
LOGGER.info("Parse the system info, versionInfo: {}", versionInfo);
// Implementation-Version: 2.0-SNAPSHOT (3473, refactoring-servo)
Pattern p = Pattern.compile("\\((\\d+),");
Matcher m = p.matcher(versionInfo);
if (m.find()) {
versionNumber = m.group(1);
}
LOGGER.info("Current version: {}, versionNumber: {}", versionInfo, versionNumber);
}
catch (Exception ex) {
LOGGER.warn("Extract version number from version info failed.", ex);
}
return versionNumber;
}
}