Class DownloadHelper
- java.lang.Object
-
- com.redhat.devtools.intellij.common.utils.DownloadHelper
-
public class DownloadHelper extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringdownloadIfRequired(java.lang.String toolName, java.net.URL url)Download tool if required.java.util.concurrent.CompletableFuture<java.lang.String>downloadIfRequiredAsync(java.lang.String toolName, java.net.URL url)static DownloadHelpergetInstance()
-
-
-
Method Detail
-
getInstance
public static DownloadHelper getInstance()
-
downloadIfRequired
public java.lang.String downloadIfRequired(java.lang.String toolName, java.net.URL url) throws java.io.IOExceptionDownload tool if required. First look at PATH then use the configuration file provided by the url to download the tool. The format of the file is the following:{ "tools": { "tool": { "version": "1.0.0", "versionCmd": "version", //the argument(s) to add to cmdFileName to get the version "versionExtractRegExp": "", //the regular expression to extract the version string from the version command "versionMatchRegExpr": "", //the regular expression use to match the extracted version to decide if download if required "baseDir": "" //the basedir to install to, a sub folder named after version will be created, can use $HOME "platforms": { "win": { "url": "https://tool.com/tool/v1.0.0/odo-windows-amd64.exe.tar.gz", "cmdFileName": "tool.exe", "dlFileName": "tool-windows-amd64.exe.gz" }, "osx": { "url": "https://tool.com/tool/v1.0.0/odo-darwin-amd64.tar.gz", "cmdFileName": "tool", "dlFileName": "tool-darwin-amd64.gz" }, "lnx": { "url": "https://tool.com/tool/v1.0.0/odo-linux-amd64.tar.gz", "cmdFileName": "odo", "dlFileName": "odo-linux-amd64.gz" } } } } }- Parameters:
toolName- the name of the tool to downloadurl- the URL to the tool description file- Returns:
- the command path
- Throws:
java.io.IOException- if the tool was not found in the config file
-
downloadIfRequiredAsync
public java.util.concurrent.CompletableFuture<java.lang.String> downloadIfRequiredAsync(java.lang.String toolName, java.net.URL url)
-
-