예제 #1
0
  public void createFile() throws FileExistException {
    String filePath =
        PathUtil.getFilePhyPath(
            config.getProjPath(), "src/java", config.getPkg(), config.getName(), "java");
    if (config.isNotIgnoreExisted() && FileUtil.isExist(filePath)) {
      FileExistException fileExistException = new FileExistException(filePath);
      log.error(fileExistException);
      throw fileExistException;
    }

    String dir = PathUtil.getDirPhyPath(config.getProjPath() + "/src/java", config.getPkg());
    if (FileUtil.isNotExist(dir)) {
      FileUtil.makeDirs(dir);
    }

    HashMap root = new HashMap();
    root.put("pkg", config.getPkg());
    root.put("clsName", config.getName());

    Template tpl = null;
    try {
      tpl = config.getFtlConfig().getTemplate("interface.ftl");
    } catch (IOException e) {
      e.printStackTrace();
      log.error(e);
    }

    try {
      FMUtil.process(tpl, filePath, root);
      log.info("creating interface file '" + filePath + "'");
      created.add(filePath);
    } catch (IOException e) {
      log.error(e);
    } catch (TemplateException e) {
      log.error(e);
    }
  }
예제 #2
0
 public static void makeDirsOfFileWhenNeeded(String filePath) {
   String dir = PathUtil.getDirPath(filePath);
   if (isNotExist(dir)) {
     makeDirs(dir);
   }
 }