summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/common/src/main/java/org/apache/qpid/common/QpidProperties.java46
-rw-r--r--java/pom.xml8
2 files changed, 44 insertions, 10 deletions
diff --git a/java/common/src/main/java/org/apache/qpid/common/QpidProperties.java b/java/common/src/main/java/org/apache/qpid/common/QpidProperties.java
index 4b281e9f8d..f4f764db1b 100644
--- a/java/common/src/main/java/org/apache/qpid/common/QpidProperties.java
+++ b/java/common/src/main/java/org/apache/qpid/common/QpidProperties.java
@@ -20,12 +20,18 @@
*/
package org.apache.qpid.common;
+import org.apache.log4j.Logger;
+
import java.util.Properties;
+import java.util.Map;
import java.io.IOException;
+import java.io.InputStream;
public class QpidProperties
{
- public static final String VERSION_RESOURCE = "version.properties";
+ private static final Logger _logger = Logger.getLogger(QpidProperties.class);
+
+ public static final String VERSION_RESOURCE = "qpidversion.properties";
public static final String PRODUCT_NAME_PROPERTY = "qpid.name";
public static final String RELEASE_VERSION_PROPERTY = "qpid.version";
@@ -44,16 +50,34 @@ public class QpidProperties
try
{
- props.load(QpidProperties.class.getClassLoader().getResourceAsStream(VERSION_RESOURCE));
+ InputStream propertyStream = QpidProperties.class.getClassLoader().getResourceAsStream(VERSION_RESOURCE);
+ if (propertyStream == null)
+ {
+ _logger.warn("Unable to find resource " + VERSION_RESOURCE + " from classloader");
+ }
+ else
+ {
+ props.load(propertyStream);
+
+ if (_logger.isDebugEnabled())
+ {
+ _logger.debug("Dumping QpidProperties");
+ for (Map.Entry<Object,Object> entry : props.entrySet())
+ {
+ _logger.debug("Property: " + entry.getKey() + " Value: "+ entry.getValue());
+ }
+ _logger.debug("End of property dump");
+ }
- productName = props.getProperty(PRODUCT_NAME_PROPERTY);
- releaseVersion = props.getProperty(RELEASE_VERSION_PROPERTY);
- buildVersion = props.getProperty(BUILD_VERSION_PROPERTY);
+ productName = readPropertyValue(props, PRODUCT_NAME_PROPERTY);
+ releaseVersion = readPropertyValue(props, RELEASE_VERSION_PROPERTY);
+ buildVersion = readPropertyValue(props, BUILD_VERSION_PROPERTY);
+ }
}
catch (IOException e)
{
// Log a warning about this and leave the values initialized to unknown.
- System.err.println("Could not load version.properties resource.");
+ _logger.error("Could not load version.properties resource: " + e, e);
}
}
@@ -77,6 +101,16 @@ public class QpidProperties
return getProductName() + " - " + getReleaseVersion() + " build: " + getBuildVersion();
}
+ private static String readPropertyValue(Properties props, String propertyName)
+ {
+ String retVal = (String) props.get(propertyName);
+ if (retVal == null)
+ {
+ retVal = DEFAULT;
+ }
+ return retVal;
+ }
+
public static void main(String[] args)
{
System.out.println(getVersionString());
diff --git a/java/pom.xml b/java/pom.xml
index 7a2790ec5c..dd63bbb100 100644
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -186,11 +186,11 @@
time, during the 'package' phase to capture the version of any resources added to jar files.
This svnversion command is always run in the top directory to accurately reflect the svnversion range accross all modules
at the time of the build.
- The properties are placed into a file 'version.properties' in the target/classes directory of any child module that runs
+ The properties are placed into a file 'qpidversion.properties' in the target/classes directory of any child module that runs
this plugin.
- The 'version.properties' file is loaded by the org.apache.qpid.common.QpidProperties class.
+ The 'qpidversion.properties' file is loaded by the org.apache.qpid.common.QpidProperties class.
Be carefull of the possibility that the 'common' module may run this antrun plugin and recieve its own set of
- version.properties and then the client or broker being built against an older version of the common library ending up with
+ qpidversion.properties and then the client or broker being built against an older version of the common library ending up with
the wrong version information. This is unlikely to happen because the client or broker should pick up its own properties
from the classpath first. If this happens it will be obvious because the productName property will be
'Qpid Common Utilities'. If this is a problem then push this ant task down into the client and broker poms and remove it
@@ -208,7 +208,7 @@
</exec>
<!-- Write the version.properties out. -->
- <propertyfile file="target/classes/version.properties">
+ <propertyfile file="target/classes/qpidversion.properties">
<entry key="qpid.svnversion" value="${svnversion}"/>
<entry key="qpid.name" value="${project.name}"/>
<entry key="qpid.version" value="${project.version}"/>