org.apache.maven.shared.utils.cli
Class CommandLineUtils
java.lang.Object
  
org.apache.maven.shared.utils.cli.CommandLineUtils
public abstract class CommandLineUtils
- extends Object
 
- Version:
 
  - $Id: CommandLineUtils.html 925654 2014-10-13 20:12:40Z krosenvold $
 
- Author:
 
  - Trygve Laugstøl 
 
 
 
| 
Method Summary | 
static int | 
executeCommandLine(Commandline cl,
                   InputStream systemIn,
                   StreamConsumer systemOut,
                   StreamConsumer systemErr)
 
            | 
static int | 
executeCommandLine(Commandline cl,
                   InputStream systemIn,
                   StreamConsumer systemOut,
                   StreamConsumer systemErr,
                   int timeoutInSeconds)
 
            | 
static int | 
executeCommandLine(Commandline cl,
                   InputStream systemIn,
                   StreamConsumer systemOut,
                   StreamConsumer systemErr,
                   int timeoutInSeconds,
                   Runnable runAfterProcessTermination)
 
            | 
static int | 
executeCommandLine(Commandline cl,
                   StreamConsumer systemOut,
                   StreamConsumer systemErr)
 
            | 
static int | 
executeCommandLine(Commandline cl,
                   StreamConsumer systemOut,
                   StreamConsumer systemErr,
                   int timeoutInSeconds)
 
            | 
static CommandLineCallable | 
executeCommandLineAsCallable(Commandline cl,
                             InputStream systemIn,
                             StreamConsumer systemOut,
                             StreamConsumer systemErr,
                             int timeoutInSeconds,
                             Runnable runAfterProcessTermination)
 
          Immediately forks a process, returns a callable that will block until process is complete. | 
static Properties | 
getSystemEnvVars()
 
          Gets the shell environment variables for this process. | 
static Properties | 
getSystemEnvVars(boolean caseSensitive)
 
          Return the shell environment variables. | 
static String | 
toString(String... line)
 
            | 
static String[] | 
translateCommandline(String toProcess)
 
            | 
 
| Methods inherited from class java.lang.Object | 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
 
CommandLineUtils
public CommandLineUtils()
executeCommandLine
public static int executeCommandLine(@Nonnull
                                     Commandline cl,
                                     StreamConsumer systemOut,
                                     StreamConsumer systemErr)
                              throws CommandLineException
- Throws:
 CommandLineException
 
executeCommandLine
public static int executeCommandLine(@Nonnull
                                     Commandline cl,
                                     StreamConsumer systemOut,
                                     StreamConsumer systemErr,
                                     int timeoutInSeconds)
                              throws CommandLineException
- Throws:
 CommandLineException
 
executeCommandLine
public static int executeCommandLine(@Nonnull
                                     Commandline cl,
                                     InputStream systemIn,
                                     StreamConsumer systemOut,
                                     StreamConsumer systemErr)
                              throws CommandLineException
- Throws:
 CommandLineException
 
executeCommandLine
public static int executeCommandLine(@Nonnull
                                     Commandline cl,
                                     InputStream systemIn,
                                     StreamConsumer systemOut,
                                     StreamConsumer systemErr,
                                     int timeoutInSeconds)
                              throws CommandLineException
- Parameters:
 cl - The command line to executesystemIn - The input to read from, must be thread safesystemOut - A consumer that receives output, must be thread safesystemErr - A consumer that receives system error stream output, must be thread safetimeoutInSeconds - Positive integer to specify timeout, zero and negative integers for no timeout.
- Returns:
 - A return value, see 
Process.exitValue()
 - Throws:
 CommandLineException - or CommandLineTimeOutException if time out occurs
 
executeCommandLine
public static int executeCommandLine(@Nonnull
                                     Commandline cl,
                                     InputStream systemIn,
                                     StreamConsumer systemOut,
                                     StreamConsumer systemErr,
                                     int timeoutInSeconds,
                                     @Nullable
                                     Runnable runAfterProcessTermination)
                              throws CommandLineException
- Parameters:
 cl - The command line to executesystemIn - The input to read from, must be thread safesystemOut - A consumer that receives output, must be thread safesystemErr - A consumer that receives system error stream output, must be thread safetimeoutInSeconds - Positive integer to specify timeout, zero and negative integers for no timeout.runAfterProcessTermination - Optional callback to run after the process terminated or the the timeout was
  exceeded, but before waiting on the stream feeder and pumpers to finish.
- Returns:
 - A return value, see 
Process.exitValue()
 - Throws:
 CommandLineException - or CommandLineTimeOutException if time out occurs
 
executeCommandLineAsCallable
public static CommandLineCallable executeCommandLineAsCallable(@Nonnull
                                                               Commandline cl,
                                                               @Nullable
                                                               InputStream systemIn,
                                                               StreamConsumer systemOut,
                                                               StreamConsumer systemErr,
                                                               int timeoutInSeconds,
                                                               @Nullable
                                                               Runnable runAfterProcessTermination)
                                                        throws CommandLineException
- Immediately forks a process, returns a callable that will block until process is complete.
- Parameters:
 cl - The command line to executesystemIn - The input to read from, must be thread safesystemOut - A consumer that receives output, must be thread safesystemErr - A consumer that receives system error stream output, must be thread safetimeoutInSeconds - Positive integer to specify timeout, zero and negative integers for no timeout.runAfterProcessTermination - Optional callback to run after the process terminated or the the timeout was
- Returns:
 - A CommandLineCallable that provides the process return value, see 
Process.exitValue(). "call" must be called on
         this to be sure the forked process has terminated, no guarantees is made about
         any internal state before after the completion of the call statements
 - Throws:
 CommandLineException - or CommandLineTimeOutException if time out occurs
 
 
getSystemEnvVars
public static Properties getSystemEnvVars()
- Gets the shell environment variables for this process. Note that the returned mapping from variable names to
 values will always be case-sensitive regardless of the platform, i.e. 
getSystemEnvVars().get("path")
 and getSystemEnvVars().get("PATH") will in general return different values. However, on platforms
 with case-insensitive environment variables like Windows, all variable names will be normalized to upper case.
- Returns:
 - The shell environment variables, can be empty but never 
null. - See Also:
 System.getenv() API, new in JDK 5.0, to get the same result
      since 2.0.2 System#getenv() will be used if available in the current running jvm.
 
 
getSystemEnvVars
public static Properties getSystemEnvVars(boolean caseSensitive)
- Return the shell environment variables. If 
caseSensitive == true, then envar
 keys will all be upper-case.
- Parameters:
 caseSensitive - Whether environment variable keys should be treated case-sensitively.
- Returns:
 - Properties object of (possibly modified) envar keys mapped to their values.
 - See Also:
 System.getenv() API, new in JDK 5.0, to get the same result
      since 2.0.2 System#getenv() will be used if available in the current running jvm.
 
 
translateCommandline
public static String[] translateCommandline(String toProcess)
                                     throws Exception
- Throws:
 Exception
 
toString
public static String toString(String... line)
 
Copyright © 2002–2014 The Apache Software Foundation. All rights reserved.