Class ExecOperation


public class ExecOperation extends AbstractOperation<ExecOperation>
Executes a command on the command line.
Since:
1.0
Author:
Erik C. Thauvin
  • Constructor Details

    • ExecOperation

      public ExecOperation()
  • Method Details

    • execute

      public void execute() throws Exception
      Executes the command.
      Specified by:
      execute in class AbstractOperation<ExecOperation>
      Throws:
      Exception
    • isAix

      public static boolean isAix()
      Determines if the current operating system is AIX.
      Returns:
      true if the operating system is identified as AIX, false otherwise
    • isCygwin

      public static boolean isCygwin()
      Determines if the current operating system is Cygwin.
      Returns:
      true if the operating system is identified as Cygwin, false otherwise
    • isFreeBsd

      public static boolean isFreeBsd()
      Determines if the current operating system is FreeBSD.
      Returns:
      true if the operating system is FreeBSD, false otherwise
    • isLinux

      public static boolean isLinux()
      Determines if the operating system is Linux.
      Returns:
      true if the operating system is Linux, false otherwise
    • isMacOS

      public static boolean isMacOS()
      Determines if the current operating system is macOS.
      Returns:
      true if the OS is macOS, false otherwise
    • isMingw

      public static boolean isMingw()
      Determines if the current operating system is MinGW.
      Returns:
      true if the operating system is identified as MinGW, false otherwise
    • isOpenVms

      public static boolean isOpenVms()
      Determines if the current operating system is OpenVMS.
      Returns:
      true if the operating system is OpenVMS, false otherwise
    • isSolaris

      public static boolean isSolaris()
      Determines if the current operating system is Solaris.
      Returns:
      true if the operating system is Solaris, false otherwise
    • isWindows

      public static boolean isWindows()
      Determines if the current operating system is Windows.
      Returns:
      true if the operating system is Windows, false otherwise
    • command

      public ExecOperation command(String... arg)
      Configures the command and arguments to be executed.

      For example:

      • command("cmd", "/c", "stop.bat")
      • command("./stop.sh"
      Parameters:
      arg - one or more arguments
      Returns:
      this operation instance
      See Also:
    • command

      public List<String> command()
      Returns the command and arguments to be executed.
      Returns:
      the command and arguments
    • command

      public ExecOperation command(Collection<String> args)
      Configures the command and arguments to be executed.
      Parameters:
      args - the list of arguments
      Returns:
      this operation instance
      See Also:
    • failOnExit

      public ExecOperation failOnExit(boolean failOnExit)
      Configures whether the operation should fail if the command exit value/status is not 0.

      Default is TRUE

      Parameters:
      failOnExit - The fail on exit toggle
      Returns:
      this operation instance.
    • fromProject

      public ExecOperation fromProject(BaseProject project)
      Configures an Exec operation from a BaseProject.

      The work directory is automatically set to the project's working directory.

      Parameters:
      project - the project
      Returns:
      this operation instance
    • isFailOnExit

      public boolean isFailOnExit()
      Returns whether the operation should fail if the command exit value/status is not 0.
      Returns:
      true or false
    • timeout

      public ExecOperation timeout(int timeout)
      Configure the command timeout.
      Parameters:
      timeout - The timeout in seconds
      Returns:
      this operation instance
    • timeout

      public int timeout()
      Returns the command timeout.
      Returns:
      the timeout
    • workDir

      public ExecOperation workDir(File dir)
      Configures the working directory.
      Parameters:
      dir - the directory
      Returns:
      this operation instance
    • workDir

      public ExecOperation workDir(Path dir)
      Configures the working directory.
      Parameters:
      dir - the directory
      Returns:
      this operation instance
    • workDir

      public ExecOperation workDir(String dir)
      Configures the working directory.
      Parameters:
      dir - the directory path
      Returns:
      this operation instance
    • workDir

      public File workDir()
      Returns the working directory.
      Returns:
      the directory