Install install = new Install(new ProgressReportingDownload(progressLoggerFactory), new PathAssembler(realUserHomeDir));
installDir = install.createDist(wrapperConfiguration);
} catch (FileNotFoundException e) {
throw new IllegalArgumentException(String.format("The specified %s does not exist.", getDisplayName()), e);
} catch (CancellationException e) {
throw new BuildCancelledException(String.format("Distribution download cancelled. Using distribution from '%s'.", wrapperConfiguration.getDistribution()), e);
} catch (Exception e) {
throw new GradleConnectionException(String.format("Could not install Gradle distribution from '%s'.", wrapperConfiguration.getDistribution()), e);
}
return installDir;
}
};
File installDir;
ExecutorService executor = null;
try {
executor = executorFactory.create();
final Future<File> installDirFuture = executor.submit(installDistroTask);
cancellationToken.addCallback(new Runnable() {
public void run() {
// TODO(radim): better to close the connection too to allow quick finish of the task
installDirFuture.cancel(true);
}
});
installDir = installDirFuture.get();
} catch (CancellationException e) {
throw new BuildCancelledException(String.format("Distribution download cancelled. Using distribution from '%s'.", wrapperConfiguration.getDistribution()), e);
} catch (InterruptedException e) {
throw new GradleConnectionException(String.format("Could not install Gradle distribution from '%s'.", wrapperConfiguration.getDistribution()), e);
} catch (ExecutionException e) {
if (e.getCause() != null) {
UncheckedException.throwAsUncheckedException(e.getCause());