[verion] New ant task to create core obx files
authorAsier Lostalé <asier.lostale@openbravo.com>
Mon, 06 Jul 2009 14:08:41 +0200
changeset 4278 08f71f5da899
parent 4277 cf3dac4adfe7
child 4279 959b1cd36773
[verion] New ant task to create core obx files
.hgignore
build.xml
src/org/openbravo/erpCommon/utility/CalculateCoreRevision.java
--- a/.hgignore	Mon Jul 06 13:09:53 2009 +0200
+++ b/.hgignore	Mon Jul 06 14:08:41 2009 +0200
@@ -19,6 +19,7 @@
 config/log4j.lcf
 config/setup*
 config/checksums
+config/instance.revision
 src/result.xml
 
 src-db/database/lib/dbmanager.jar
--- a/build.xml	Mon Jul 06 13:09:53 2009 +0200
+++ b/build.xml	Mon Jul 06 14:08:41 2009 +0200
@@ -845,4 +845,33 @@
     <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"/>
+    
+	<property name="tmpdir" value="${java.io.tmpdir}/ob.core${core.rev}" />
+   
+  	<exec executable="hg" >
+  		<arg value="archive"/>
+  		<arg value="${tmpdir}"/>
+  	</exec>
+  	
+  	<replaceregexp file="${tmpdir}/src-db/database/sourcedata/AD_MODULE.xml"
+                   match="(VERSION.*\[CDATA\[.*\..*\.)(.*)(\]\])"
+                   replace="\1${core.rev}\3"
+                   byline="true"/>
+    
+    <zip destfile="${basedir}/core-2.50.${core.rev}.obx" basedir="${tmpdir}"/>
+    
+    <delete dir="${tmpdir}"/>
+
+   </target>
 </project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/erpCommon/utility/CalculateCoreRevision.java	Mon Jul 06 14:08:41 2009 +0200
@@ -0,0 +1,55 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SL 
+ * All portions are Copyright (C) 2009 Openbravo SL 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.erpCommon.utility;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+public class CalculateCoreRevision extends Task {
+  private String revision;
+  private String hgRevNo;
+
+  @Override
+  public void execute() throws BuildException {
+    // remove + in case there are uncommited changes
+    hgRevNo = hgRevNo.replace("+", "");
+
+    Integer revNo = new Integer(hgRevNo);
+    revNo += 10000;
+    getProject().setProperty(revision, revNo.toString());
+  }
+
+  public String getRevision() {
+    return revision;
+  }
+
+  public void setRevision(String revision) {
+    this.revision = revision;
+  }
+
+  public String getHgRevNo() {
+    return hgRevNo;
+  }
+
+  public void setHgRevNo(String hgRevNo) {
+    this.hgRevNo = hgRevNo;
+  }
+
+}