Class ExecutablePathUtils


  • public final class ExecutablePathUtils
    extends Object
    • 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 using existsInHomeBinExePattern(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 for
        validityPredicate - predicate used to validate the executable path
        envHomeDir - home directory from environment
        fhsHome - 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 for
        validityPredicate - predicate used to validate the executable path
        envHomeDir - home directory from environment
        fhsHomes - FHS-compliant home directory
        Returns:
        file to executable
      • findExecutablePath

        @Nullable
        public static @Nullable String findExecutablePath​(@NotNull
                                                          @NotNull String executableName)
        Finds the path of the executable given its name.
        Parameters:
        executableName - of the executable
        Returns:
        path