Class SystemUtility

java.lang.Object
com.owc.gradle.SystemUtility

public class SystemUtility extends Object
  • Constructor Details

    • SystemUtility

      public SystemUtility()
    • SystemUtility

      public SystemUtility(File workingDirectory)
  • Method Details

    • executeShellCommand

      public String executeShellCommand(String command) throws IOException
      Executes a shell command and return the output as multiline string
      Parameters:
      command - the command to execute
      Returns:
      multiline string representing the result of
      Throws:
      IOException - if any error happens during the execution of the command, or a stream was closed by the system
    • getEnvironmentVariableOrFail

      public static String getEnvironmentVariableOrFail(String variableKey) throws IOException
      Extracts the system environment variable value and fails if the value is not present
      Parameters:
      variableKey - the requested variable key
      Returns:
      variable value
      Throws:
      IOException - if the environment variable is not defined
    • getEnvironmentVariableOrNull

      public static String getEnvironmentVariableOrNull(String variableKey)
      Extracts the system environment variable value. It may return null if the variable is not defined
      Parameters:
      variableKey - the requested variable key
      Returns:
      variable value or null if not defined