Search in sources :

Example 1 with DownloadableFileSetDescription

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;
}
Also used : DownloadableFileSetDescription(com.intellij.util.download.DownloadableFileSetDescription) IOException(java.io.IOException) File(java.io.File) DownloadableFileService(com.intellij.util.download.DownloadableFileService) Pair(com.intellij.openapi.util.Pair)

Aggregations

Pair (com.intellij.openapi.util.Pair)1 DownloadableFileService (com.intellij.util.download.DownloadableFileService)1 DownloadableFileSetDescription (com.intellij.util.download.DownloadableFileSetDescription)1 File (java.io.File)1 IOException (java.io.IOException)1