DirUtil.mkdir(root);
} catch (Exception e) {
throw new RuntimeException(e);
}
TranslateTemplateTask t = new TranslateTemplateTask();
File rootDir = new File(root);
t.setPackageRoot(rootDir);
t.setInclude(new File(rootDir, DirUtil.JAPIDVIEWS_ROOT));
t.clearImports();
t.importStatic(JapidPlayAdapter.class);
t.importStatic(Validation.class);
t.importStatic(JavaExtensions.class);
t.addAnnotation(NoEnhance.class);
if (DirUtil.hasLayouts(root))
t.addImport(DirUtil.JAPIDVIEWS_ROOT + "._layouts.*");
if (DirUtil.hasJavaTags(root))
t.addImport(DirUtil.JAPIDVIEWS_ROOT + "._javatags.*");
if (DirUtil.hasTags(root))
t.addImport(DirUtil.JAPIDVIEWS_ROOT + "._tags.*");
t.addImport("models.*");
t.addImport("controllers.*");
t.addImport(play.mvc.Scope.class.getName() + ".*");
t.addImport(play.i18n.Messages.class);
t.addImport(play.i18n.Lang.class);
t.addImport(play.mvc.Http.class.getName() + ".*");
t.addImport(Validation.class.getName());
t.addImport(play.data.validation.Error.class.getName());
// t.addImport("static japidviews._javatags.JapidWebUtil.*");
List<String> javatags = DirUtil.scanJavaTags(root);
for (String f : javatags) {
t.addImport("static " + f + ".*");
}
try {
t.execute();
} catch (JapidCompilationException e) {
// remove the .class file from previous successful compilation if any
// String templateName = e.getTemplateName();
// String javaSrc = DirUtil.mapSrcToJava(templateName);
// // remove the java file
// String javaSrcPath = APP + File.separator + javaSrc;
// if (new File(javaSrcPath).delete()){
// System.out.println("[Japid] deleted: " + javaSrcPath);
// }
// String className = javaSrc.substring(0, javaSrc.length() - 5).replace('/', '.').replace('\\', '.');
// // remove the class file
// Play.classes.remove(className);
throw e;
}
List<File> changedFiles = t.getChangedFiles();
return changedFiles;
}