Example #1
0
  private String findExecutable(CompilerConfiguration config) {
    String executable = config.getExecutable();

    if (!StringUtils.isEmpty(executable)) {
      return executable;
    }

    if (Os.isFamily("windows")) {
      return "csc";
    }

    return "mcs";
  }
Example #2
0
  public List compile(CompilerConfiguration config) throws CompilerException {
    File destinationDir = new File(config.getOutputLocation());

    if (!destinationDir.exists()) {
      destinationDir.mkdirs();
    }

    String[] sourceFiles = getSourceFiles(config);

    if (sourceFiles.length == 0) {
      return Collections.EMPTY_LIST;
    }

    System.out.println(
        "Compiling "
            + sourceFiles.length
            + " "
            + "source file"
            + (sourceFiles.length == 1 ? "" : "s")
            + " to "
            + destinationDir.getAbsolutePath());

    String[] args = buildCompilerArguments(config, sourceFiles);

    List messages;

    if (config.isFork()) {
      String executable = config.getExecutable();

      if (StringUtils.isEmpty(executable)) {
        executable = "javac";
      }

      messages = compileOutOfProcess(config.getWorkingDirectory(), executable, args);
    } else {
      messages = compileInProcess(args);
    }

    return messages;
  }