summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBhupendra Bhusman Bhardwaj <bhupendrab@apache.org>2006-12-21 16:47:01 +0000
committerBhupendra Bhusman Bhardwaj <bhupendrab@apache.org>2006-12-21 16:47:01 +0000
commit2032535eb650a7fddeef04d21b750dc026f43eb8 (patch)
tree6f6d96bef5cb538cf389c16ee5b73f6e0649c64b
parent73e1fc2b9f4cf126b8143714d32c964c76d9161d (diff)
downloadqpid-python-2032535eb650a7fddeef04d21b750dc026f43eb8.tar.gz
QPID-227
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@489403 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/broker/pom.xml5
-rw-r--r--java/client/pom.xml5
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/QpidConnectionMetaData.java5
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java2
-rw-r--r--java/common/src/main/java/org/apache/qpid/common/QpidProperties.java50
-rw-r--r--java/pom.xml47
6 files changed, 104 insertions, 10 deletions
diff --git a/java/broker/pom.xml b/java/broker/pom.xml
index 485fcf896b..92a3d69060 100644
--- a/java/broker/pom.xml
+++ b/java/broker/pom.xml
@@ -86,6 +86,11 @@
<build>
<plugins>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ </plugin>
+
+ <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>javacc-maven-plugin</artifactId>
<version>2.0</version>
diff --git a/java/client/pom.xml b/java/client/pom.xml
index 68e6f30e01..e45aad733d 100644
--- a/java/client/pom.xml
+++ b/java/client/pom.xml
@@ -97,6 +97,11 @@
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
diff --git a/java/client/src/main/java/org/apache/qpid/client/QpidConnectionMetaData.java b/java/client/src/main/java/org/apache/qpid/client/QpidConnectionMetaData.java
index d9e946c397..9ee802ff10 100644
--- a/java/client/src/main/java/org/apache/qpid/client/QpidConnectionMetaData.java
+++ b/java/client/src/main/java/org/apache/qpid/client/QpidConnectionMetaData.java
@@ -22,10 +22,9 @@ package org.apache.qpid.client;
import org.apache.qpid.common.QpidProperties;
-import java.util.Enumeration;
-
import javax.jms.ConnectionMetaData;
import javax.jms.JMSException;
+import java.util.Enumeration;
public class QpidConnectionMetaData implements ConnectionMetaData
{
@@ -90,7 +89,7 @@ public class QpidConnectionMetaData implements ConnectionMetaData
public String getClientVersion()
{
- return QpidProperties.getBuildVerision();
+ return QpidProperties.getBuildVersion();
}
diff --git a/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java b/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java
index f7b0cb5331..cfc3c2898b 100644
--- a/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java
+++ b/java/client/src/main/java/org/apache/qpid/client/handler/ConnectionStartMethodHandler.java
@@ -124,7 +124,7 @@ public class ConnectionStartMethodHandler implements StateAwareMethodListener
clientProperties.put(ClientProperties.instance.toString(), ps.getClientID());
clientProperties.put(ClientProperties.product.toString(), QpidProperties.getProductName());
- clientProperties.put(ClientProperties.version.toString(), QpidProperties.getReleaseVerision());
+ clientProperties.put(ClientProperties.version.toString(), QpidProperties.getReleaseVersion());
clientProperties.put(ClientProperties.platform.toString(), getFullSystemInfo());
ps.writeFrame(ConnectionStartOkBody.createAMQFrame(evt.getChannelId(), clientProperties, mechanism,
saslResponse, selectedLocale));
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 3a96821e93..4b281e9f8d 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,27 +20,65 @@
*/
package org.apache.qpid.common;
+import java.util.Properties;
+import java.io.IOException;
+
public class QpidProperties
{
+ public static final String VERSION_RESOURCE = "version.properties";
+
+ public static final String PRODUCT_NAME_PROPERTY = "qpid.name";
+ public static final String RELEASE_VERSION_PROPERTY = "qpid.version";
+ public static final String BUILD_VERSION_PROPERTY = "qpid.svnversion";
+
+ private static final String DEFAULT = "unknown";
+ private static String productName = DEFAULT;
+ private static String releaseVersion = DEFAULT;
+ private static String buildVersion = DEFAULT;
+
+ /** Loads the values from the version properties file. */
static
{
- //load values from property file.
+ Properties props = new Properties();
+
+ try
+ {
+ props.load(QpidProperties.class.getClassLoader().getResourceAsStream(VERSION_RESOURCE));
+
+ productName = props.getProperty(PRODUCT_NAME_PROPERTY);
+ releaseVersion = props.getProperty(RELEASE_VERSION_PROPERTY);
+ buildVersion = props.getProperty(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.");
+ }
}
public static String getProductName()
{
- return "Qpid";
+ return productName;
}
- public static String getReleaseVerision()
+ public static String getReleaseVersion()
{
- return "1.0";
+ return releaseVersion;
}
+ public static String getBuildVersion()
+ {
+ return buildVersion;
+ }
+
+ public static String getVersionString()
+ {
+ return getProductName() + " - " + getReleaseVersion() + " build: " + getBuildVersion();
+ }
- public static String getBuildVerision()
+ public static void main(String[] args)
{
- return "1";
+ System.out.println(getVersionString());
}
}
diff --git a/java/pom.xml b/java/pom.xml
index 6cd745726f..7a2790ec5c 100644
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -162,6 +162,7 @@
<pluginManagement>
<plugins>
+
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
@@ -174,6 +175,52 @@
</dependency>
</dependencies>
+
+ <executions>
+
+ <!-- This Ant task writes the module name, version and the Subversion version information out to a properties file.
+ The svnversion command must be available to run from the command line for this to work. The build will not fail if
+ svnversion cannot be run though.
+ This is done during the 'compile' phase to reflect the version of the currently compiled code and to ensure that
+ these properties are up to date when running from a file system classpath. Consider moving this to, or running a second
+ 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
+ this plugin.
+ The 'version.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
+ 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
+ from here.
+ -->
+ <execution>
+ <id>version_properties</id>
+ <phase>compile</phase>
+ <configuration>
+ <tasks>
+
+ <exec executable="svnversion" spawn="false" failifexecutionfails="false"
+ dir="${topDirectoryLocation}" outputproperty="svnversion">
+ <arg line="."/>
+ </exec>
+
+ <!-- Write the version.properties out. -->
+ <propertyfile file="target/classes/version.properties">
+ <entry key="qpid.svnversion" value="${svnversion}"/>
+ <entry key="qpid.name" value="${project.name}"/>
+ <entry key="qpid.version" value="${project.version}"/>
+ </propertyfile>
+
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>