public static final String API_CURRENT = "15";\r
\r
public static String getVersion() {\r
- String v = Constants.class.getPackage().getImplementationVersion();\r
- if (v == null) {\r
- return "0.0.0-SNAPSHOT";\r
- }\r
- return v;\r
+ return getManifestValue("implementation-version", "0.0.0-SNAPSHOT");\r
}\r
\r
public static String getBuildDate() {\r
Class<?> clazz = Constants.class;\r
String className = clazz.getSimpleName() + ".class";\r
String classPath = clazz.getResource(className).toString();\r
- if (!classPath.startsWith("jar")) {\r
- // Class not from JAR\r
- return defaultValue;\r
- }\r
try {\r
- String manifestPath = classPath.substring(0, classPath.lastIndexOf("!") + 1) + "/META-INF/MANIFEST.MF";\r
+ String manifestPath;\r
+ if (classPath.indexOf('!') > -1) {\r
+ manifestPath = classPath.substring(0, classPath.lastIndexOf("!") + 1) + "/META-INF/MANIFEST.MF";\r
+ } else {\r
+ String pkgPath = "/" + clazz.getPackage().getName().replace('.', '/');\r
+ manifestPath = classPath.substring(0, classPath.indexOf(pkgPath)) + "/META-INF/MANIFEST.MF";\r
+ }\r
Manifest manifest = new Manifest(new URL(manifestPath).openStream());\r
Attributes attr = manifest.getMainAttributes();\r
String value = attr.getValue(attrib);\r