\r
package com.iciql;\r
\r
+import java.net.URL;\r
+import java.util.jar.Attributes;\r
+import java.util.jar.Manifest;\r
+\r
/**\r
* Iciql constants.\r
*/\r
\r
// The build script extracts this exact line so be careful editing it\r
// and only use A-Z a-z 0-9 .-_ in the string.\r
- public static final String VERSION = "1.6.0-SNAPSHOT";\r
+ public static final String API_CURRENT = "15";\r
\r
- // The build script extracts this exact line so be careful editing it\r
- // and only use A-Z a-z 0-9 .-_ in the string.\r
- public static final String VERSION_DATE = "PENDING";\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
+ }\r
\r
- // The build script extracts this exact line so be careful editing it\r
- // and only use A-Z a-z 0-9 .-_ in the string.\r
- public static final String API_CURRENT = "15";\r
+ public static String getBuildDate() {\r
+ return getManifestValue("build-date", "PENDING");\r
+ }\r
\r
+ private static String getManifestValue(String attrib, String defaultValue) {\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
+ Manifest manifest = new Manifest(new URL(manifestPath).openStream());\r
+ Attributes attr = manifest.getMainAttributes();\r
+ String value = attr.getValue(attrib);\r
+ return value;\r
+ } catch (Exception e) {\r
+ }\r
+ return defaultValue;\r
+ }\r
}\r
// Header\r
out.println(dividerMajor);\r
out.println(MessageFormat.format("{0} {1} ({2}) testing {3} database configurations", Constants.NAME,\r
- Constants.VERSION, Constants.VERSION_DATE, TEST_DBS.length));\r
+ Constants.getVersion(), Constants.getBuildDate(), TEST_DBS.length));\r
out.println(dividerMajor);\r
out.println();\r
\r
out.println();\r
out.println(dividerMajor);\r
out.println(MessageFormat.format("{0} {1} ({2}) test suite performance results", Constants.NAME,\r
- Constants.VERSION, Constants.VERSION_DATE));\r
+ Constants.getVersion(), Constants.getBuildDate()));\r
\r
StringBuilder compressedSystem = new StringBuilder();\r
compressedSystem.append(" on ");\r
}\r
\r
private static void usage(JCommander jc, ParameterException t) {\r
- System.out.println(Constants.NAME + " test suite v" + Constants.VERSION);\r
+ System.out.println(Constants.NAME + " test suite v" + Constants.getVersion());\r
System.out.println();\r
if (t != null) {\r
System.out.println(t.getMessage());\r