Class ForeignExe


  • public class ForeignExe
    extends java.lang.Object
    Finds a foreign executable and checks its version. If either part of that fails, it shows you why and helps you fix it. Usage: ForeignExe.nameAndVersion("grep", "2.5.7").confirmVersionAndGetAbsolutePath() will find grep, confirm that it is version 2.5.7, and then return.
    • Constructor Summary

      Constructors 
      Constructor Description
      ForeignExe()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String confirmVersionAndGetAbsolutePath()
      Searches for the executable and confirms that it has the expected version.
      ForeignExe fixCantFind​(java.lang.String msg)
      Use {version} anywhere you would like to inject the actual version string.
      ForeignExe fixWrongVersion​(java.lang.String msg)
      Use {version} or {versionFound} anywhere you would like to inject the actual version strings.
      static ForeignExe nameAndVersion​(java.lang.String exeName, java.lang.String version)
      The name of the executable, used by "where" (win) and "which" (unix).
      ForeignExe pathToExe​(java.lang.String pathToExe)
      Path to the executable.
      ForeignExe versionFlag​(java.lang.String versionFlag)
      The flag which causes the exe to print its version (defaults to --version).
      ForeignExe versionRegex​(java.util.regex.Pattern versionRegex)
      A regex which can parse the version out of the output of the versionFlag(String) command (defaults to version (\\S*))
      • Methods inherited from class java.lang.Object

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

      • ForeignExe

        public ForeignExe()
    • Method Detail

      • nameAndVersion

        public static ForeignExe nameAndVersion​(java.lang.String exeName,
                                                java.lang.String version)
        The name of the executable, used by "where" (win) and "which" (unix).
      • versionFlag

        public ForeignExe versionFlag​(java.lang.String versionFlag)
        The flag which causes the exe to print its version (defaults to --version).
      • versionRegex

        public ForeignExe versionRegex​(java.util.regex.Pattern versionRegex)
        A regex which can parse the version out of the output of the versionFlag(String) command (defaults to version (\\S*))
      • fixCantFind

        public ForeignExe fixCantFind​(java.lang.String msg)
        Use {version} anywhere you would like to inject the actual version string.
      • fixWrongVersion

        public ForeignExe fixWrongVersion​(java.lang.String msg)
        Use {version} or {versionFound} anywhere you would like to inject the actual version strings.
      • pathToExe

        public ForeignExe pathToExe​(@Nullable
                                    java.lang.String pathToExe)
        Path to the executable. If null, will search for the executable on the system path.
      • confirmVersionAndGetAbsolutePath

        public java.lang.String confirmVersionAndGetAbsolutePath()
                                                          throws java.io.IOException,
                                                                 java.lang.InterruptedException
        Searches for the executable and confirms that it has the expected version. If it can't find the executable, or if it doesn't have the correct version, throws an exception with a message describing how to fix.
        Throws:
        java.io.IOException
        java.lang.InterruptedException