openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mprud...@apache.org
Subject svn commit: r433850 - in /incubator/openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAVersion.java pom.xml
Date Wed, 23 Aug 2006 02:43:03 GMT
Author: mprudhom
Date: Tue Aug 22 19:43:02 2006
New Revision: 433850

URL: http://svn.apache.org/viewvc?rev=433850&view=rev
Log:
Added generation of a /META-INF/revision.properties file that will hold the current subversion
revision that was used when creating the jars; also made org.apache.openjpa.conf.OpenJPAVersion
output this information when it is found

Modified:
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAVersion.java
    incubator/openjpa/trunk/pom.xml

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAVersion.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAVersion.java?rev=433850&r1=433849&r2=433850&view=diff
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAVersion.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAVersion.java
Tue Aug 22 19:43:02 2006
@@ -16,7 +16,9 @@
 package org.apache.openjpa.conf;
 
 import java.io.File;
+import java.io.InputStream;
 import java.util.Date;
+import java.util.Properties;
 import java.util.StringTokenizer;
 
 /**
@@ -39,6 +41,7 @@
     public static final int MINOR_RELEASE;
     public static final int PATCH_RELEASE;
     public static final String RELEASE_STATUS;
+    public static final int REVISION_NUMBER;
 
     static {
         Package pack = OpenJPAVersion.class.getPackage();
@@ -47,7 +50,6 @@
             vers = "0.0.0";
 
         VERSION_NUMBER = vers;
-        VERSION_ID = VERSION_NUMBER;
 
         StringTokenizer tok = new StringTokenizer(VERSION_NUMBER, ".-");
 
@@ -71,10 +73,29 @@
             patch = 0;
         }
 
+        int revision = 0;
+        try {
+            InputStream in = OpenJPAVersion.class.
+                getResourceAsStream("/META-INF/revision.properties");
+            if (in != null) {
+                try {
+                    Properties props = new Properties();
+                    props.load(in);
+                    revision = Integer.parseInt
+                        (props.getProperty("revision.number"));
+                } finally {
+                    in.close();
+                }
+            }
+        } catch (Exception e) {
+        }
+
         MAJOR_RELEASE = major;
         MINOR_RELEASE = minor;
         PATCH_RELEASE = patch;
         RELEASE_STATUS = tok.hasMoreTokens() ? tok.nextToken("!") : "";
+        REVISION_NUMBER = revision;
+        VERSION_ID = VERSION_NUMBER + "-r" + REVISION_NUMBER;
     }
 
     public static void main(String [] args) {
@@ -83,10 +104,12 @@
 
     public String toString() {
         StringBuffer buf = new StringBuffer(80 * 30);
-        buf.append("OpenJPA");
+        buf.append("OpenJPA ");
         buf.append(VERSION_NUMBER);
         buf.append("\n");
         buf.append("version id: ").append(VERSION_ID);
+        buf.append("\n");
+        buf.append("revision: ").append(REVISION_NUMBER);
         buf.append("\n\n");
 
         getProperty("os.name", buf).append("\n");

Modified: incubator/openjpa/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/pom.xml?rev=433850&r1=433849&r2=433850&view=diff
==============================================================================
--- incubator/openjpa/trunk/pom.xml (original)
+++ incubator/openjpa/trunk/pom.xml Tue Aug 22 19:43:02 2006
@@ -161,23 +161,35 @@
             </plugin>
             <!--
                 get the svn revision number and set it in the
-                project.revision setting - disabled for now
+                subversion.revision setting - disabled for now
                 since we need to be able to build from sources
                 zip (when there is no .svn/ metadata)
             -->
-            <!--
             <plugin>
                 <artifactId>maven-antrun-plugin</artifactId>
                 <executions>
                     <execution>
-                        <phase>compile</phase>
+                        <id>set subversion revision</id>
+                        <phase>package</phase>
                         <configuration>
                             <tasks>
+                                <property name="tmpdir"
+                                    value="${java.io.tmpdir}/openjpamvntmp"/>
+                                <condition property="outdir"
+                                    value="${project.build.outputDirectory}">
+                                    <available type="dir"
+                                    file="${project.build.outputDirectory}"/>
+                                </condition>
+
+                                <property name="outdir" value="${tmpdir}"/>
+
                                 <xmlproperty file="${basedir}/.svn/entries"
                                     collapseAttributes="true"/>
-                                <property name="project.revision"
+                                <property name="subversion.revision"
                                     value="${wc-entries.entry.revision}"/>
-                                <echo>Revision: ${project.revision}</echo>
+                                <mkdir dir="${outdir}/META-INF"/>
+                                <echo file="${outdir}/META-INF/revision.properties">revision.number=${subversion.revision}</echo>
+                                <delete dir="${tmpdir}"/>
                             </tasks>
                         </configuration>
                         <goals>
@@ -186,7 +198,6 @@
                     </execution>
                 </executions>
             </plugin>
-            -->
         </plugins>
     </build>
     <reporting>



Mime
View raw message