aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/iciql/Constants.java40
1 files changed, 33 insertions, 7 deletions
diff --git a/src/main/java/com/iciql/Constants.java b/src/main/java/com/iciql/Constants.java
index ba75de3..6b5d83a 100644
--- a/src/main/java/com/iciql/Constants.java
+++ b/src/main/java/com/iciql/Constants.java
@@ -16,6 +16,10 @@
package com.iciql;
+import java.net.URL;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
/**
* Iciql constants.
*/
@@ -25,14 +29,36 @@ public class Constants {
// The build script extracts this exact line so be careful editing it
// and only use A-Z a-z 0-9 .-_ in the string.
- public static final String VERSION = "1.6.0-SNAPSHOT";
+ public static final String API_CURRENT = "15";
- // The build script extracts this exact line so be careful editing it
- // and only use A-Z a-z 0-9 .-_ in the string.
- public static final String VERSION_DATE = "PENDING";
+ public static String getVersion() {
+ String v = Constants.class.getPackage().getImplementationVersion();
+ if (v == null) {
+ return "0.0.0-SNAPSHOT";
+ }
+ return v;
+ }
- // The build script extracts this exact line so be careful editing it
- // and only use A-Z a-z 0-9 .-_ in the string.
- public static final String API_CURRENT = "15";
+ public static String getBuildDate() {
+ return getManifestValue("build-date", "PENDING");
+ }
+ private static String getManifestValue(String attrib, String defaultValue) {
+ Class<?> clazz = Constants.class;
+ String className = clazz.getSimpleName() + ".class";
+ String classPath = clazz.getResource(className).toString();
+ if (!classPath.startsWith("jar")) {
+ // Class not from JAR
+ return defaultValue;
+ }
+ try {
+ String manifestPath = classPath.substring(0, classPath.lastIndexOf("!") + 1) + "/META-INF/MANIFEST.MF";
+ Manifest manifest = new Manifest(new URL(manifestPath).openStream());
+ Attributes attr = manifest.getMainAttributes();
+ String value = attr.getValue(attrib);
+ return value;
+ } catch (Exception e) {
+ }
+ return defaultValue;
+ }
}