use of com.intellij.util.download.DownloadableFileSetDescription in project intellij-plugins by JetBrains.
the class ErrorProneCompilerDownloadingTask method execute.
@Override
public boolean execute(CompileContext context) {
if (!ErrorProneClasspathProvider.isErrorProneCompilerSelected(context.getProject())) {
return true;
}
DownloadableFileService service = DownloadableFileService.getInstance();
DownloadableFileSetVersions<DownloadableFileSetDescription> versions = service.createFileSetVersions(null, getClass().getResource("/library/error-prone.xml"));
List<DownloadableFileSetDescription> descriptions = versions.fetchVersions();
if (descriptions.isEmpty()) {
context.addMessage(CompilerMessageCategory.ERROR, "No error-prone compiler versions loaded", null, -1, -1);
return false;
}
DownloadableFileSetDescription latestVersion = descriptions.get(0);
File cacheDir = ErrorProneClasspathProvider.getCompilerFilesDir(latestVersion.getVersionString());
if (ErrorProneClasspathProvider.getJarFiles(cacheDir).length > 0) {
return true;
}
try {
List<Pair<File, DownloadableFileDescription>> pairs = service.createDownloader(latestVersion).download(cacheDir);
if (pairs.isEmpty() || ErrorProneClasspathProvider.getJarFiles(cacheDir).length == 0) {
context.addMessage(CompilerMessageCategory.ERROR, "No compiler JARs were downloaded", null, -1, -1);
return false;
}
} catch (IOException e) {
LOG.info(e);
context.addMessage(CompilerMessageCategory.ERROR, "Failed to download error-prone compiler JARs: " + e.getMessage(), null, -1, -1);
return false;
}
return true;
}
Aggregations