use of cn.bran.japid.compiler.TranslateTemplateTask in project Japid by branaway.
the class JapidCommands method reloadChanged.
/**
* @param root
* the package root "/"
* @return
*/
public static List<File> reloadChanged(String root) {
try {
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) {
// Play.classes.remove(className);
throw e;
}
List<File> changedFiles = t.getChangedFiles();
return changedFiles;
}
use of cn.bran.japid.compiler.TranslateTemplateTask in project Japid by branaway.
the class JapidRenderer method reloadChanged.
/**
* @param root
* the package root "/"
* @return the updated Java files.
*/
static List<File> reloadChanged(String root) {
try {
mkdir(root);
} catch (Exception e) {
throw new RuntimeException(e);
}
TranslateTemplateTask t = new TranslateTemplateTask();
t.setUsePlay(usePlay);
File rootDir = new File(root);
t.setPackageRoot(rootDir);
t.setInclude(new File(japidviews));
if (DirUtil.hasLayouts(root))
t.addImport("japidviews._layouts.*");
if (DirUtil.hasJavaTags(root))
t.addImport("japidviews._javatags.*");
if (DirUtil.hasTags(root))
t.addImport("japidviews._tags.*");
for (String imp : importlines) {
t.addImport(imp);
}
t.execute();
// List<File> changedFiles = t.getChangedFiles();
return t.getChangedTargetFiles();
// return changedFiles;
}
use of cn.bran.japid.compiler.TranslateTemplateTask in project japid42 by branaway.
the class JapidRenderer method reloadChanged.
/**
* @param roots
* the package root
* @return the updated Java files.
*/
static List<File> reloadChanged(String... roots) {
List<File> files = new ArrayList<File>();
if (roots == null)
return files;
//
for (String r : roots) {
File root = new File(r);
if (!root.exists()) {
JapidFlags.warn("root directory does not exist: " + root.getAbsolutePath());
continue;
}
TranslateTemplateTask t = new TranslateTemplateTask();
t.addImport("japidviews.*");
t.addImport("java.util.*");
if (usePlay) {
t.addImport("controllers.*");
t.addImport("models.*");
t.addImport("play.data.validation.Validation");
t.addImport("play.i18n.Lang");
t.addImport("play.mvc.Http.Context.Implicit");
t.addImport("play.mvc.Http.Flash");
t.addImport("play.mvc.Http.Request");
t.addImport("play.mvc.Http.Response");
t.addImport("play.mvc.Http.Session");
t.addImport("play.data.Form");
t.addImport("play.data.Form.Field");
}
for (String imp : imports) {
t.addImport(imp);
}
t.setUsePlay(usePlay);
t.setPackageRoot(root);
t.setInclude(new File(r + SEP + JAPIDVIEWS + SEP));
// _layouts and _tags are deprecated
// if (DirUtil.hasLayouts(r))
// t.addImport("japidviews._layouts.*");
// if (DirUtil.hasTags(r))
// t.addImport("japidviews._tags.*");
t.execute();
files.addAll(t.getChangedTargetFiles());
}
return files;
}
use of cn.bran.japid.compiler.TranslateTemplateTask in project Japid by branaway.
the class JapidPlayRenderer method reloadChanged.
/**
* @param root
* the package root "/"
* @return the updated Java files.
*/
static List<File> reloadChanged(String root) {
try {
mkdir(root);
} catch (Exception e) {
throw new RuntimeException(e);
}
TranslateTemplateTask t = new TranslateTemplateTask();
t.setUsePlay(usePlay);
File rootDir = new File(root);
t.setPackageRoot(rootDir);
t.setInclude(new File(japidviews));
if (DirUtil.hasLayouts(root))
t.addImport("japidviews._layouts.*");
if (DirUtil.hasJavaTags(root))
t.addImport("japidviews._javatags.*");
if (DirUtil.hasTags(root))
t.addImport("japidviews._tags.*");
for (String imp : importlines) {
t.addImport(imp);
}
// since we're bound together with play:
t.importStatic(JapidPlayAdapter.class);
t.importStatic(Validation.class);
t.importStatic(JavaExtensions.class);
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());
List<String> javatags = DirUtil.scanJavaTags(root);
for (String f : javatags) {
t.addImport("static " + f + ".*");
}
t.execute();
// List<File> changedFiles = t.getChangedFiles();
return t.getChangedTargetFiles();
// return changedFiles;
}
Aggregations