Class ForeignExe

java.lang.Object
com.diffplug.spotless.ForeignExe
All Implemented Interfaces:
Serializable

public class ForeignExe extends Object implements Serializable
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.

See Also:
  • Constructor Details

    • ForeignExe

      public ForeignExe()
  • Method Details

    • nameAndVersion

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

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

      public ForeignExe versionRegex(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(String msg)
      Use {version} anywhere you would like to inject the actual version string.
    • fixWrongVersion

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

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

      public String confirmVersionAndGetAbsolutePath() throws IOException, 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:
      IOException
      InterruptedException