Class ExecutablePathUtils
- java.lang.Object
-
- com.atlassian.bamboo.v2.build.agent.capability.ExecutablePathUtils
-
public final class ExecutablePathUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static @Nullable FiledetectExecutableOnPath(@NotNull String executableName)Detects the executable home directory and validates that it matches the required pattern usingexistsInHomeBinExePattern(String, String)static booleanexistsInHomeBinExePattern(@Nullable String homePath, @NotNull String executableName)Validates that the executable exists at the path ${homePath}/bin/${executableName} Appends ".bat" to the executable name if the platform is Windowsstatic @Nullable FilefindExecutable(@NotNull String executableName, @Nullable com.google.common.base.Predicate<File> validityPredicate, @Nullable String envHomeDir, @NotNull List<String> fhsHomes)This method will return the executable home path, searching first in environment home, then on PATH, finally in a FHS - compliant directory.static @Nullable FilefindExecutable(@NotNull String executableName, @Nullable com.google.common.base.Predicate<File> validityPredicate, @Nullable String envHomeDir, @Nullable String fhsHome)This method will return the executable home path, searching first in environment home, then on PATH, finally in a FHS - compliant directory.static @Nullable StringfindExecutablePath(@NotNull String executableName)Finds the path of the executable given its name.static Optional<File>getExistingExecutable(@Nullable String basePath, @NotNull String executableName)static @Nullable FilegetHomeFromExecutableInHomeBin(@NotNull File executable)Gets the home directory for an executable if its parent directory is 'bin'static @NotNull StringmakeBatchIfOnWindows(String builder)This method will return the executable path location based on the OS
-
-
-
Method Detail
-
existsInHomeBinExePattern
public static boolean existsInHomeBinExePattern(@Nullable @Nullable String homePath, @NotNull @NotNull String executableName)Validates that the executable exists at the path ${homePath}/bin/${executableName} Appends ".bat" to the executable name if the platform is Windows- Parameters:
homePath-executableName-- Returns:
- matches
-
getExistingExecutable
public static Optional<File> getExistingExecutable(@Nullable @Nullable String basePath, @NotNull @NotNull String executableName)
-
makeBatchIfOnWindows
@NotNull public static @NotNull String makeBatchIfOnWindows(String builder)
This method will return the executable path location based on the OS- Parameters:
builder- the executable
-
detectExecutableOnPath
@Nullable public static @Nullable File detectExecutableOnPath(@NotNull @NotNull String executableName)
Detects the executable home directory and validates that it matches the required pattern usingexistsInHomeBinExePattern(String, String)- Parameters:
executableName- of the builder executable- Returns:
- home
-
getHomeFromExecutableInHomeBin
@Nullable public static @Nullable File getHomeFromExecutableInHomeBin(@NotNull @NotNull File executable)
Gets the home directory for an executable if its parent directory is 'bin'- Parameters:
executable- the executable file used to detect the home directory- Returns:
- homeDir
-
findExecutable
@Nullable public static @Nullable File findExecutable(@NotNull @NotNull String executableName, @Nullable @Nullable com.google.common.base.Predicate<File> validityPredicate, @Nullable @Nullable String envHomeDir, @Nullable @Nullable String fhsHome)
This method will return the executable home path, searching first in environment home, then on PATH, finally in a FHS - compliant directory.- Parameters:
executableName- executable name to search forvalidityPredicate- predicate used to validate the executable pathenvHomeDir- home directory from environmentfhsHome- FHS-compliant home directory- Returns:
- file to executable
-
findExecutable
@Nullable public static @Nullable File findExecutable(@NotNull @NotNull String executableName, @Nullable @Nullable com.google.common.base.Predicate<File> validityPredicate, @Nullable @Nullable String envHomeDir, @NotNull @NotNull List<String> fhsHomes)
This method will return the executable home path, searching first in environment home, then on PATH, finally in a FHS - compliant directory.- Parameters:
executableName- executable name to search forvalidityPredicate- predicate used to validate the executable pathenvHomeDir- home directory from environmentfhsHomes- FHS-compliant home directory- Returns:
- file to executable
-
-