Skip to content

Instantly share code, notes, and snippets.

@paulp
Last active March 30, 2017 07:58
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulp/7e65b83691e917d823b023185f226a9c to your computer and use it in GitHub Desktop.
Save paulp/7e65b83691e917d823b023185f226a9c to your computer and use it in GitHub Desktop.
sbt from zero to shell in 39s.
#!/usr/bin/env bash -x
#
# Invoke sbt starting with no local jars, using coursier.
shopt -s globstar
set -euo pipefail
cpof() {
find "$@" -iname '*.jar' -o -iname '*.zip' | paste -sd: -
}
mmkdir() {
[[ -d "$1" ]] || mkdir -p "$1"
}
SBTVERSION="0.13.13"
SCALAVERSION="2.10.6"
CACHE="./.coursier"
BOOT="./.boot"
SBTJAR="./sbt"
SCALALIB="$BOOT/scala-$SCALAVERSION/lib"
COURSIER_CACHE=$CACHE coursier fetch -r typesafe:ivy-releases -r sonatype:releases org.scala-sbt:sbt:$SBTVERSION
mmkdir $SBTJAR
cp $CACHE/**/interface*.jar "interface-$SBTVERSION.jar"
cp $CACHE/**/compiler-interface*.jar "compiler-interface-$SBTVERSION-sources.jar"
mmkdir $SCALALIB
cp $CACHE/**/scala-lang/scala-*/**/scala-compiler-*.jar $SCALALIB/scala-compiler.jar
cp $CACHE/**/scala-lang/scala-*/**/scala-reflect-*.jar $SCALALIB/scala-reflect.jar
cp $CACHE/**/scala-lang/scala-*/**/scala-library-*.jar $SCALALIB/scala-library.jar
cp $CACHE/**/jansi-*.jar $SCALALIB/jansi.jar
cp $CACHE/**/jline-*.jar $SCALALIB/jline.jar
java -Dsbt.boot.directory="$BOOT" -Dsbt.global.base="$CACHE" -cp $(cpof .coursier):$SCALALIB:. sbt.Main "$@"
% time echo about | ./bin/make-sbt.sh
Downloading https://repo1.maven.org/maven2/org/scala-sbt/sbt/0.13.13/sbt-0.13.13.pom.sha1
Downloading https://repo1.maven.org/maven2/org/scala-sbt/sbt/0.13.13/sbt-0.13.13.pom
...
> about
[info] This is sbt 0.13.13
[info] The current project is {file:/r/ivy-vs-coursier/}ivy-vs-coursier 0.1-SNAPSHOT
[info] The current project is built against Scala 2.10.6
[info] Available Plugins: sbt.plugins.IvyPlugin, sbt.plugins.JvmPlugin,
sbt.plugins.CorePlugin, sbt.plugins.JUnitXmlReportPlugin, sbt.plugins.Giter8TemplatePlugin
[info] sbt, sbt plugins, and build definitions are using Scala 2.10.6
> 39.095 real, 17.280 user, 2.029 sys
% time echo about | sbtx -no-share
Getting org.scala-sbt sbt 0.13.13 ...
downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt/0.13.13/jars/sbt.jar ...
[SUCCESSFUL ] org.scala-sbt#sbt;0.13.13!sbt.jar (2215ms)
...
> about
[info] This is sbt 0.13.13
[info] The current project is {file:/private/tmp/sbtbare/}sbtbare 0.1-SNAPSHOT
[info] The current project is built against Scala 2.10.6
[info] Available Plugins: sbt.plugins.IvyPlugin, sbt.plugins.JvmPlugin,
sbt.plugins.CorePlugin, sbt.plugins.JUnitXmlReportPlugin, sbt.plugins.Giter8TemplatePlugin
[info] sbt, sbt plugins, and build definitions are using Scala 2.10.6
> 204.582 real, 24.446 user, 2.159 sys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment