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

ca.ibodrov.mica.its.Version Maven / Gradle / Ivy

There is a newer version: 0.0.22
Show newest version
package ca.ibodrov.mica.its;

import java.io.IOException;
import java.util.Properties;

import static java.util.Objects.requireNonNull;

public class Version {

    private final String mavenProjectVersion;
    private final String gitCommitId;

    public Version() {
        var projectProperties = loadProperties("/ca/ibodrov/mica/its/version.properties");
        this.mavenProjectVersion = requireNonNull(projectProperties.getProperty("project.version"));

        var gitProperties = loadProperties("/ca/ibodrov/mica/its/git.properties");
        this.gitCommitId = requireNonNull(gitProperties.getProperty("git.commit.id"));
    }

    public String getMavenProjectVersion() {
        return mavenProjectVersion;
    }

    public String getGitCommitId() {
        return gitCommitId;
    }

    private static Properties loadProperties(String path) {
        var props = new Properties();
        try {
            props.load(Version.class.getResourceAsStream(path));
            return props;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy