[quickbuild] Use md5 to check if compile.complete is needed
authorAsier Lostalé <asier.lostale@openbravo.com>
Fri, 30 Jan 2009 11:57:02 +0000
changeset 2853 7f843a980871
parent 2852 727669f2e657
child 2854 941a30f00659
[quickbuild] Use md5 to check if compile.complete is needed
build.xml
src-core/src/org/openbravo/checksum/CheckSum.java
src-core/src/org/openbravo/utils/CheckSum.java
src/build.xml
--- a/build.xml	Fri Jan 30 11:39:36 2009 +0000
+++ b/build.xml	Fri Jan 30 11:57:02 2009 +0000
@@ -68,6 +68,7 @@
 	<property environment="env" />
 	<property name="base.config" location="config" />
 	<property file="${base.config}/Openbravo.properties" />
+	<property file="${base.config}/checksums" />
 
 	<property name="base.config" location="config" />
 	<property name="base.src" location="src" />
@@ -100,6 +101,14 @@
 
 	<available file=".svn/entries" property="is.svn" />
 
+	<checksum file="${base.src.wad}/lib/openbravo-wad.jar" algorithm="MD5" property="test.md5.wad"/>
+	
+	<condition property="new.wad">
+		<not>
+	    <equals arg1="${test.md5.wad}" arg2="${md5.wad}"/>
+		</not>
+	</condition>
+	
   <condition property="deploy.mode" value="class">
     <not>
       <isset property="${deploy.mode}" />
@@ -214,7 +223,8 @@
 	</target>
 	
 	 <target name="build.quick" depends="init">
-	    <ant dir="${base.src}" target="build.quick" inheritAll="true" inheritRefs="true" />
+
+	    <ant dir="${base.src}" target="build.quick" inheritAll="true" inheritRefs="true"/>
 	  </target>
 	
 
