mirror of https://github.com/sbt/sbt.git
Slightly better output from boostrap JARs
This commit is contained in:
parent
c0bc52f53e
commit
71878ce3e9
|
|
@ -131,7 +131,7 @@ public class Bootstrap {
|
|||
return new File(jarDir, fileName);
|
||||
}
|
||||
|
||||
static List<URL> getLocalURLs(List<URL> urls, final File jarDir, String bootstrapProtocol) {
|
||||
static List<URL> getLocalURLs(List<URL> urls, final File jarDir, String bootstrapProtocol) throws MalformedURLException {
|
||||
|
||||
ThreadFactory threadFactory = new ThreadFactory() {
|
||||
// from scalaz Strategy.DefaultDaemonThreadFactory
|
||||
|
|
@ -149,6 +149,7 @@ public class Bootstrap {
|
|||
new ExecutorCompletionService<>(pool);
|
||||
|
||||
List<URL> localURLs = new ArrayList<>();
|
||||
List<URL> missingURLs = new ArrayList<>();
|
||||
|
||||
for (URL url : urls) {
|
||||
|
||||
|
|
@ -157,24 +158,32 @@ public class Bootstrap {
|
|||
if (protocol.equals("file") || protocol.equals(bootstrapProtocol)) {
|
||||
localURLs.add(url);
|
||||
} else {
|
||||
final URL url0 = url;
|
||||
File dest = localFile(jarDir, url);
|
||||
|
||||
if (dest.exists()) {
|
||||
localURLs.add(dest.toURI().toURL());
|
||||
} else {
|
||||
missingURLs.add(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (final URL url : missingURLs) {
|
||||
completionService.submit(new Callable<URL>() {
|
||||
@Override
|
||||
public URL call() throws Exception {
|
||||
File dest = localFile(jarDir, url0);
|
||||
File dest = localFile(jarDir, url);
|
||||
|
||||
if (!dest.exists()) {
|
||||
System.err.println("Downloading " + url0);
|
||||
try {
|
||||
URLConnection conn = url0.openConnection();
|
||||
URLConnection conn = url.openConnection();
|
||||
long lastModified = conn.getLastModified();
|
||||
InputStream s = conn.getInputStream();
|
||||
byte[] b = readFullySync(s);
|
||||
Files.write(dest.toPath(), b);
|
||||
dest.setLastModified(lastModified);
|
||||
} catch (Exception e) {
|
||||
System.err.println("Error while downloading " + url0 + ": " + e.getMessage() + ", ignoring it");
|
||||
System.err.println("Error while downloading " + url + ": " + e.getMessage() + ", ignoring it");
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
|
@ -183,7 +192,6 @@ public class Bootstrap {
|
|||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
while (localURLs.size() < urls.size()) {
|
||||
|
|
@ -191,6 +199,10 @@ public class Bootstrap {
|
|||
try {
|
||||
URL url = future.get();
|
||||
localURLs.add(url);
|
||||
int nowMissing = urls.size() - localURLs.size();
|
||||
String clearLine = "\033[2K";
|
||||
String up = "\033[1A";
|
||||
System.err.print(clearLine + "Downloaded " + (missingURLs.size() - nowMissing) + " missing file(s) / " + missingURLs.size() + "\n" + up);
|
||||
} catch (ExecutionException ex) {
|
||||
// Error message already printed from the Callable above
|
||||
System.exit(255);
|
||||
|
|
|
|||
Loading…
Reference in New Issue