Package com.diffplug.spotless
Class ForeignExe
java.lang.Object
com.diffplug.spotless.ForeignExe
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSearches for the executable and confirms that it has the expected version.fixCantFind
(String msg) Use {version} anywhere you would like to inject the actual version string.fixWrongVersion
(String msg) Use {version} or {versionFound} anywhere you would like to inject the actual version strings.static ForeignExe
nameAndVersion
(String exeName, String version) The name of the executable, used by "where" (win) and "which" (unix).Path to the executable.versionFlag
(String versionFlag) The flag which causes the exe to print its version (defaults to --version).versionRegex
(Pattern versionRegex) A regex which can parse the version out of the output of theversionFlag(String)
command (defaults toversion (\\S*)
)
-
Constructor Details
-
ForeignExe
public ForeignExe()
-
-
Method Details
-
nameAndVersion
The name of the executable, used by "where" (win) and "which" (unix). -
versionFlag
The flag which causes the exe to print its version (defaults to --version). -
versionRegex
A regex which can parse the version out of the output of theversionFlag(String)
command (defaults toversion (\\S*)
) -
fixCantFind
Use {version} anywhere you would like to inject the actual version string. -
fixWrongVersion
Use {version} or {versionFound} anywhere you would like to inject the actual version strings. -
pathToExe
Path to the executable. If null, will search for the executable on the system path. -
confirmVersionAndGetAbsolutePath
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
-