java.lang.Object
org.apache.hadoop.maven.plugin.util.Exec

public class Exec extends Object
Exec is a helper class for executing an external process from a mojo.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    OutputBufferThread is a background thread for consuming and storing output of the external process.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Exec(org.apache.maven.plugin.Mojo mojo)
    Creates a new Exec instance for executing an external process from the given mojo.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Add environment variables to a ProcessBuilder.
    static String
    Pretty-print the environment to a StringBuilder.
    int
    run(List<String> command, List<String> output)
    Runs the specified command and saves each line of the command's output to the given list.
    int
    run(List<String> command, List<String> output, List<String> errors)
    Runs the specified command and saves each line of the command's output to the given list and each line of the command's stderr to the other list.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Exec

      public Exec(org.apache.maven.plugin.Mojo mojo)
      Creates a new Exec instance for executing an external process from the given mojo.
      Parameters:
      mojo - Mojo executing external process
  • Method Details

    • run

      public int run(List<String> command, List<String> output)
      Runs the specified command and saves each line of the command's output to the given list.
      Parameters:
      command - List containing command and all arguments
      output - List in/out parameter to receive command output
      Returns:
      int exit code of command
    • run

      public int run(List<String> command, List<String> output, List<String> errors)
      Runs the specified command and saves each line of the command's output to the given list and each line of the command's stderr to the other list.
      Parameters:
      command - List containing command and all arguments
      output - List in/out parameter to receive command output
      errors - List in/out parameter to receive command stderr
      Returns:
      int exit code of command
    • addEnvironment

      public static void addEnvironment(ProcessBuilder pb, Map<String,String> env)
      Add environment variables to a ProcessBuilder.
      Parameters:
      pb - The ProcessBuilder
      env - A map of environment variable names to values.
    • envToString

      public static String envToString(Map<String,String> env)
      Pretty-print the environment to a StringBuilder.
      Parameters:
      env - A map of environment variable names to values to print.
      Returns:
      The pretty-printed string.