List of usage examples for java.lang Package getSpecificationVersion
public String getSpecificationVersion()
From source file:org.opoo.press.impl.ConfigImpl.java
public static Map<String, Object> defaultOpooPressOptions() { Map<String, Object> options = new HashMap<String, Object>(); Package pkg = ConfigImpl.class.getPackage(); String version = pkg != null ? pkg.getSpecificationVersion() : null; if (StringUtils.isBlank(version)) { version = "unkown_version"; }//from www.ja v a2s. com options.put("version", version); options.put("name", "OpooPress"); return options; }
From source file:org.rhq.enterprise.gui.common.framework.ServerInfoUIBean.java
private String getManifestVersion(Class clazz) { String version = null;//from w w w . j av a2s . c o m try { Package pkg = clazz.getPackage(); if (pkg != null) { version = pkg.getImplementationVersion(); if (version == null) { version = pkg.getSpecificationVersion(); } } } catch (Exception e) { log.error("Error while looking up manifest version for " + clazz + ".", e); } return version; }
From source file:org.trimou.engine.MustacheEngineBuilder.java
/** * Builds the engine instance./*from w w w.j a v a 2s .co m*/ * * @return the built engine */ public MustacheEngine build() { registerBuiltinHelpersIfNecessary(); MustacheEngine engine = new DefaultMustacheEngine(this); for (EngineBuiltCallback callback : engineReadyCallbacks) { callback.engineBuilt(engine); } String version = null; String timestamp = null; // First try to get trimou-build.properties file InputStream in = MustacheEngineBuilder.class.getResourceAsStream(BUILD_PROPERTIES_FILE); try { if (in != null) { try { Properties buildProperties = new Properties(); buildProperties.load(in); version = buildProperties.getProperty("version"); timestamp = buildProperties.getProperty("timestamp"); } finally { in.close(); } } } catch (IOException e) { // No-op } if (version == null) { // If not available use the manifest info Package pack = MustacheEngineBuilder.class.getPackage(); version = pack.getSpecificationVersion(); timestamp = pack.getImplementationVersion(); } if (StringUtils.isEmpty(version)) { version = "SNAPSHOT"; timestamp = "n/a"; } int idx = timestamp.indexOf('T'); if (idx > 0) { timestamp = timestamp.substring(0, idx); } logger.info("Engine built {} ({})", version, timestamp); logger.debug("Engine configuration: " + engine.getConfiguration().getInfo()); isBuilt = true; return engine; }
From source file:org.ut.biolab.medsavant.shared.util.VersionSettings.java
public static String getVersionString() { String version = UNDEFINED_VERSION; Package aPackage = VersionSettings.class.getPackage(); if (aPackage != null) { version = aPackage.getImplementationVersion(); if (version == null) { version = aPackage.getSpecificationVersion(); }//from w ww. jav a2 s . com } if (version == null) { version = UNDEFINED_VERSION; } //Allow version to be overridden from command line. return System.getProperty("medsavant.version", version); }
From source file:ubicrypt.UbiCrypt.java
public static String getVersion() { String version = null;//from w ww . j a v a2 s .c om // try to load from maven properties first try { try (final InputStream is = UbiCrypt.class.getResourceAsStream("META-INF/MANIFEST.MF")) { if (is != null) { Manifest manifest = new Manifest(is); version = manifest.getMainAttributes().getValue("Implementation-Version"); } } } catch (final Exception e) { // ignore } // fallback to using Java API if (version == null) { final Package aPackage = UbiCrypt.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 = ""; } return version; }