All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bidib.wizard.api.version.ApiVersion Maven / Gradle / Ivy

There is a newer version: 2.0.25
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy