Example #1
0
 protected static void addRecursively(File dir, List<String> result, Set<String> all) {
   String[] files = dir.list();
   if (files == null || files.length == 0) return;
   Arrays.sort(files);
   for (int i = 0; i < files.length; i++) {
     File file = new File(dir, files[i]);
     if (file.isDirectory()) addRecursively(file, result, all);
     else if (files[i].endsWith(".class")) {
       result.add(file.getAbsolutePath());
       all.add(file.getAbsolutePath());
     }
   }
 }
Example #2
0
 /* discovers all the .class files for a given set of .java files */
 protected List<String> java2classFiles(
     List<String> javas, File cwd, File buildDir, Set<String> exclude, Set<String> noCompile)
     throws FakeException {
   List<String> result = new ArrayList<String>();
   Set<String> all = new HashSet<String>();
   if (buildDir != null) {
     addRecursively(buildDir, result, all);
     Collections.sort(result);
   }
   String lastJava = null;
   for (String file : javas) {
     if (exclude.contains(file)) continue;
     boolean dontCompile = noCompile.contains(file);
     if (buildDir != null) {
       if (!dontCompile && file.endsWith(".java")) {
         lastJava = file;
         continue;
       }
       if (lastJava != null) {
         String prefix = getPrefix(cwd, lastJava);
         if (prefix != null) result.add(prefix);
         else err.println("Error: " + lastJava);
         lastJava = null;
       }
     }
     if (dontCompile) {
       if (!all.contains(file)) {
         result.add(file);
         all.add(file);
       }
       continue;
     }
     java2classFiles(file, cwd, buildDir, result, all);
   }
   if (buildDir == null) sortClassesAtEnd(result);
   return result;
 }