Merge pull request #17662 from rjernst/verbose_install

Plugin cli: Add verbose output with zip url when installing plugin
This commit is contained in:
Ryan Ernst 2016-04-22 09:26:30 -07:00
commit d4b3ff983f
1 changed files with 7 additions and 6 deletions

View File

@ -222,7 +222,7 @@ class InstallPluginCommand extends Command {
version); version);
} }
terminal.println("-> Downloading " + pluginId + " from elastic"); terminal.println("-> Downloading " + pluginId + " from elastic");
return downloadZipAndChecksum(url, tmpDir); return downloadZipAndChecksum(terminal, url, tmpDir);
} }
// now try as maven coordinates, a valid URL would only have a colon and slash // now try as maven coordinates, a valid URL would only have a colon and slash
@ -231,16 +231,17 @@ class InstallPluginCommand extends Command {
String mavenUrl = String.format(Locale.ROOT, "https://repo1.maven.org/maven2/%1$s/%2$s/%3$s/%2$s-%3$s.zip", String mavenUrl = String.format(Locale.ROOT, "https://repo1.maven.org/maven2/%1$s/%2$s/%3$s/%2$s-%3$s.zip",
coordinates[0].replace(".", "/") /* groupId */, coordinates[1] /* artifactId */, coordinates[2] /* version */); coordinates[0].replace(".", "/") /* groupId */, coordinates[1] /* artifactId */, coordinates[2] /* version */);
terminal.println("-> Downloading " + pluginId + " from maven central"); terminal.println("-> Downloading " + pluginId + " from maven central");
return downloadZipAndChecksum(mavenUrl, tmpDir); return downloadZipAndChecksum(terminal, mavenUrl, tmpDir);
} }
// fall back to plain old URL // fall back to plain old URL
terminal.println("-> Downloading " + URLDecoder.decode(pluginId, "UTF-8")); terminal.println("-> Downloading " + URLDecoder.decode(pluginId, "UTF-8"));
return downloadZip(pluginId, tmpDir); return downloadZip(terminal, pluginId, tmpDir);
} }
/** Downloads a zip from the url, into a temp file under the given temp dir. */ /** Downloads a zip from the url, into a temp file under the given temp dir. */
private Path downloadZip(String urlString, Path tmpDir) throws IOException { private Path downloadZip(Terminal terminal, String urlString, Path tmpDir) throws IOException {
terminal.println(VERBOSE, "Retrieving zip from " + urlString);
URL url = new URL(urlString); URL url = new URL(urlString);
Path zip = Files.createTempFile(tmpDir, null, ".zip"); Path zip = Files.createTempFile(tmpDir, null, ".zip");
try (InputStream in = url.openStream()) { try (InputStream in = url.openStream()) {
@ -251,8 +252,8 @@ class InstallPluginCommand extends Command {
} }
/** Downloads a zip from the url, as well as a SHA1 checksum, and checks the checksum. */ /** Downloads a zip from the url, as well as a SHA1 checksum, and checks the checksum. */
private Path downloadZipAndChecksum(String urlString, Path tmpDir) throws Exception { private Path downloadZipAndChecksum(Terminal terminal, String urlString, Path tmpDir) throws Exception {
Path zip = downloadZip(urlString, tmpDir); Path zip = downloadZip(terminal, urlString, tmpDir);
URL checksumUrl = new URL(urlString + ".sha1"); URL checksumUrl = new URL(urlString + ".sha1");
final String expectedChecksum; final String expectedChecksum;