Exemplo n.º 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));
  }
Exemplo n.º 2
0
 private String getParam(String key, String value) {
   Object o = params.get(key);
   if (params == null || o == null) return value;
   return o.toString();
 }