use of com.twelvemonkeys.lang.Platform in project intellij-common by redhat-developer.
the class DownloadHelper method downloadInBackgroundManager.
private void downloadInBackgroundManager(String toolName, ToolsConfig.Platform platform, Path path, String cmd, CompletableFuture<String> result) {
final Path dlFilePath = path.resolveSibling(platform.getDlFileName());
ProgressManager.getInstance().run(new Task.Backgroundable(null, "Downloading " + toolName, false) {
@Override
public void run(@NotNull ProgressIndicator progressIndicator) {
try {
HttpRequests.request(platform.getUrl().toString()).useProxy(true).connect(request -> {
downloadFile(request.getInputStream(), dlFilePath, progressIndicator, request.getConnection().getContentLength());
uncompress(dlFilePath, path);
return cmd;
});
} catch (IOException ignored) {
result.completeExceptionally(new IOException("Error while setting tool " + toolName + "."));
}
}
@Override
public void onFinished() {
if (!result.isCompletedExceptionally()) {
result.complete(cmd);
}
}
});
}
use of com.twelvemonkeys.lang.Platform in project intellij-common by redhat-developer.
the class DownloadHelper method getVersionFromPath.
private String getVersionFromPath(ToolsConfig.Tool tool, ToolsConfig.Platform platform) {
String version = "";
try {
Pattern pattern = Pattern.compile(tool.getVersionExtractRegExp());
String[] arguments = tool.getVersionCmd().split(" ");
String output = ExecHelper.execute(platform.getCmdFileName(), false, arguments);
try (BufferedReader reader = new BufferedReader(new StringReader(output))) {
version = reader.lines().map(line -> pattern.matcher(line)).filter(matcher -> matcher.matches()).map(matcher -> matcher.group(1)).findFirst().orElse("");
}
} catch (IOException e) {
}
return version;
}
Aggregations