diff --git a/README.md b/README.md index 0cdd72f1f..bc9a9b552 100644 --- a/README.md +++ b/README.md @@ -606,6 +606,10 @@ Set the `COURSIER_NO_TERM` environment variable to `1`. This disables the progress bar message, and prints simple `Downloading URL` / `Downloaded URL` instead. +#### On first launch, the coursier launcher downloads a 1.5+ MB JAR. Is it possible to have a standalone launcher, that would not need to download things on first launch? + +Run `project/generate-launcher.sh -s` from the root of the coursier sources. That will generate a new (bigger) `coursier` launcher, that needs not to download anything on first launch. + ## Development tips #### Working on the plugin module in an IDE diff --git a/bootstrap/src/main/java/coursier/Bootstrap.java b/bootstrap/src/main/java/coursier/Bootstrap.java index 9caa2e4ec..c27a3b459 100644 --- a/bootstrap/src/main/java/coursier/Bootstrap.java +++ b/bootstrap/src/main/java/coursier/Bootstrap.java @@ -50,6 +50,15 @@ public class Bootstrap { return content.split("\n"); } + /** + * + * @param jarDir can be null if nothing should be downloaded! + * @param isolationIDs + * @param bootstrapProtocol + * @param loader + * @return + * @throws IOException + */ static Map readIsolationContexts(File jarDir, String[] isolationIDs, String bootstrapProtocol, ClassLoader loader) throws IOException { final Map perContextURLs = new LinkedHashMap(); @@ -151,6 +160,14 @@ public class Bootstrap { } } + /** + * + * @param urls + * @param jarDir: can be null if nothing should be downloaded! + * @param bootstrapProtocol + * @return + * @throws MalformedURLException + */ static List getLocalURLs(List urls, final File jarDir, String bootstrapProtocol) throws MalformedURLException { ThreadFactory threadFactory = new ThreadFactory() { @@ -178,6 +195,8 @@ public class Bootstrap { if (protocol.equals("file") || protocol.equals(bootstrapProtocol)) { localURLs.add(url); } else { + assert jarDir != null : "Should not happen, not supposed to download things"; + File dest = localFile(jarDir, url); if (dest.exists()) { @@ -190,6 +209,8 @@ public class Bootstrap { final Random random = new Random(); for (final URL url : missingURLs) { + assert jarDir != null : "Should not happen, not supposed to download things"; + completionService.submit(new Callable() { @Override public URL call() throws Exception { @@ -326,13 +347,17 @@ public class Bootstrap { String mainClass0 = System.getProperty("bootstrap.mainClass"); String jarDir0 = System.getProperty("bootstrap.jarDir"); - final File jarDir = new File(jarDir0); + File jarDir = null; - if (jarDir.exists()) { - if (!jarDir.isDirectory()) - exit("Error: " + jarDir0 + " is not a directory"); - } else if (!jarDir.mkdirs()) - System.err.println("Warning: cannot create " + jarDir0 + ", continuing anyway."); + if (jarDir0 != null) { + jarDir = new File(jarDir0); + + if (jarDir.exists()) { + if (!jarDir.isDirectory()) + exit("Error: " + jarDir0 + " is not a directory"); + } else if (!jarDir.mkdirs()) + System.err.println("Warning: cannot create " + jarDir0 + ", continuing anyway."); + } Random rng = new Random(); String protocol = "bootstrap" + rng.nextLong(); diff --git a/coursier-standalone b/coursier-standalone deleted file mode 100755 index bd6c81beb..000000000 Binary files a/coursier-standalone and /dev/null differ diff --git a/doc/README.md b/doc/README.md index b15f9be3d..e6586a44d 100644 --- a/doc/README.md +++ b/doc/README.md @@ -630,6 +630,10 @@ Set the `COURSIER_NO_TERM` environment variable to `1`. This disables the progress bar message, and prints simple `Downloading URL` / `Downloaded URL` instead. +#### On first launch, the coursier launcher downloads a 1.5+ MB JAR. Is it possible to have a standalone launcher, that would not need to download things on first launch? + +Run `project/generate-launcher.sh -s` from the root of the coursier sources. That will generate a new (bigger) `coursier` launcher, that needs not to download anything on first launch. + ## Development tips #### Working on the plugin module in an IDE diff --git a/project/generate-launcher.sh b/project/generate-launcher.sh index 81f999a63..3c3ea727a 100755 --- a/project/generate-launcher.sh +++ b/project/generate-launcher.sh @@ -20,4 +20,5 @@ fi -D "\${user.home}/.coursier/bootstrap/$VERSION" \ -f -o coursier \ -M coursier.cli.Coursier \ - -P coursier.cache="\${user.home}/.coursier/cache/$CACHE_VERSION" + -P coursier.cache="\${user.home}/.coursier/cache/$CACHE_VERSION" \ + "$@" diff --git a/project/generate-standalone-launcher.sh b/project/generate-standalone-launcher.sh deleted file mode 100755 index 594adc9d8..000000000 --- a/project/generate-standalone-launcher.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -set -e - -cd "$(dirname "$0")/.." - -if [ ! -e cli/target/scala-2.11/proguard/coursier-standalone.jar ]; then - echo "Generating proguarded JAR..." 1>&2 - sbt cli/proguard:proguard -fi - -cat > coursier-standalone << EOF -#!/bin/sh -exec java -noverify -cp "\$0" coursier.cli.Coursier "\$@" -EOF -cat cli/target/scala-2.11/proguard/coursier-standalone.jar >> coursier-standalone -chmod +x coursier-standalone