Merge pull request #179 from alexarchambault/topic/remove-standalone-launcher

Remove standalone launcher from the sources
This commit is contained in:
Alexandre Archambault 2016-02-27 15:52:58 +01:00
commit 506cb53f3f
6 changed files with 41 additions and 23 deletions

View File

@ -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

View File

@ -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<String, URL[]> readIsolationContexts(File jarDir, String[] isolationIDs, String bootstrapProtocol, ClassLoader loader) throws IOException {
final Map<String, URL[]> perContextURLs = new LinkedHashMap<String, URL[]>();
@ -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<URL> getLocalURLs(List<URL> 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<URL>() {
@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();

Binary file not shown.

View File

@ -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

View File

@ -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" \
"$@"

View File

@ -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