Package cn.bran.japid.compiler

Examples of cn.bran.japid.compiler.TranslateTemplateTask


      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;
  }
View Full Code Here


      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;
  }
View Full Code Here

      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;
  }
View Full Code Here

      mkdir(root);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }

    TranslateTemplateTask t = new TranslateTemplateTask();
    t.setUsePlay(false);
    File rootDir = new File(root);
    t.setPackageRoot(rootDir);
    t.setInclude(new File(japidviews));
    t.addImport("japidviews ._layouts.*");
    // t.addImport(root + "/" + "._javatags.*");
    t.addImport("japidviews ._tags.*");

    for (String imp : importlines) {
      t.addImport(imp);
    }

    t.execute();
    // List<File> changedFiles = t.getChangedFiles();
    return t.getChangedTargetFiles();
    // return changedFiles;
  }
View Full Code Here

      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, JapidPlugin.JAPIDVIEWS_ROOT));
    t.importStatic(JapidPlayAdapter.class);
    t.importStatic(Validation.class);
    t.importStatic(JavaExtensions.class);
    t.addAnnotation(NoEnhance.class);
    t.addImport(JapidPlugin.JAPIDVIEWS_ROOT + "._layouts.*");
    t.addImport(JapidPlugin.JAPIDVIEWS_ROOT + "._javatags.*");
    t.addImport(JapidPlugin.JAPIDVIEWS_ROOT + "._tags.*");
    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("models.*");
    t.addImport("controllers.*");
    t.addImport("static  japidviews._javatags.JapidWebUtil.*");
    t.execute();
    List<File> changedFiles = t.getChangedFiles();
    return changedFiles;
  }
View Full Code Here

      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;
  }
View Full Code Here

      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;
  }
View Full Code Here

TOP

Related Classes of cn.bran.japid.compiler.TranslateTemplateTask

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.