[Schmitzm-commits] r1935 - trunk/schmitzm-core/src/main/java/de/schmitzm/versionnumber

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Wed Apr 4 14:35:54 CEST 2012


Author: mojays
Date: 2012-04-04 14:35:54 +0200 (Wed, 04 Apr 2012)
New Revision: 1935

Modified:
   trunk/schmitzm-core/src/main/java/de/schmitzm/versionnumber/ReleaseUtil.java
Log:
ReleaseUtil: new method getIndividualProperty(.) to retrieve non-predefined property from release.properties

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/versionnumber/ReleaseUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/versionnumber/ReleaseUtil.java	2012-04-04 11:09:07 UTC (rev 1934)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/versionnumber/ReleaseUtil.java	2012-04-04 12:35:54 UTC (rev 1935)
@@ -174,6 +174,32 @@
 
 	}
 
+    /**
+     * Returns individual information from release properties file.
+     * @param clazz
+     *            Pass a class that resides in the same "project" or jar, where
+     *            the /release.properties resides as well.
+     */
+    public static String getIndividualProperty(Class<?> clazz, String propKey) {
+      try {
+        final URL releasePropsURL = clazz.getResource("/release.properties");
+        final Properties releaseProps = new Properties();
+        final InputStream openStream = releasePropsURL.openStream();
+        try {
+            releaseProps.load(openStream);
+        } finally {
+            openStream.close();
+        }
+        final String value = releaseProps.getProperty(propKey);
+        return value;
+      } catch (final Exception e) {
+        log.error(
+                "/release.properties could not be read from "
+                    + clazz.getSimpleName(), e);
+        return null;
+      }
+    }
+    
 	/**
 	 * @param clazz
 	 *            Pass a class that resides in the same "project" or jar, where



More information about the Schmitzm-commits mailing list