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

io.hyperfoil.api.Version Maven / Gradle / Ivy

There is a newer version: 0.27
Show newest version
package io.hyperfoil.api;

import java.net.URL;
import java.util.jar.Attributes;
import java.util.jar.Manifest;

import io.vertx.core.logging.LoggerFactory;

public class Version {
   public static final String VERSION;
   public static final String COMMIT_ID;

   static {
      String version = "unknown";
      String commitId = "unknown";
      try {
         String classPath = Version.class.getResource(Version.class.getSimpleName() + ".class").toString();
         if (classPath.startsWith("jar")) {
            String manifestPath = classPath.substring(0, classPath.lastIndexOf("!") + 1) +
                  "/META-INF/MANIFEST.MF";
            Manifest manifest = null;
            manifest = new Manifest(new URL(manifestPath).openStream());
            Attributes attr = manifest.getMainAttributes();
            commitId = attr.getValue("Scm-Revision");
            version = attr.getValue("Implementation-Version");
         }
      } catch (Throwable e) {
         LoggerFactory.getLogger(Version.class).error("Cannot find version info.", e);
      } finally {
         VERSION = version;
         COMMIT_ID = commitId;
      }
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy