[verion] Update version ID whenever the system is built
authorAsier Lostalé <asier.lostale@openbravo.com>
Mon, 06 Jul 2009 13:09:53 +0200
changeset 4277 cf3dac4adfe7
parent 4276 861ca54f4e79
child 4278 08f71f5da899
[verion] Update version ID whenever the system is built
build.xml
src/build.xml
--- a/build.xml	Mon Jul 06 11:49:23 2009 +0200
+++ b/build.xml	Mon Jul 06 13:09:53 2009 +0200
@@ -201,7 +201,7 @@
 
   <taskdef resource="axis-tasks.properties" classpathref="project.class.path" />
 
-  <target name="init">
+  <target name="init" depends="code.rev">
     <fail if="no.java.home" message="The environment variable JAVA_HOME is not set." />
   </target>
 
--- a/src/build.xml	Mon Jul 06 11:49:23 2009 +0200
+++ b/src/build.xml	Mon Jul 06 13:09:53 2009 +0200
@@ -284,7 +284,42 @@
     <javac srcdir="${build.AD}" destdir="${build}" encoding="UTF-8" fork="true" memorymaximumsize="${build.maxmemory}" debug="true" debuglevel="lines,vars,source" deprecation="on">
       <classpath refid="project.class.path" />
     </javac>
+  	<antcall target="calculate.version"/>
   </target>
+	
+	<target name="calculate.version" depends="init">
+	  <condition property="revision.from.file">
+		<and>
+		  <not>
+		 	<isset property="hg.id"/>
+		  </not>
+		  <available file="${basedir}/config/instance.revision"/>
+	    </and>
+	  </condition>
+	  <antcall inheritall="true" target="calculate.instance.version"/>
+	</target>
+	<target name="calculate.instance.version" depends="calculate.version.from.hg, calculate.version.from.file">
+		<echo message="Instance version: ${instance.version}"/>
+	    <sql driver="${bbdd.driver}" url="${bbdd.owner.url}" userid="${bbdd.user}" password="${bbdd.password}" delimiter="/">
+	      <classpath>
+	        <fileset dir="${base.lib}">
+	          <include name="**/*.jar">
+	          </include>
+	        </fileset>
+	      </classpath>
+	      <transaction>
+		        UPDATE AD_MODULE 
+	      	       SET VERSION_ID='${instance.version}'
+                 WHERE AD_MODULE_ID='0'
+		      </transaction>
+	    </sql>
+	</target>
+	<target name="calculate.version.from.hg" if="is.hg">
+	  <property name="instance.version" value="${hg.id}"/>
+	</target>
+	<target name="calculate.version.from.file" if="revision.from.file">
+		<loadfile property="instance.version" srcfile="${basedir}/config/instance.revision"/>
+	</target>
 
   <target name="compile.src.gen" depends="init">
     <javac srcdir="${basedir}" includes="org/openbravo/base/exception/**,org/openbravo/base/gen/**,org/openbravo/base/expression/**,org/openbravo/base/provider/**,org/openbravo/base/model/**,org/openbravo/base/session/**,org/openbravo/base/validation/**,org/openbravo/base/util/**" destdir="${build}" encoding="UTF-8" fork="true" memorymaximumsize="${build.maxmemory}" debug="true" debuglevel="lines,vars,source" deprecation="on">