[version] Enable not calculated revision number for core obx files
authorAsier Lostalé <asier.lostale@openbravo.com>
Mon, 06 Jul 2009 15:01:12 +0200
changeset 4279 959b1cd36773
parent 4278 08f71f5da899
child 4280 a2f6c1f8d4fb
[version] Enable not calculated revision number for core obx files
build.xml
src/org/openbravo/erpCommon/utility/CalculateCoreRevision.java
--- a/build.xml	Mon Jul 06 14:08:41 2009 +0200
+++ b/build.xml	Mon Jul 06 15:01:12 2009 +0200
@@ -103,12 +103,20 @@
   <property name="force" value="false" />
   <property name="local" value="true" />
   <property name="apply.modules.complete.compilation" value="false" />
+  <property name="calculate.core.revision" value="true"/>
 
 
   
   <available file=".hg" property="is.hg" />
 
-
+  <condition property="calculate.core.rev">
+   <istrue value="${calculate.core.revision}"/>
+  </condition>
+  
+  <condition property="xml.core.rev">
+     <isfalse value="${calculate.core.revision}"/>
+  </condition>
+  
   <condition property="deploy.mode" value="class">
     <not>
       <isset property="${deploy.mode}" />
@@ -845,18 +853,7 @@
     <chmod file="config/setup-properties-${osname}${osarch}.${bin.ext}" perm="+x" />
   </target>
 
-  <target name="package.core">
-    <exec executable="hg" outputproperty="hg.idno" failifexecutionfails="false">
-      <arg value="id"/>
-      <arg value="-n"/>
-    </exec>
-    
-    <taskdef name="CoreRevision" classname="org.openbravo.erpCommon.utility.CalculateCoreRevision">
-        <classpath refid="project.class.path" />
-      </taskdef>
-
-    <CoreRevision hgRevNo="${hg.idno}" revision="core.rev"/>
-    
+  <target name="package.core" depends="set.version.number">
 	<property name="tmpdir" value="${java.io.tmpdir}/ob.core${core.rev}" />
    
   	<exec executable="hg" >
@@ -865,13 +862,42 @@
   	</exec>
   	
   	<replaceregexp file="${tmpdir}/src-db/database/sourcedata/AD_MODULE.xml"
-                   match="(VERSION.*\[CDATA\[.*\..*\.)(.*)(\]\])"
+                   match="(VERSION.*\[CDATA\[).*\..*\.(.*)(\]\])"
                    replace="\1${core.rev}\3"
                    byline="true"/>
     
-    <zip destfile="${basedir}/core-2.50.${core.rev}.obx" basedir="${tmpdir}"/>
+    <zip destfile="${basedir}/core-${core.rev}.obx" basedir="${tmpdir}"/>
     
     <delete dir="${tmpdir}"/>
 
    </target>
+ 
+  <target name="set.version.number" depends="set.version.from.file, set.version.calculated"/>
+  
+  <target name="set.version.calculated" if="calculate.core.rev">
+    <echo message="calculating core revision..."/>
+    <exec executable="hg" outputproperty="hg.idno" failifexecutionfails="false">
+      <arg value="id"/>
+      <arg value="-n"/>
+    </exec>
+    <taskdef name="CoreRevision" classname="org.openbravo.erpCommon.utility.CalculateCoreRevision">
+            <classpath refid="project.class.path" />
+          </taskdef>
+
+    <CoreRevision hgRevNo="${hg.idno}" revision="core.rev"/>
+  </target>
+  
+  <target name="set.version.from.file" if="xml.core.rev">
+    <echo message="reading core revision from xml file..."/>
+    <loadfile property="core.rev" srcfile="${basedir}/src-db/database/sourcedata/AD_MODULE.xml">
+      <filterchain>
+        <linecontains>
+          <contains value="VERSION>"/>
+        </linecontains>
+        <tokenfilter>
+            <replaceregex pattern="(.*VERSION.*\[CDATA\[)(.*\..*\..*)(\]\].*)" replace="\2"/>
+        </tokenfilter>
+      </filterchain>
+    </loadfile>
+  </target>
 </project>
--- a/src/org/openbravo/erpCommon/utility/CalculateCoreRevision.java	Mon Jul 06 14:08:41 2009 +0200
+++ b/src/org/openbravo/erpCommon/utility/CalculateCoreRevision.java	Mon Jul 06 15:01:12 2009 +0200
@@ -22,6 +22,13 @@
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Task;
 
+/**
+ * Calculates the version number for core.
+ * 
+ * It is used when extracting obx for core
+ * 
+ * 
+ */
 public class CalculateCoreRevision extends Task {
   private String revision;
   private String hgRevNo;
@@ -33,7 +40,7 @@
 
     Integer revNo = new Integer(hgRevNo);
     revNo += 10000;
-    getProject().setProperty(revision, revNo.toString());
+    getProject().setProperty(revision, "2.50." + revNo.toString());
   }
 
   public String getRevision() {