示例#1
0
  @SuppressWarnings("unchecked")
  public static void load(String[] args) throws Exception {
    ArrayMap params = makeDefaultConfig(args);
    if (args.length == 0) {
      if (params == null) return;
    } else {
      String path = args[0];
      if (".".equals(path)) {
        File thisPath = new File("");
        args[0] = thisPath.getAbsolutePath() + "\\build.txt";
        args[0] = StringUtils.replace(args[0], "\\", "/");
      }
      String fileContext = readString(new FileInputStream(args[0]), LSystem.ENCODING);
      ArrayMap map = (ArrayMap) ParseData.parseAll(fileContext);
      params.putAll(map);
    }
    String pb1 = (String) params.get("sourceDir");
    String outputDir = (String) params.get("outputDir");
    String javaHome = JVM.getJavaHome((String) params.get("javaHome"));
    if (outputDir == null) {
      outputDir = ".";
    }
    if (!StringUtils.isEmpty(javaHome)) {
      log("found latest JDK:" + javaHome);
    } else {
      log("didnot found JDK");
    }
    Object prjList = params.get("list");
    Projects prjs1 = new Projects();
    prjs1.verbose = true;
    prjs1.addPrjs((List<Object>) prjList);
    prjs1.sourceDir =
        args.length == 0 ? "." : addPath(new File(args[0]).getParent(), pb1).getCanonicalPath();
    prjs1.javaHome = javaHome;

    long t1 = System.currentTimeMillis();
    if (args.length > 1 && args[1].equals("clean")) {
      new JavaBuild(params).clean(prjs1);
    }
    new JavaBuild(params).build(prjs1, outputDir);
    long t2 = System.currentTimeMillis();
    log(
        String.format(
            "Compile end. time cost %,d ms, javac(compiled):%,d, copy:%,d(%,d bytes), jar:%,d, java(exec):%,d.",
            t2 - t1,
            prjs1.totalJavac,
            prjs1.totalCopy,
            prjs1.totalCopys,
            prjs1.totalJar,
            prjs1.totalJava));
  }
示例#2
0
  @SuppressWarnings("unchecked")
  static ArrayMap makeDefaultConfig(String[] args) throws Exception {
    File dir =
        args.length > 0 ? new File(args[0]).getAbsoluteFile().getParentFile() : new File(".");
    log("Current Dir:" + dir.getCanonicalPath());
    File srcDir = new File(dir, sourceFileName);
    if (srcDir.exists() && srcDir.isDirectory()) {

    } else {
      log("'src' dir not found, exiting...");
      return null;
    }
    String prjName = dir.getCanonicalFile().getName();
    log("user default project name:" + prjName);
    ArrayMap maps = new ArrayMap();
    maps.put("sourceDir", ".");
    maps.put("outputDir", ".");
    maps.put("debug", "true");
    maps.put("list", (List<Object>) ParseData.parseAll(String.format("[ [ %s , . ],  ]", prjName)));
    return maps;
  }