*** empty log message ***
[IRC.git] / Robust / Transactions / jcarderdstm2version / src / com / enea / jcarder / util / BuildInformation.java
diff --git a/Robust/Transactions/jcarderdstm2version/src/com/enea/jcarder/util/BuildInformation.java b/Robust/Transactions/jcarderdstm2version/src/com/enea/jcarder/util/BuildInformation.java
new file mode 100644 (file)
index 0000000..a3494a8
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * JCarder -- cards Java programs to keep threads disentangled
+ *
+ * Copyright (C) 2006-2007 Enea AB
+ * Copyright (C) 2007 Ulrik Svensson
+ * Copyright (C) 2007 Joel Rosdahl
+ *
+ * This program is made available under the GNU GPL version 2, with a special
+ * exception for linking with JUnit. See the accompanying file LICENSE.txt for
+ * details.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+package com.enea.jcarder.util;
+
+import java.io.IOException;
+import java.util.Properties;
+
+public final class BuildInformation {
+
+    private BuildInformation() { }
+
+    public static String getShortInfo() {
+        try {
+            Properties props = loadBuildProperties();
+            return "JCarder ("
+                   + props.getProperty("build.version")
+                   + "/"
+                   + props.getProperty("build.number")
+                   + ")";
+        } catch (IOException e) {
+            e.printStackTrace();
+            return "JCarder";
+        }
+    }
+
+    public static void printLongBuildInformation() {
+        Properties props;
+        try {
+            props = loadBuildProperties();
+        } catch (IOException e) {
+            e.printStackTrace();
+            return;
+        }
+        StringBuffer sb = new StringBuffer();
+        sb.append("JCarder -- cards Java programs to keep threads"
+                  + " disentangled\n");
+        sb.append("\nCopyright (C) 2006-2007 Enea AB\n");
+        sb.append("Copyright (C) 2007 Ulrik Svensson\n");
+        sb.append("Copyright (C) 2007 Joel Rosdahl\n");
+        sb.append("\nVersion: " + props.getProperty("build.version"));
+        sb.append("\nBuild  : " + props.getProperty("build.number"));
+        sb.append("\nAt     : " + props.getProperty("build.timestamp"));
+        sb.append("\nBy     : " + props.getProperty("build.user.name"));
+        sb.append("\nOn     : " + props.getProperty("build.os.name"));
+        System.out.println(sb.toString());
+    }
+
+    private static Properties loadBuildProperties() throws IOException {
+        Properties props = new Properties();
+        ClassLoader classLoader = ClassLoader.getSystemClassLoader();
+        props.load(classLoader.getResourceAsStream("build.properties"));
+       // return null;
+        return props;
+    }
+}