only compile class if source file is newer than binary
authorcrawshaw <crawshaw@ibex.org>
Tue, 23 Nov 2004 19:25:38 +0000 (19:25 +0000)
committercrawshaw <crawshaw@ibex.org>
Tue, 23 Nov 2004 19:25:38 +0000 (19:25 +0000)
darcs-hash:20041123192538-2eb37-87ce91478004d8a7f439a4ae122e543a67b04caf.gz

src/java/org/ibex/tool/Compiler.java

index aaf2828..a34a735 100644 (file)
@@ -147,10 +147,20 @@ public class Compiler {
         public boolean accept(File path) { return path.isDirectory(); }
     };
     private void filterSources(List s, File dir, char[][] pack) {
+        // add the java files in this directory
+        File bdir = new File(builddir, str(pack, File.separatorChar));
         File[] ja = dir.listFiles(filterSrcs);
-        for (int i=0; i < ja.length; i++)
-            s.add(new Source(ja[i], name(classname(ja[i].getName())), pack));
+        for (int i=0; i < ja.length; i++) {
+            char[] n = name(classname(ja[i].getName()));
 
+            // skip the file if the build version is newer than the source
+            File bfile = new File(bdir, new String(n) + ".class");
+            if (bfile.lastModified() > ja[i].lastModified()) continue;
+
+            s.add(new Source(ja[i], n, pack));
+        }
+
+        // add the subdirectories as packages
         File[] d = dir.listFiles(filterDirs);
         for (int i=0; i < d.length; i++) {
             char[][] newpack = new char[pack.length + 1][];