Example #1
0
  void createProcess() throws IOException {
    String[] command = workerKey.getArgs().toArray(new String[0]);

    // Follows the logic of {@link com.google.devtools.build.lib.shell.Command}.
    File executable = new File(command[0]);
    if (!executable.isAbsolute() && executable.getParent() != null) {
      command[0] = new File(workDir.getPathFile(), command[0]).getAbsolutePath();
    }
    ProcessBuilder processBuilder =
        new ProcessBuilder(command)
            .directory(workDir.getPathFile())
            .redirectError(Redirect.appendTo(logFile.getPathFile()));
    processBuilder.environment().clear();
    processBuilder.environment().putAll(workerKey.getEnv());

    this.process = processBuilder.start();
  }
Example #2
0
 public CommandBuilder setWorkingDir(Path path) {
   Preconditions.checkNotNull(path);
   workingDir = path.getPathFile();
   return this;
 }