tmp.removeAll(keySet); // added html
removeRemoved(currentClassesOnDir, keySet);
for (String c : tmp) {
RendererClass rc = newRendererClass(c);
classes.put(c, rc);
}
// now all the class set size is up to date
// now update any Java source code
List<File> gen = gen(templateRoot);
// this would include both new and updated java
Set<String> updatedClasses = new HashSet<String>();
if (gen.size() > 0) {
// int i = 0;
for (File f : gen) {
String className = getClassName(f);
updatedClasses.add(className);
RendererClass rendererClass = classes.get(className);
if (rendererClass == null) {
// this should not happen, since
throw new RuntimeException("any new key should have been in the classes container: " + className);
// rendererClass = newRendererClass(className);
// classes.put(className, rendererClass);
}
rendererClass.setSourceCode(readSource(f));
removeInnerClasses(className);
cleanClassHolder(rendererClass);
}
}
// find all render class without bytecode
for (Iterator<String> i = classes.keySet().iterator(); i.hasNext();) {
String k = i.next();
RendererClass rc = classes.get(k);
if (rc.getSourceCode() == null) {
if (!rc.getClassName().contains("$")) {
rc.setSourceCode(getSourceCode(k));
cleanClassHolder(rc);
updatedClasses.add(k);
} else {
rc.setLastUpdated(0);
}
} else {
if (rc.getBytecode() == null) {
cleanClassHolder(rc);
updatedClasses.add(k);
}
}
}
// compile all
if (updatedClasses.size() > 0) {
String[] names = new String[updatedClasses.size()];
int i = 0;
for (String s : updatedClasses) {
names[i++] = s;
}
long t = System.currentTimeMillis();
compiler.compile(names);
howlong("compile time for " + names.length + " classes", t);
// clear the global class cache
for (String k : classes.keySet()) {
RendererClass rc = classes.get(k);
rc.setClz(null);
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}