Class CommandExecutor


  • public class CommandExecutor
    extends java.lang.Object
    A wrapper for ProcessBuilder that can be overridden easily for frameworks like Gradle that don't support it well.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) Logger logger  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int executeCommand​(java.util.List<java.lang.String> command, java.io.File workingDirectory, java.util.Map<java.lang.String,​java.lang.String> environmentVariables)
      Executes a command with ProcessBuilder, but also logs the call and redirects its input and output to our process.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

    • Constructor Detail

      • CommandExecutor

        public CommandExecutor​(Logger logger)
    • Method Detail

      • executeCommand

        public int executeCommand​(java.util.List<java.lang.String> command,
                                  java.io.File workingDirectory,
                                  java.util.Map<java.lang.String,​java.lang.String> environmentVariables)
                           throws java.io.IOException,
                                  java.lang.InterruptedException
        Executes a command with ProcessBuilder, but also logs the call and redirects its input and output to our process.
        Parameters:
        command - to have ProcessBuilder execute
        workingDirectory - to pass to ProcessBuilder.directory()
        environmentVariables - to put in ProcessBuilder.environment()
        Returns:
        the exit value of the command
        Throws:
        java.io.IOException
        java.lang.InterruptedException