Class ExecHelper


  • public class ExecHelper
    extends java.lang.Object
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  ExecHelper.ExecResult  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void attachProcessToTerminal​(com.intellij.execution.ui.ConsoleView terminalExecutionConsole, com.pty4j.PtyProcess p, boolean waitForProcessExit, java.util.function.Function<ProcessHandlerInput,​ExecProcessHandler> processHandlerFunction, com.intellij.execution.process.ProcessListener processListener, java.lang.String... command)  
      static CommonTerminalExecutionConsole createTerminalTabForReuse​(com.intellij.openapi.project.Project project, java.lang.String title)  
      static java.lang.String execute​(java.lang.String executable, boolean checkExitCode, java.io.File workingDirectory, java.util.Map<java.lang.String,​java.lang.String> envs, java.lang.String... arguments)
      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...)
      static java.lang.String execute​(java.lang.String executable, boolean checkExitCode, java.lang.String... arguments)
      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...)
      static java.lang.String execute​(java.lang.String executable, boolean checkExitCode, java.util.Map<java.lang.String,​java.lang.String> envs, java.lang.String... arguments)
      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...)
      static java.lang.String execute​(java.lang.String executable, java.io.File workingDirectory, java.lang.String... arguments)
      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...)
      static java.lang.String execute​(java.lang.String executable, java.io.File workingDirectory, java.util.Map<java.lang.String,​java.lang.String> envs, java.lang.String... arguments)
      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...)
      static java.lang.String execute​(java.lang.String executable, java.lang.String... arguments)
      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...)
      static java.lang.String execute​(java.lang.String executable, java.util.Map<java.lang.String,​java.lang.String> envs, java.lang.String... arguments)
      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...)
      static java.util.concurrent.ScheduledFuture<?> executeAfter​(java.lang.Runnable runnable, long delay, java.util.concurrent.TimeUnit unit)  
      static ExecHelper.ExecResult executeWithResult​(java.lang.String executable, boolean checkExitCode, java.io.File workingDirectory, java.util.Map<java.lang.String,​java.lang.String> envs, java.lang.String... arguments)  
      static ExecHelper.ExecResult executeWithResult​(java.lang.String executable, java.util.Map<java.lang.String,​java.lang.String> envs, java.lang.String... arguments)  
      static void executeWithTerminal​(com.intellij.openapi.project.Project project, java.lang.String title, boolean waitForProcessToExit, java.lang.String... command)  
      static void executeWithTerminal​(com.intellij.openapi.project.Project project, java.lang.String title, boolean waitForProcessToExit, java.util.Map<java.lang.String,​java.lang.String> envs, java.lang.String... command)  
      static void executeWithTerminal​(com.intellij.openapi.project.Project project, java.lang.String title, java.io.File workingDirectory, boolean waitForProcessToExit, java.util.Map<java.lang.String,​java.lang.String> envs, com.intellij.execution.ui.ConsoleView terminalToReuse, java.util.function.Function<ProcessHandlerInput,​ExecProcessHandler> processHandlerFunction, com.intellij.execution.process.ProcessListener processListener, java.lang.String... command)  
      static void executeWithTerminal​(com.intellij.openapi.project.Project project, java.lang.String title, java.io.File workingDirectory, java.lang.String... command)  
      static void executeWithTerminal​(com.intellij.openapi.project.Project project, java.lang.String title, java.lang.String... command)  
      static void executeWithTerminal​(com.intellij.openapi.project.Project project, java.lang.String title, java.util.Map<java.lang.String,​java.lang.String> envs, com.intellij.execution.ui.ConsoleView terminalToReuse, com.intellij.execution.process.ProcessListener processListener, java.lang.String... command)  
      static void executeWithTerminal​(com.intellij.openapi.project.Project project, java.lang.String title, java.util.Map<java.lang.String,​java.lang.String> envs, com.intellij.execution.ui.ConsoleView terminalToReuse, java.lang.String... command)  
      static void executeWithTerminal​(com.intellij.openapi.project.Project project, java.lang.String title, java.util.Map<java.lang.String,​java.lang.String> envs, com.intellij.execution.ui.ConsoleView terminalToReuse, java.util.function.Function<ProcessHandlerInput,​ExecProcessHandler> processHandlerFunction, com.intellij.execution.process.ProcessListener processListener, java.lang.String... command)  
      static void executeWithTerminal​(com.intellij.openapi.project.Project project, java.lang.String title, java.util.Map<java.lang.String,​java.lang.String> envs, java.lang.String... command)  
      static void executeWithUI​(java.util.Map<java.lang.String,​java.lang.String> envs, java.lang.Runnable initRunnable, java.util.function.Consumer<java.lang.String> runnable, java.lang.String... command)  
      static void executeWithUI​(java.util.Map<java.lang.String,​java.lang.String> envs, java.util.function.Consumer<java.lang.String> runnable, java.lang.String... command)  
      static void linkProcessToTerminal​(com.pty4j.PtyProcess p, com.intellij.openapi.project.Project project, java.lang.String title, boolean waitForProcessExit, java.lang.String... command)  
      static void linkProcessToTerminal​(com.pty4j.PtyProcess p, com.intellij.openapi.project.Project project, java.lang.String title, boolean waitForProcessExit, java.util.function.Function<ProcessHandlerInput,​ExecProcessHandler> processHandlerFunction, com.intellij.execution.process.ProcessListener processListener, java.lang.String... command)  
      static void submit​(java.lang.Runnable runnable)  
      • Methods inherited from class java.lang.Object

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

      • executeAfter

        public static java.util.concurrent.ScheduledFuture<?> executeAfter​(java.lang.Runnable runnable,
                                                                           long delay,
                                                                           java.util.concurrent.TimeUnit unit)
      • submit

        public static void submit​(java.lang.Runnable runnable)
      • execute

        public static java.lang.String execute​(java.lang.String executable,
                                               boolean checkExitCode,
                                               java.io.File workingDirectory,
                                               java.util.Map<java.lang.String,​java.lang.String> envs,
                                               java.lang.String... arguments)
                                        throws java.io.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:
        java.io.IOException - if error during process execution
      • execute

        public static java.lang.String execute​(java.lang.String executable,
                                               java.io.File workingDirectory,
                                               java.util.Map<java.lang.String,​java.lang.String> envs,
                                               java.lang.String... arguments)
                                        throws java.io.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:
        java.io.IOException - if error during process execution
      • execute

        public static java.lang.String execute​(java.lang.String executable,
                                               java.util.Map<java.lang.String,​java.lang.String> envs,
                                               java.lang.String... arguments)
                                        throws java.io.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:
        java.io.IOException - if error during process execution
      • execute

        public static java.lang.String execute​(java.lang.String executable,
                                               java.lang.String... arguments)
                                        throws java.io.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:
        java.io.IOException - if error during process execution
      • execute

        public static java.lang.String execute​(java.lang.String executable,
                                               java.io.File workingDirectory,
                                               java.lang.String... arguments)
                                        throws java.io.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:
        java.io.IOException - if error during process execution
      • execute

        public static java.lang.String execute​(java.lang.String executable,
                                               boolean checkExitCode,
                                               java.util.Map<java.lang.String,​java.lang.String> envs,
                                               java.lang.String... arguments)
                                        throws java.io.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:
        java.io.IOException - if error during process execution
      • execute

        public static java.lang.String execute​(java.lang.String executable,
                                               boolean checkExitCode,
                                               java.lang.String... arguments)
                                        throws java.io.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:
        java.io.IOException - if error during process execution
      • executeWithResult

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        public static void executeWithUI​(java.util.Map<java.lang.String,​java.lang.String> envs,
                                         java.lang.Runnable initRunnable,
                                         java.util.function.Consumer<java.lang.String> runnable,
                                         java.lang.String... command)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • executeWithUI

        public static void executeWithUI​(java.util.Map<java.lang.String,​java.lang.String> envs,
                                         java.util.function.Consumer<java.lang.String> runnable,
                                         java.lang.String... command)
                                  throws java.io.IOException
        Throws:
        java.io.IOException