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

fr.opensagres.xdocreport.core.Platform Maven / Gradle / Ivy

package fr.opensagres.xdocreport.core;

import java.io.InputStream;
import java.util.Properties;

public abstract class Platform {

	private static String version;
	public static String getVersion() {
		if (version != null) {
	        return version;
	    }

	    // try to load from maven properties first
	    try {
	        Properties p = new Properties();
	        InputStream is = ClassLoader.getSystemResourceAsStream("META-INF/maven/fr.opensagres.xdocreport/fr.opensagres.xdocreport.core/pom.properties");
	        if (is != null) {
	            p.load(is);
	            version = p.getProperty("version", "");
	        }
	    } catch (Exception e) {
	        // ignore
	    }

	    // fallback to using Java API
	    if (version == null) {
	        Package aPackage = Platform.class.getPackage();
	        if (aPackage != null) {
	            version = aPackage.getImplementationVersion();
	            if (version == null) {
	                version = aPackage.getSpecificationVersion();
	            }
	        }
	    }

	    if (version == null) {
	        // we could not compute the version so use a blank
	        version = "not found";
	    }

	    return version;
	} 

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy