Class ExecHelper

java.lang.Object
com.redhat.devtools.intellij.common.utils.ExecHelper

public class ExecHelper extends Object
  • Method Details

    • executeAfter

      public static ScheduledFuture<?> executeAfter(Runnable runnable, long delay, TimeUnit unit)
    • submit

      public static void submit(Runnable runnable)
    • execute

      public static String execute(String executable, boolean checkExitCode, File workingDirectory, Map<String,String> envs, com.intellij.execution.process.ProcessListener listener, String... arguments) throws IOException
      This method combine out and err outputs in result string, if you need to have them separately use @link executeWithResult(String, boolean, File, Map, String...)
      Parameters:
      executable - the executable
      checkExitCode - if exit code should be checked
      workingDirectory - the working directory for the process
      envs - the map for the environment variables
      listener - the process listener
      arguments - the arguments
      Returns:
      the combined output and error stream as a String
      Throws:
      IOException - if error during process execution
    • execute

      public static String execute(String executable, boolean checkExitCode, File workingDirectory, Map<String,String> envs, String... arguments) throws IOException
      This method combine out and err outputs in result string, if you need to have them separately use @link executeWithResult(String, boolean, File, Map, String...)
      Parameters:
      executable - the executable
      checkExitCode - if exit code should be checked
      workingDirectory - the working directory for the process
      envs - the map for the environment variables
      arguments - the arguments
      Returns:
      the combined output and error stream as a String
      Throws:
      IOException - if error during process execution
    • execute

      public static String execute(String executable, File workingDirectory, Map<String,String> envs, String... arguments) throws IOException
      This method combine out and err outputs in result string, if you need to have them separately use @link executeWithResult(String, boolean, File, Map, String...)
      Parameters:
      executable - the executable
      workingDirectory - the working directory for the process
      envs - the map for the environment variables
      arguments - the arguments
      Returns:
      the combined output and error stream as a String
      Throws:
      IOException - if error during process execution
    • execute

      public static String execute(String executable, Map<String,String> envs, String... arguments) throws IOException
      This method combine out and err outputs in result string, if you need to have them separately use @link executeWithResult(String, boolean, File, Map, String...)
      Parameters:
      executable - the executable
      envs - the map for the environment variables
      arguments - the arguments
      Returns:
      the combined output and error stream as a String
      Throws:
      IOException - if error during process execution
    • execute

      public static String execute(String executable, String... arguments) throws IOException
      This method combine out and err outputs in result string, if you need to have them separately use @link executeWithResult(String, boolean, File, Map, String...)
      Parameters:
      executable - the executable
      arguments - the arguments
      Returns:
      the combined output and error stream as a String
      Throws:
      IOException - if error during process execution
    • execute

      public static String execute(String executable, File workingDirectory, String... arguments) throws IOException
      This method combine out and err outputs in result string, if you need to have them separately use @link executeWithResult(String, boolean, File, Map, String...)
      Parameters:
      executable - the executable
      workingDirectory - the working directory for the process
      arguments - the arguments
      Returns:
      the combined output and error stream as a String
      Throws:
      IOException - if error during process execution
    • execute

      public static String execute(String executable, boolean checkExitCode, Map<String,String> envs, String... arguments) throws IOException
      This method combine out and err outputs in result string, if you need to have them separately use @link executeWithResult(String, boolean, File, Map, String...)
      Parameters:
      executable - the executable
      checkExitCode - if exit code should be checked
      envs - the map for the environment variables
      arguments - the arguments
      Returns:
      the combined output and error stream as a String
      Throws:
      IOException - if error during process execution
    • execute

      public static String execute(String executable, boolean checkExitCode, String... arguments) throws IOException
      This method combine out and err outputs in result string, if you need to have them separately use @link executeWithResult(String, boolean, File, Map, String...)
      Parameters:
      executable - the executable
      checkExitCode - if exit code should be checked
      arguments - the arguments
      Returns:
      the combined output and error stream as a String
      Throws:
      IOException - if error during process execution
    • executeWithResult

      public static ExecHelper.ExecResult executeWithResult(String executable, boolean checkExitCode, File workingDirectory, Map<String,String> envs, String... arguments) throws IOException
      Throws:
      IOException
    • executeWithResult

      public static ExecHelper.ExecResult executeWithResult(String executable, Map<String,String> envs, String... arguments) throws IOException
      Throws:
      IOException
    • createTerminalTabForReuse

      public static CommonTerminalExecutionConsole createTerminalTabForReuse(com.intellij.openapi.project.Project project, String title)
    • linkProcessToTerminal

      public static void linkProcessToTerminal(com.pty4j.PtyProcess p, com.intellij.openapi.project.Project project, String title, boolean waitForProcessExit, String... command) throws IOException
      Parameters:
      p - ptyprocess
      project - project
      title - tab title
      waitForProcessExit - wait
      command - must not be empty (for correct thread attribution in the stacktrace)
      Throws:
      IOException - if errors while processing
    • linkProcessToTerminal

      public static void linkProcessToTerminal(com.pty4j.PtyProcess p, com.intellij.openapi.project.Project project, String title, boolean waitForProcessExit, Function<ProcessHandlerInput,ExecProcessHandler> processHandlerFunction, com.intellij.execution.process.ProcessListener processListener, String... command) throws IOException
      Parameters:
      p - ptyprocess
      project - project
      title - tab title
      waitForProcessExit - wait
      processHandlerFunction - the process handler function
      processListener - listener to attach to the process
      command - must not be empty (for correct thread attribution in the stacktrace)
      Throws:
      IOException - if errors while processing
    • attachProcessToTerminal

      public static void attachProcessToTerminal(com.intellij.execution.ui.ConsoleView terminalExecutionConsole, com.pty4j.PtyProcess p, boolean waitForProcessExit, Function<ProcessHandlerInput,ExecProcessHandler> processHandlerFunction, com.intellij.execution.process.ProcessListener processListener, String... command) throws IOException
      Throws:
      IOException
    • executeWithTerminal

      public static void executeWithTerminal(com.intellij.openapi.project.Project project, String title, File workingDirectory, boolean waitForProcessToExit, Map<String,String> envs, com.intellij.execution.ui.ConsoleView terminalToReuse, Function<ProcessHandlerInput,ExecProcessHandler> processHandlerFunction, com.intellij.execution.process.ProcessListener processListener, String... command) throws IOException
      Throws:
      IOException
    • executeWithTerminal

      public static void executeWithTerminal(com.intellij.openapi.project.Project project, String title, File workingDirectory, String... command) throws IOException
      Throws:
      IOException
    • executeWithTerminal

      public static void executeWithTerminal(com.intellij.openapi.project.Project project, String title, boolean waitForProcessToExit, Map<String,String> envs, String... command) throws IOException
      Throws:
      IOException
    • executeWithTerminal

      public static void executeWithTerminal(com.intellij.openapi.project.Project project, String title, boolean waitForProcessToExit, String... command) throws IOException
      Throws:
      IOException
    • executeWithTerminal

      public static void executeWithTerminal(com.intellij.openapi.project.Project project, String title, Map<String,String> envs, String... command) throws IOException
      Throws:
      IOException
    • executeWithTerminal

      public static void executeWithTerminal(com.intellij.openapi.project.Project project, String title, String... command) throws IOException
      Throws:
      IOException
    • executeWithTerminal

      public static void executeWithTerminal(com.intellij.openapi.project.Project project, String title, File workingDirectory, boolean waitForProcessToExit, Map<String,String> envs, String... command) throws IOException
      Throws:
      IOException
    • executeWithTerminal

      public static void executeWithTerminal(com.intellij.openapi.project.Project project, String title, Map<String,String> envs, com.intellij.execution.ui.ConsoleView terminalToReuse, String... command) throws IOException
      Throws:
      IOException
    • executeWithTerminal

      public static void executeWithTerminal(com.intellij.openapi.project.Project project, String title, Map<String,String> envs, com.intellij.execution.ui.ConsoleView terminalToReuse, com.intellij.execution.process.ProcessListener processListener, String... command) throws IOException
      Throws:
      IOException
    • executeWithTerminal

      public static void executeWithTerminal(com.intellij.openapi.project.Project project, String title, Map<String,String> envs, com.intellij.execution.ui.ConsoleView terminalToReuse, Function<ProcessHandlerInput,ExecProcessHandler> processHandlerFunction, com.intellij.execution.process.ProcessListener processListener, String... command) throws IOException
      Throws:
      IOException
    • executeWithUI

      public static void executeWithUI(Map<String,String> envs, Runnable initRunnable, Consumer<String> runnable, String... command) throws IOException
      Throws:
      IOException
    • executeWithUI

      public static void executeWithUI(Map<String,String> envs, Consumer<String> runnable, String... command) throws IOException
      Throws:
      IOException