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 ensureTerminalWindowsIsOpened​(com.intellij.openapi.project.Project project)
      Ensure the terminal window tab is created.
      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, 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, 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​(java.lang.Process p, com.intellij.openapi.project.Project project, java.lang.String title, boolean waitForProcessExit)  
      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
      • ensureTerminalWindowsIsOpened

        public static void ensureTerminalWindowsIsOpened​(com.intellij.openapi.project.Project project)
        Ensure the terminal window tab is created. This is required because some IJ editions (2018.3) do not initialize this window when you create a TerminalView through linkProcessToTerminal(Process, Project, String, boolean)
        Parameters:
        project - the IJ project
      • linkProcessToTerminal

        public static void linkProcessToTerminal​(java.lang.Process p,
                                                 com.intellij.openapi.project.Project project,
                                                 java.lang.String title,
                                                 boolean waitForProcessExit)
                                          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,
                                               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
      • 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