public static void compile()

in common/src/main/java/org/apache/servicecomb/toolkit/common/ClassMaker.java [31:57]


  public static void compile(String projectPath) throws IOException, TimeoutException, InterruptedException {
    Runtime runtime = Runtime.getRuntime();

    boolean isWindows = System.getProperty("os.name").toLowerCase().indexOf("win") >= 0;
    String mvnCommand = (isWindows ? "mvn.cmd" : "mvn") + " clean package -f " + projectPath;
    Process exec = runtime.exec(mvnCommand);

    Worker worker = new Worker(exec);
    worker.start();
    ProcessStatus ps = worker.getProcessStatus();

    try {
      worker.join(30000);
      if (ps.exitCode == ProcessStatus.CODE_FAIL) {
        throw new RuntimeException("Command exec fail,command is: " + mvnCommand);
      }
      if (ps.exitCode == ProcessStatus.CODE_STARTED) {
        // not finished
        worker.interrupt();
        throw new TimeoutException();
      }
    } catch (InterruptedException e) {
      // canceled by other thread.
      worker.interrupt();
      throw e;
    }
  }