1 package net.sf.openrocket.util;
\r
3 import java.io.IOException;
\r
4 import java.io.InputStream;
\r
5 import java.util.MissingResourceException;
\r
6 import java.util.Properties;
\r
8 public class BuildProperties {
\r
10 private static final Properties PROPERTIES;
\r
11 private static final String BUILD_VERSION;
\r
12 private static final String BUILD_SOURCE;
\r
13 private static final boolean DEFAULT_CHECK_UPDATES;
\r
16 * Return the OpenRocket version number.
\r
18 public static String getVersion() {
\r
19 return BUILD_VERSION;
\r
23 * Return the OpenRocket build source (e.g. "default" or "Debian")
\r
25 public static String getBuildSource() {
\r
26 return BUILD_SOURCE;
\r
29 public static boolean getDefaultCheckUpdates() {
\r
30 return DEFAULT_CHECK_UPDATES;
\r
35 InputStream is = ClassLoader.getSystemResourceAsStream("build.properties");
\r
37 throw new MissingResourceException(
\r
38 "build.properties not found, distribution built wrong" +
\r
39 " classpath:" + System.getProperty("java.class.path"),
\r
40 "build.properties", "build.version");
\r
43 PROPERTIES = new Properties();
\r
44 PROPERTIES.load(is);
\r
47 String version = PROPERTIES.getProperty("build.version");
\r
48 if (version == null) {
\r
49 throw new MissingResourceException(
\r
50 "build.version not found in property file",
\r
51 "build.properties", "build.version");
\r
53 BUILD_VERSION = version.trim();
\r
55 BUILD_SOURCE = PROPERTIES.getProperty("build.source");
\r
56 if (BUILD_SOURCE == null) {
\r
57 throw new MissingResourceException(
\r
58 "build.source not found in property file",
\r
59 "build.properties", "build.source");
\r
62 String value = PROPERTIES.getProperty("build.checkupdates");
\r
64 DEFAULT_CHECK_UPDATES = Boolean.parseBoolean(value);
\r
66 DEFAULT_CHECK_UPDATES = true;
\r
68 } catch (IOException e) {
\r
69 throw new MissingResourceException(
\r
70 "Error reading build.properties",
\r
71 "build.properties", "build.version");
\r