--- a/src-core/src/org/openbravo/checksum/CheckSum.java	Fri Jan 30 11:39:36 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,140 +0,0 @@
-/*
- *************************************************************************
- * 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.checksum;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FilenameFilter;
-import java.math.BigInteger;
-import java.security.MessageDigest;
-import java.util.Properties;
-
-public class CheckSum {
-    private String obDir;
-    private Properties properties;
-
-    public CheckSum(String dir) {
-        obDir = dir.replace("\\", "/");
-        if (!obDir.endsWith("/"))
-            obDir += "/";
-        properties = new Properties();
-        File propertiesFile = new File(obDir + "/config/checksums");
-        if (propertiesFile.exists()) {
-            try {
-                properties.load(new FileInputStream(propertiesFile));
-            } catch (Exception e) {
-                // do nothing, just do not read properties
-            }
-        }
-    }
-
-    private void getCheckSum(MessageDigest cs, File f) throws Exception {
-        if (f.isDirectory()) {
-            File[] list = f.listFiles(new FilenameFilter() {
-                public boolean accept(File file, String s) {
-                    return !s.equals(".svn");
-                }
-            });
-            for (File element : list)
-                getCheckSum(cs, element);
-        } else {
-
-            FileInputStream is = new FileInputStream(f);
-            byte[] bytes = new byte[1024];
-            int len = 0;
-
-            // Checksum file directly
-            while ((len = is.read(bytes)) >= 0) {
-                cs.update(bytes, 0, len);
-            }
-            is.close();
-        }
-    }
-
-    private String getCheckSum(String[] files) throws Exception {
-        MessageDigest cs = MessageDigest.getInstance("MD5");
-        for (String fileName : files) {
-            File file = new File(fileName);
-            if (file.exists())
-                getCheckSum(cs, file);
-        }
-        return new BigInteger(1, cs.digest()).toString(16);
-    }
-
-    private String[] getFiles(String type) {
-        if (type.equals("db.structure")) {
-            String rt[] = { obDir + "src-db/database/model" };
-            return rt;
-        } else if (type.equals("db.sourcedata")) {
-            String rt[] = { obDir + "src-db/database/sourcedata" };
-            return rt;
-        } else if (type.equals("wad")) {
-            String rt[] = { obDir + "src-wad/lib/openbravo-wad.jar" };
-            return rt;
-        } else {
-            String rt[] = new String[0];
-            return rt;
-        }
-    }
-
-    private void saveCheckSum() throws Exception {
-        FileOutputStream file = new FileOutputStream(new File(obDir
-                + "/config/checksums"));
-        properties.store(file, "Checksums for build tasks comparation");
-    }
-
-    private String calculateCheckSum(String type) {
-        try {
-            String[] files = getFiles(type);
-            String checkSum = getCheckSum(files);
-            properties.setProperty(type, checkSum);
-            saveCheckSum();
-            return checkSum;
-        } catch (Exception e) {
-            e.printStackTrace();
-            return "0";
-        }
-    }
-
-    public String calculateCheckSumDBStructure() {
-        return calculateCheckSum("db.structure");
-    }
-
-    public String calculateCheckSumDBSourceData() {
-        return calculateCheckSum("db.sourcedata");
-    }
-
-    public String calculateCheckSumWad() {
-        return calculateCheckSum("wad");
-    }
-
-    public String getCheckSumDBSTructure() {
-        return properties.getProperty("db.structure", "0");
-    }
-
-    public String getCheckSumDBSourceData() {
-        return properties.getProperty("db.sourcedata", "0");
-    }
-
-    public String getCheckSumWad() {
-        return properties.getProperty("wad", "0");
-    }
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-core/src/org/openbravo/utils/CheckSum.java	Fri Jan 30 11:57:02 2009 +0000
@@ -0,0 +1,146 @@
+/*
+ *************************************************************************
+ * 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.utils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FilenameFilter;
+import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.util.Properties;
+
+public class CheckSum {
+    private String obDir;
+    private Properties properties;
+
+    public CheckSum(String dir) {
+        obDir = dir.replace("\\", "/");
+        if (!obDir.endsWith("/"))
+            obDir += "/";
+        properties = new Properties();
+        File propertiesFile = new File(obDir + "/config/checksums");
+        if (propertiesFile.exists()) {
+            try {
+                properties.load(new FileInputStream(propertiesFile));
+            } catch (Exception e) {
+                // do nothing, just do not read properties
+            }
+        }
+    }
+
+    private void getCheckSum(MessageDigest cs, File f) throws Exception {
+        if (f.isDirectory()) {
+            File[] list = f.listFiles(new FilenameFilter() {
+                public boolean accept(File file, String s) {
+                    return !s.equals(".svn");
+                }
+            });
+            for (File element : list)
+                getCheckSum(cs, element);
+        } else {
+
+            FileInputStream is = new FileInputStream(f);
+            byte[] bytes = new byte[1024];
+            int len = 0;
+
+            // Checksum file directly
+            while ((len = is.read(bytes)) >= 0) {
+                cs.update(bytes, 0, len);
+            }
+            is.close();
+        }
+    }
+
+    private String getCheckSum(String[] files) throws Exception {
+        MessageDigest cs = MessageDigest.getInstance("MD5");
+        for (String fileName : files) {
+            File file = new File(fileName);
+            if (file.exists())
+                getCheckSum(cs, file);
+        }
+        return new BigInteger(1, cs.digest()).toString(16);
+    }
+
+    private String[] getFiles(String type) {
+        if (type.equals("md5.db.structure")) {
+            String rt[] = { obDir + "src-db/database/model" };
+            return rt;
+        } else if (type.equals("md5.db.sourcedata")) {
+            String rt[] = { obDir + "src-db/database/sourcedata" };
+            return rt;
+        } else if (type.equals("md5.wad")) {
+            String rt[] = { obDir + "src-wad/lib/openbravo-wad.jar" };
+            return rt;
+        } else {
+            String rt[] = new String[0];
+            return rt;
+        }
+    }
+
+    private void saveCheckSum() throws Exception {
+
+        FileOutputStream file = new FileOutputStream(obDir
+                + "/config/checksums");
+        properties.store(file, "Checksums for build tasks comparation");
+    }
+
+    private String calculateCheckSum(String type) {
+        try {
+            String[] files = getFiles(type);
+            String checkSum = getCheckSum(files);
+            properties.setProperty(type, checkSum);
+            saveCheckSum();
+            return checkSum;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return "0";
+        }
+    }
+
+    public String calculateCheckSumDBStructure() {
+        return calculateCheckSum("md5.db.structure");
+    }
+
+    public String calculateCheckSumDBSourceData() {
+        return calculateCheckSum("md5.db.sourcedata");
+    }
+
+    public String calculateCheckSumWad() {
+        return calculateCheckSum("md5.wad");
+    }
+
+    public String getCheckSumDBSTructure() {
+        return properties.getProperty("md5.db.structure", "0");
+    }
+
+    public String getCheckSumDBSourceData() {
+        return properties.getProperty("md5.db.sourcedata", "0");
+    }
+
+    public String getCheckSumWad() {
+        return properties.getProperty("md5.wad", "0");
+    }
+
+    public static void main(String[] args) {
+        CheckSum cs = new CheckSum("/home/openbravo/ws/trunk/openbravo");
+        cs.calculateCheckSumWad();
+    }
+
+}
--- a/src/build.xml	Fri Jan 30 11:39:36 2009 +0000
+++ b/src/build.xml	Fri Jan 30 11:57:02 2009 +0000
@@ -252,6 +252,8 @@
 	</target>
 	
 	<target name="wad.quick" depends="init">
+		
+		
 		<java classname="org.openbravo.wad.Wad" jvm="${env.JAVA_HOME}/bin/java" fork="yes" maxmemory="${build.maxmemory}">
 		      <arg line="'${base.config}' '${tab}' '${build.AD}/org/openbravo/erpWindows' '${build.AD}/org/openbravo/erpCommon' '${build.sqlc}/src' '${webTab}' '${build.AD}/org/openbravo/erpCommon/ad_actionButton' '${base.design}' '${base.translate.structure}' '${client.web.xml}' '..' '${attach.path}' '${web.url}' '${base.src}' '${complete}' '${module}' 'quick'" />
 		      <classpath refid="project.class.path" />
@@ -496,8 +498,17 @@
 		<antcall target="update.build.timestamp"/>
 	</target>
 	
-	<target name="build.quick" depends="generate.entities.quick,wad.quick,compileSqlc,postsrc,translate">
-		<antcall target="update.build.timestamp"/>
+	
+	<target name="build.quick.new.wad" if="new.wad" depends="generate.entities.quick,wad,compileSqlc,postsrc,translate">
+  </target>
+	
+	<target name="build.quick.no.new.wad" unless="new.wad" depends="generate.entities.quick,wad.quick,compileSqlc,postsrc,translate">
+	</target>
+	
+	<target name="build.quick">
+		<antcall inheritall="true" inheritrefs="true" target="build.quick.new.wad"/>
+		<antcall inheritall="true" inheritrefs="true" target="build.quick.no.new.wad"/>
+		<antcall inheritall="true" inheritrefs="true" target="update.build.timestamp"/>
 	</target>
 
 	<target name="translate" if="translation">