class ExternalNativeBuildTaskUtils {

    @VisibleForTesting
    @NonNull
    static File doFindCmakeExecutableFolder(
            @Nullable String cmakeVersion,
            @NonNull SdkHandler sdkHandler,
            @NonNull List<File> foldersToSearch) {
        if (sdkHandler.getCmakePathInLocalProp() != null) {
            return sdkHandler.getCmakePathInLocalProp();
        }

        if (cmakeVersion != null && !isDefaultSdkCmakeVersion(cmakeVersion)) {
            // getRequiredCmakeFromFolders will throw a RuntimeException with errors if it is unable
            // to find the required CMake.
            File cmakeFolder =
                    getRequiredCmakeFromFolders(
                            Revision.parseRevision(cmakeVersion), foldersToSearch);
            return new File(cmakeFolder.getParent());
        }

        return getCmakeFolderFromSdkPackage(sdkHandler);
    }

}