Upgrade to sbt-1.0.3
This commit is contained in:
parent
4ff7447abf
commit
64d2274d30
44
build.sbt
44
build.sbt
|
@ -1,13 +1,7 @@
|
|||
import de.johoop.findbugs4sbt.ReportType
|
||||
|
||||
name := "snappy-java"
|
||||
|
||||
organization := "org.xerial.snappy"
|
||||
|
||||
organizationName := "xerial.org"
|
||||
|
||||
description := "snappy-java: A fast compression/decompression library"
|
||||
|
||||
sonatypeProfileName := "org.xerial"
|
||||
|
||||
credentials ++= {
|
||||
|
@ -19,6 +13,14 @@ credentials ++= {
|
|||
}
|
||||
}
|
||||
|
||||
publishTo := Some(
|
||||
if (isSnapshot.value) {
|
||||
Opts.resolver.sonatypeSnapshots
|
||||
} else {
|
||||
Opts.resolver.sonatypeStaging
|
||||
}
|
||||
)
|
||||
|
||||
pomExtra := {
|
||||
<url>https://github.com/xerial/snappy-java</url>
|
||||
<licenses>
|
||||
|
@ -54,7 +56,7 @@ pomExtra := {
|
|||
</scm>
|
||||
}
|
||||
|
||||
scalaVersion in ThisBuild := "2.11.8"
|
||||
scalaVersion in ThisBuild := "2.12.4"
|
||||
|
||||
javacOptions in (Compile, compile) ++= Seq("-encoding", "UTF-8", "-Xlint:unchecked", "-Xlint:deprecation", "-source", "1.7", "-target", "1.7")
|
||||
|
||||
|
@ -67,25 +69,14 @@ javacOptions in doc := {
|
|||
}
|
||||
|
||||
testOptions += Tests.Argument(TestFrameworks.JUnit, "-q", "-v")
|
||||
|
||||
concurrentRestrictions in Global := Seq(Tags.limit(Tags.Test, 1))
|
||||
|
||||
autoScalaLibrary := false
|
||||
|
||||
crossPaths := false
|
||||
|
||||
logBuffered in Test := false
|
||||
|
||||
incOptions := incOptions.value.withNameHashing(true)
|
||||
|
||||
findbugsSettings
|
||||
|
||||
findbugsReportType := Some(ReportType.FancyHtml)
|
||||
|
||||
findbugsReportType := Some(FindbugsReport.FancyHtml)
|
||||
findbugsReportPath := Some(crossTarget.value / "findbugs" / "report.html")
|
||||
|
||||
jacoco.settings
|
||||
|
||||
libraryDependencies ++= Seq(
|
||||
"junit" % "junit" % "4.8.2" % "test",
|
||||
"org.codehaus.plexus" % "plexus-classworlds" % "2.4" % "test",
|
||||
|
@ -96,15 +87,11 @@ libraryDependencies ++= Seq(
|
|||
"com.novocode" % "junit-interface" % "0.10" % "test"
|
||||
)
|
||||
|
||||
osgiSettings
|
||||
|
||||
enablePlugins(SbtOsgi)
|
||||
|
||||
OsgiKeys.exportPackage := Seq("org.xerial.snappy", "org.xerial.snappy.buffer")
|
||||
|
||||
OsgiKeys.bundleSymbolicName := "org.xerial.snappy.snappy-java"
|
||||
|
||||
OsgiKeys.bundleActivator := Option("org.xerial.snappy.SnappyBundleActivator")
|
||||
|
||||
OsgiKeys.importPackage := Seq("""org.osgi.framework;version="[1.5,2)"""")
|
||||
|
||||
OsgiKeys.additionalHeaders := Map(
|
||||
|
@ -140,6 +127,7 @@ import ReleaseTransformations._
|
|||
import sbtrelease._
|
||||
|
||||
releaseTagName := { (version in ThisBuild).value }
|
||||
releasePublishArtifactsAction := PgpKeys.publishSigned.value
|
||||
|
||||
releaseProcess := Seq[ReleaseStep](
|
||||
checkSnapshotDependencies,
|
||||
|
@ -149,14 +137,10 @@ releaseProcess := Seq[ReleaseStep](
|
|||
setReleaseVersion,
|
||||
commitReleaseVersion,
|
||||
tagRelease,
|
||||
ReleaseStep(action = Command.process("publishSigned", _)),
|
||||
publishArtifacts,
|
||||
setNextVersion,
|
||||
commitNextVersion,
|
||||
ReleaseStep(action = Command.process("sonatypeReleaseAll", _)),
|
||||
releaseStepCommand("sonatypeReleaseAll"),
|
||||
pushChanges
|
||||
)
|
||||
|
||||
|
||||
com.etsy.sbt.Checkstyle.checkstyleSettings
|
||||
|
||||
com.etsy.sbt.Checkstyle.CheckstyleTasks.checkstyleConfig := file("src/checkstyle/checks.xml")
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
sbt.version=0.13.13
|
||||
sbt.version=1.0.3
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.3")
|
||||
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "1.1")
|
||||
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")
|
||||
addSbtPlugin("de.johoop" % "findbugs4sbt" % "1.4.0")
|
||||
addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.1.5")
|
||||
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.7.0")
|
||||
addSbtPlugin("com.etsy" % "sbt-checkstyle-plugin" % "0.4.3")
|
||||
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0-M15")
|
||||
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.6")
|
||||
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.0")
|
||||
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0")
|
||||
addSbtPlugin("com.github.sbt" % "sbt-findbugs" % "2.0.0")
|
||||
addSbtPlugin("com.github.sbt" % "sbt-jacoco" % "3.0.3")
|
||||
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.9.2")
|
||||
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0-RC13")
|
||||
addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.3.0")
|
||||
|
|
363
sbt
363
sbt
|
@ -3,20 +3,95 @@
|
|||
# A more capable sbt runner, coincidentally also called sbt.
|
||||
# Author: Paul Phillips <paulp@improving.org>
|
||||
|
||||
# todo - make this dynamic
|
||||
declare -r sbt_release_version="0.13.8"
|
||||
declare -r sbt_unreleased_version="0.13.9-M1"
|
||||
set -o pipefail
|
||||
|
||||
declare -r sbt_release_version="0.13.16"
|
||||
declare -r sbt_unreleased_version="0.13.16"
|
||||
|
||||
declare -r latest_213="2.13.0-M2"
|
||||
declare -r latest_212="2.12.4"
|
||||
declare -r latest_211="2.11.11"
|
||||
declare -r latest_210="2.10.6"
|
||||
declare -r latest_29="2.9.3"
|
||||
declare -r latest_28="2.8.2"
|
||||
|
||||
declare -r buildProps="project/build.properties"
|
||||
|
||||
declare sbt_jar sbt_dir sbt_create sbt_version
|
||||
declare scala_version sbt_explicit_version
|
||||
declare verbose noshare batch trace_level log_level
|
||||
declare sbt_saved_stty debugUs
|
||||
declare -r sbt_launch_ivy_release_repo="http://repo.typesafe.com/typesafe/ivy-releases"
|
||||
declare -r sbt_launch_ivy_snapshot_repo="https://repo.scala-sbt.org/scalasbt/ivy-snapshots"
|
||||
declare -r sbt_launch_mvn_release_repo="http://repo.scala-sbt.org/scalasbt/maven-releases"
|
||||
declare -r sbt_launch_mvn_snapshot_repo="http://repo.scala-sbt.org/scalasbt/maven-snapshots"
|
||||
|
||||
declare -r default_jvm_opts_common="-Xms512m -Xmx1536m -Xss2m"
|
||||
declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy"
|
||||
|
||||
declare sbt_jar sbt_dir sbt_create sbt_version sbt_script sbt_new
|
||||
declare sbt_explicit_version
|
||||
declare verbose noshare batch trace_level
|
||||
declare debugUs
|
||||
|
||||
declare java_cmd="java"
|
||||
declare sbt_launch_dir="$HOME/.sbt/launchers"
|
||||
declare sbt_launch_repo
|
||||
|
||||
# pull -J and -D options to give to java.
|
||||
declare -a java_args scalac_args sbt_commands residual_args
|
||||
|
||||
# args to jvm/sbt via files or environment variables
|
||||
declare -a extra_jvm_opts extra_sbt_opts
|
||||
|
||||
echoerr () { echo >&2 "$@"; }
|
||||
vlog () { [[ -n "$verbose" ]] && echoerr "$@"; }
|
||||
die () { echo "Aborting: $@" ; exit 1; }
|
||||
|
||||
setTrapExit () {
|
||||
# save stty and trap exit, to ensure echo is re-enabled if we are interrupted.
|
||||
export SBT_STTY="$(stty -g 2>/dev/null)"
|
||||
|
||||
# restore stty settings (echo in particular)
|
||||
onSbtRunnerExit() {
|
||||
[ -t 0 ] || return
|
||||
vlog ""
|
||||
vlog "restoring stty: $SBT_STTY"
|
||||
stty "$SBT_STTY"
|
||||
}
|
||||
|
||||
vlog "saving stty: $SBT_STTY"
|
||||
trap onSbtRunnerExit EXIT
|
||||
}
|
||||
|
||||
# this seems to cover the bases on OSX, and someone will
|
||||
# have to tell me about the others.
|
||||
get_script_path () {
|
||||
local path="$1"
|
||||
[[ -L "$path" ]] || { echo "$path" ; return; }
|
||||
|
||||
local target="$(readlink "$path")"
|
||||
if [[ "${target:0:1}" == "/" ]]; then
|
||||
echo "$target"
|
||||
else
|
||||
echo "${path%/*}/$target"
|
||||
fi
|
||||
}
|
||||
|
||||
declare -r script_path="$(get_script_path "$BASH_SOURCE")"
|
||||
declare -r script_name="${script_path##*/}"
|
||||
|
||||
init_default_option_file () {
|
||||
local overriding_var="${!1}"
|
||||
local default_file="$2"
|
||||
if [[ ! -r "$default_file" && "$overriding_var" =~ ^@(.*)$ ]]; then
|
||||
local envvar_file="${BASH_REMATCH[1]}"
|
||||
if [[ -r "$envvar_file" ]]; then
|
||||
default_file="$envvar_file"
|
||||
fi
|
||||
fi
|
||||
echo "$default_file"
|
||||
}
|
||||
|
||||
declare sbt_opts_file="$(init_default_option_file SBT_OPTS .sbtopts)"
|
||||
declare jvm_opts_file="$(init_default_option_file JVM_OPTS .jvmopts)"
|
||||
|
||||
# spaces are possible, e.g. sbt.version = 0.13.0
|
||||
build_props_sbt () {
|
||||
[[ -r "$buildProps" ]] && \
|
||||
grep '^sbt\.version' "$buildProps" | tr '=\r' ' ' | awk '{ print $2; }'
|
||||
|
@ -43,153 +118,87 @@ set_sbt_version () {
|
|||
export sbt_version
|
||||
}
|
||||
|
||||
# restore stty settings (echo in particular)
|
||||
onSbtRunnerExit() {
|
||||
[[ -n "$sbt_saved_stty" ]] || return
|
||||
vlog ""
|
||||
vlog "restoring stty: $sbt_saved_stty"
|
||||
stty "$sbt_saved_stty"
|
||||
unset sbt_saved_stty
|
||||
}
|
||||
|
||||
# save stty and trap exit, to ensure echo is reenabled if we are interrupted.
|
||||
trap onSbtRunnerExit EXIT
|
||||
sbt_saved_stty="$(stty -g 2>/dev/null)"
|
||||
vlog "Saved stty: $sbt_saved_stty"
|
||||
|
||||
# this seems to cover the bases on OSX, and someone will
|
||||
# have to tell me about the others.
|
||||
get_script_path () {
|
||||
local path="$1"
|
||||
[[ -L "$path" ]] || { echo "$path" ; return; }
|
||||
|
||||
local target="$(readlink "$path")"
|
||||
if [[ "${target:0:1}" == "/" ]]; then
|
||||
echo "$target"
|
||||
else
|
||||
echo "${path%/*}/$target"
|
||||
fi
|
||||
}
|
||||
|
||||
die() {
|
||||
echo "Aborting: $@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
make_url () {
|
||||
version="$1"
|
||||
url_base () {
|
||||
local version="$1"
|
||||
|
||||
case "$version" in
|
||||
0.7.*) echo "http://simple-build-tool.googlecode.com/files/sbt-launch-0.7.7.jar" ;;
|
||||
0.10.* ) echo "$sbt_launch_repo/org.scala-tools.sbt/sbt-launch/$version/sbt-launch.jar" ;;
|
||||
0.11.[12]) echo "$sbt_launch_repo/org.scala-tools.sbt/sbt-launch/$version/sbt-launch.jar" ;;
|
||||
*) echo "$sbt_launch_repo/org.scala-sbt/sbt-launch/$version/sbt-launch.jar" ;;
|
||||
0.7.*) echo "http://simple-build-tool.googlecode.com" ;;
|
||||
0.10.* ) echo "$sbt_launch_ivy_release_repo" ;;
|
||||
0.11.[12]) echo "$sbt_launch_ivy_release_repo" ;;
|
||||
0.*-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9]) # ie "*-yyyymmdd-hhMMss"
|
||||
echo "$sbt_launch_ivy_snapshot_repo" ;;
|
||||
0.*) echo "$sbt_launch_ivy_release_repo" ;;
|
||||
*-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9]) # ie "*-yyyymmdd-hhMMss"
|
||||
echo "$sbt_launch_mvn_snapshot_repo" ;;
|
||||
*) echo "$sbt_launch_mvn_release_repo" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
init_default_option_file () {
|
||||
local overriding_var="${!1}"
|
||||
local default_file="$2"
|
||||
if [[ ! -r "$default_file" && "$overriding_var" =~ ^@(.*)$ ]]; then
|
||||
local envvar_file="${BASH_REMATCH[1]}"
|
||||
if [[ -r "$envvar_file" ]]; then
|
||||
default_file="$envvar_file"
|
||||
fi
|
||||
fi
|
||||
echo "$default_file"
|
||||
make_url () {
|
||||
local version="$1"
|
||||
|
||||
local base="${sbt_launch_repo:-$(url_base "$version")}"
|
||||
|
||||
case "$version" in
|
||||
0.7.*) echo "$base/files/sbt-launch-0.7.7.jar" ;;
|
||||
0.10.* ) echo "$base/org.scala-tools.sbt/sbt-launch/$version/sbt-launch.jar" ;;
|
||||
0.11.[12]) echo "$base/org.scala-tools.sbt/sbt-launch/$version/sbt-launch.jar" ;;
|
||||
0.*) echo "$base/org.scala-sbt/sbt-launch/$version/sbt-launch.jar" ;;
|
||||
*) echo "$base/org/scala-sbt/sbt-launch/$version/sbt-launch.jar" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
declare -r cms_opts="-XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC"
|
||||
declare -r jit_opts="-XX:ReservedCodeCacheSize=256m -XX:+TieredCompilation"
|
||||
declare -r default_jvm_opts_common="-Xms512m -Xmx2048m -Xss2m $jit_opts $cms_opts"
|
||||
declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy"
|
||||
declare -r latest_28="2.8.2"
|
||||
declare -r latest_29="2.9.3"
|
||||
declare -r latest_210="2.10.5"
|
||||
declare -r latest_211="2.11.7"
|
||||
addJava () { vlog "[addJava] arg = '$1'" ; java_args+=("$1"); }
|
||||
addSbt () { vlog "[addSbt] arg = '$1'" ; sbt_commands+=("$1"); }
|
||||
addScalac () { vlog "[addScalac] arg = '$1'" ; scalac_args+=("$1"); }
|
||||
addResidual () { vlog "[residual] arg = '$1'" ; residual_args+=("$1"); }
|
||||
|
||||
declare -r script_path="$(get_script_path "$BASH_SOURCE")"
|
||||
declare -r script_name="${script_path##*/}"
|
||||
|
||||
# some non-read-onlies set with defaults
|
||||
declare java_cmd="java"
|
||||
declare sbt_opts_file="$(init_default_option_file SBT_OPTS .sbtopts)"
|
||||
declare jvm_opts_file="$(init_default_option_file JVM_OPTS .jvmopts)"
|
||||
declare sbt_launch_repo="http://repo.typesafe.com/typesafe/ivy-releases"
|
||||
|
||||
# pull -J and -D options to give to java.
|
||||
declare -a residual_args
|
||||
declare -a java_args
|
||||
declare -a scalac_args
|
||||
declare -a sbt_commands
|
||||
|
||||
# args to jvm/sbt via files or environment variables
|
||||
declare -a extra_jvm_opts extra_sbt_opts
|
||||
|
||||
addJava () {
|
||||
vlog "[addJava] arg = '$1'"
|
||||
java_args+=("$1")
|
||||
}
|
||||
addSbt () {
|
||||
vlog "[addSbt] arg = '$1'"
|
||||
sbt_commands+=("$1")
|
||||
}
|
||||
addResolver () { addSbt "set resolvers += $1"; }
|
||||
addDebugger () { addJava "-Xdebug" ; addJava "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$1"; }
|
||||
setThisBuild () {
|
||||
vlog "[addBuild] args = '$@'"
|
||||
local key="$1" && shift
|
||||
addSbt "set $key in ThisBuild := $@"
|
||||
}
|
||||
addScalac () {
|
||||
vlog "[addScalac] arg = '$1'"
|
||||
scalac_args+=("$1")
|
||||
}
|
||||
addResidual () {
|
||||
vlog "[residual] arg = '$1'"
|
||||
residual_args+=("$1")
|
||||
}
|
||||
addResolver () {
|
||||
addSbt "set resolvers += $1"
|
||||
}
|
||||
addDebugger () {
|
||||
addJava "-Xdebug"
|
||||
addJava "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$1"
|
||||
}
|
||||
setScalaVersion () {
|
||||
[[ "$1" == *"-SNAPSHOT" ]] && addResolver 'Resolver.sonatypeRepo("snapshots")'
|
||||
addSbt "++ $1"
|
||||
}
|
||||
setJavaHome () {
|
||||
java_cmd="$1/bin/java"
|
||||
setThisBuild javaHome "Some(file(\"$1\"))"
|
||||
setThisBuild javaHome "_root_.scala.Some(file(\"$1\"))"
|
||||
export JAVA_HOME="$1"
|
||||
export JDK_HOME="$1"
|
||||
export PATH="$JAVA_HOME/bin:$PATH"
|
||||
}
|
||||
setJavaHomeQuietly () {
|
||||
addSbt warn
|
||||
setJavaHome "$1"
|
||||
addSbt info
|
||||
|
||||
getJavaVersion() { "$1" -version 2>&1 | grep -E -e '(java|openjdk) version' | awk '{ print $3 }' | tr -d \"; }
|
||||
|
||||
checkJava() {
|
||||
# Warn if there is a Java version mismatch between PATH and JAVA_HOME/JDK_HOME
|
||||
|
||||
[[ -n "$JAVA_HOME" && -e "$JAVA_HOME/bin/java" ]] && java="$JAVA_HOME/bin/java"
|
||||
[[ -n "$JDK_HOME" && -e "$JDK_HOME/lib/tools.jar" ]] && java="$JDK_HOME/bin/java"
|
||||
|
||||
if [[ -n "$java" ]]; then
|
||||
pathJavaVersion=$(getJavaVersion java)
|
||||
homeJavaVersion=$(getJavaVersion "$java")
|
||||
if [[ "$pathJavaVersion" != "$homeJavaVersion" ]]; then
|
||||
echoerr "Warning: Java version mismatch between PATH and JAVA_HOME/JDK_HOME, sbt will use the one in PATH"
|
||||
echoerr " Either: fix your PATH, remove JAVA_HOME/JDK_HOME or use -java-home"
|
||||
echoerr " java version from PATH: $pathJavaVersion"
|
||||
echoerr " java version from JAVA_HOME/JDK_HOME: $homeJavaVersion"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# if set, use JDK_HOME/JAVA_HOME over java found in path
|
||||
if [[ -e "$JDK_HOME/lib/tools.jar" ]]; then
|
||||
setJavaHomeQuietly "$JDK_HOME"
|
||||
elif [[ -e "$JAVA_HOME/bin/java" ]]; then
|
||||
setJavaHomeQuietly "$JAVA_HOME"
|
||||
fi
|
||||
|
||||
# directory to store sbt launchers
|
||||
declare sbt_launch_dir="$HOME/.sbt/launchers"
|
||||
[[ -d "$sbt_launch_dir" ]] || mkdir -p "$sbt_launch_dir"
|
||||
[[ -w "$sbt_launch_dir" ]] || sbt_launch_dir="$(mktemp -d -t sbt_extras_launchers.XXXXXX)"
|
||||
|
||||
java_version () {
|
||||
local version=$("$java_cmd" -version 2>&1 | grep -E -e '(java|openjdk) version' | awk '{ print $3 }' | tr -d \")
|
||||
local version=$(getJavaVersion "$java_cmd")
|
||||
vlog "Detected Java version: $version"
|
||||
echo "${version:2:1}"
|
||||
}
|
||||
|
||||
# MaxPermSize critical on pre-8 jvms but incurs noisy warning on 8+
|
||||
# MaxPermSize critical on pre-8 JVMs but incurs noisy warning on 8+
|
||||
default_jvm_opts () {
|
||||
local v="$(java_version)"
|
||||
if [[ $v -ge 8 ]]; then
|
||||
|
@ -222,16 +231,23 @@ execRunner () {
|
|||
vlog ""
|
||||
}
|
||||
|
||||
[[ -n "$batch" ]] && exec </dev/null
|
||||
exec "$@"
|
||||
setTrapExit
|
||||
|
||||
if [[ -n "$batch" ]]; then
|
||||
"$@" < /dev/null
|
||||
else
|
||||
"$@"
|
||||
fi
|
||||
}
|
||||
|
||||
jar_url () {
|
||||
make_url "$1"
|
||||
}
|
||||
jar_url () { make_url "$1"; }
|
||||
|
||||
is_cygwin () [[ "$(uname -a)" == "CYGWIN"* ]]
|
||||
|
||||
jar_file () {
|
||||
echo "$sbt_launch_dir/$1/sbt-launch.jar"
|
||||
is_cygwin \
|
||||
&& echo "$(cygpath -w $sbt_launch_dir/"$1"/sbt-launch.jar)" \
|
||||
|| echo "$sbt_launch_dir/$1/sbt-launch.jar"
|
||||
}
|
||||
|
||||
download_url () {
|
||||
|
@ -246,19 +262,26 @@ download_url () {
|
|||
if which curl >/dev/null; then
|
||||
curl --fail --silent --location "$url" --output "$jar"
|
||||
elif which wget >/dev/null; then
|
||||
wget --quiet -O "$jar" "$url"
|
||||
wget -q -O "$jar" "$url"
|
||||
fi
|
||||
} && [[ -r "$jar" ]]
|
||||
}
|
||||
|
||||
acquire_sbt_jar () {
|
||||
sbt_url="$(jar_url "$sbt_version")"
|
||||
sbt_jar="$(jar_file "$sbt_version")"
|
||||
|
||||
[[ -r "$sbt_jar" ]] || download_url "$sbt_url" "$sbt_jar"
|
||||
{
|
||||
sbt_jar="$(jar_file "$sbt_version")"
|
||||
[[ -r "$sbt_jar" ]]
|
||||
} || {
|
||||
sbt_jar="$HOME/.ivy2/local/org.scala-sbt/sbt-launch/$sbt_version/jars/sbt-launch.jar"
|
||||
[[ -r "$sbt_jar" ]]
|
||||
} || {
|
||||
sbt_jar="$(jar_file "$sbt_version")"
|
||||
download_url "$(make_url "$sbt_version")" "$sbt_jar"
|
||||
}
|
||||
}
|
||||
|
||||
usage () {
|
||||
set_sbt_version
|
||||
cat <<EOM
|
||||
Usage: $script_name [options]
|
||||
|
||||
|
@ -289,20 +312,23 @@ runner with the -x option.
|
|||
-jvm-debug <port> Turn on JVM debugging, open at the given port.
|
||||
-batch Disable interactive mode
|
||||
-prompt <expr> Set the sbt prompt; in expr, 's' is the State and 'e' is Extracted
|
||||
-script <file> Run the specified file as a scala script
|
||||
|
||||
# sbt version (default: sbt.version from $buildProps if present, otherwise $sbt_release_version)
|
||||
-sbt-force-latest force the use of the latest release of sbt: $sbt_release_version
|
||||
-sbt-version <version> use the specified version of sbt (default: $sbt_release_version)
|
||||
-sbt-dev use the latest pre-release version of sbt: $sbt_unreleased_version
|
||||
-sbt-jar <path> use the specified jar as the sbt launcher
|
||||
-sbt-launch-dir <path> directory to hold sbt launchers (default: ~/.sbt/launchers)
|
||||
-sbt-launch-repo <url> repo url for downloading sbt launcher jar (default: $sbt_launch_repo)
|
||||
-sbt-launch-dir <path> directory to hold sbt launchers (default: $sbt_launch_dir)
|
||||
-sbt-launch-repo <url> repo url for downloading sbt launcher jar (default: $(url_base "$sbt_version"))
|
||||
|
||||
# scala version (default: as chosen by sbt)
|
||||
-28 use $latest_28
|
||||
-29 use $latest_29
|
||||
-210 use $latest_210
|
||||
-211 use $latest_211
|
||||
-212 use $latest_212
|
||||
-213 use $latest_213
|
||||
-scala-home <path> use the scala build at the specified directory
|
||||
-scala-version <version> use the specified version of scala
|
||||
-binary-version <version> use the specified scala version when searching for dependencies
|
||||
|
@ -329,8 +355,7 @@ runner with the -x option.
|
|||
EOM
|
||||
}
|
||||
|
||||
process_args ()
|
||||
{
|
||||
process_args () {
|
||||
require_arg () {
|
||||
local type="$1"
|
||||
local opt="$2"
|
||||
|
@ -342,11 +367,11 @@ process_args ()
|
|||
}
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
-h|-help) usage; exit 1 ;;
|
||||
-h|-help) usage; exit 0 ;;
|
||||
-v) verbose=true && shift ;;
|
||||
-d) addSbt "--debug" && addSbt debug && shift ;;
|
||||
-w) addSbt "--warn" && addSbt warn && shift ;;
|
||||
-q) addSbt "--error" && addSbt error && shift ;;
|
||||
-d) addSbt "--debug" && shift ;;
|
||||
-w) addSbt "--warn" && shift ;;
|
||||
-q) addSbt "--error" && shift ;;
|
||||
-x) debugUs=true && shift ;;
|
||||
-trace) require_arg integer "$1" "$2" && trace_level="$2" && shift 2 ;;
|
||||
-ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;;
|
||||
|
@ -355,10 +380,11 @@ process_args ()
|
|||
-sbt-boot) require_arg path "$1" "$2" && addJava "-Dsbt.boot.directory=$2" && shift 2 ;;
|
||||
-sbt-dir) require_arg path "$1" "$2" && sbt_dir="$2" && shift 2 ;;
|
||||
-debug-inc) addJava "-Dxsbt.inc.debug=true" && shift ;;
|
||||
-offline) addSbt "set offline := true" && shift ;;
|
||||
-offline) addSbt "set offline in Global := true" && shift ;;
|
||||
-jvm-debug) require_arg port "$1" "$2" && addDebugger "$2" && shift 2 ;;
|
||||
-batch) batch=true && shift ;;
|
||||
-prompt) require_arg "expr" "$1" "$2" && setThisBuild shellPrompt "(s => { val e = Project.extract(s) ; $2 })" && shift 2 ;;
|
||||
-script) require_arg file "$1" "$2" && sbt_script="$2" && addJava "-Dsbt.main.class=sbt.ScriptMain" && shift 2 ;;
|
||||
|
||||
-sbt-create) sbt_create=true && shift ;;
|
||||
-sbt-jar) require_arg path "$1" "$2" && sbt_jar="$2" && shift 2 ;;
|
||||
|
@ -369,7 +395,7 @@ process_args ()
|
|||
-sbt-launch-repo) require_arg path "$1" "$2" && sbt_launch_repo="$2" && shift 2 ;;
|
||||
-scala-version) require_arg version "$1" "$2" && setScalaVersion "$2" && shift 2 ;;
|
||||
-binary-version) require_arg version "$1" "$2" && setThisBuild scalaBinaryVersion "\"$2\"" && shift 2 ;;
|
||||
-scala-home) require_arg path "$1" "$2" && setThisBuild scalaHome "Some(file(\"$2\"))" && shift 2 ;;
|
||||
-scala-home) require_arg path "$1" "$2" && setThisBuild scalaHome "_root_.scala.Some(file(\"$2\"))" && shift 2 ;;
|
||||
-java-home) require_arg path "$1" "$2" && setJavaHome "$2" && shift 2 ;;
|
||||
-sbt-opts) require_arg path "$1" "$2" && sbt_opts_file="$2" && shift 2 ;;
|
||||
-jvm-opts) require_arg path "$1" "$2" && jvm_opts_file="$2" && shift 2 ;;
|
||||
|
@ -381,10 +407,9 @@ process_args ()
|
|||
-29) setScalaVersion "$latest_29" && shift ;;
|
||||
-210) setScalaVersion "$latest_210" && shift ;;
|
||||
-211) setScalaVersion "$latest_211" && shift ;;
|
||||
|
||||
--debug) addSbt debug && addResidual "$1" && shift ;;
|
||||
--warn) addSbt warn && addResidual "$1" && shift ;;
|
||||
--error) addSbt error && addResidual "$1" && shift ;;
|
||||
-212) setScalaVersion "$latest_212" && shift ;;
|
||||
-213) setScalaVersion "$latest_213" && shift ;;
|
||||
new) sbt_new=true && : ${sbt_explicit_version:=$sbt_release_version} && addResidual "$1" && shift ;;
|
||||
*) addResidual "$1" && shift ;;
|
||||
esac
|
||||
done
|
||||
|
@ -395,8 +420,10 @@ process_args "$@"
|
|||
|
||||
# skip #-styled comments and blank lines
|
||||
readConfigFile() {
|
||||
while read line; do
|
||||
[[ $line =~ ^# ]] || [[ -z $line ]] || echo "$line"
|
||||
local end=false
|
||||
until $end; do
|
||||
read || end=true
|
||||
[[ $REPLY =~ ^# ]] || [[ -z $REPLY ]] || echo "$REPLY"
|
||||
done < "$1"
|
||||
}
|
||||
|
||||
|
@ -421,6 +448,8 @@ argumentCount=$#
|
|||
# set sbt version
|
||||
set_sbt_version
|
||||
|
||||
checkJava
|
||||
|
||||
# only exists in 0.12+
|
||||
setTraceLevel() {
|
||||
case "$sbt_version" in
|
||||
|
@ -433,19 +462,21 @@ setTraceLevel() {
|
|||
[[ ${#scalac_args[@]} -eq 0 ]] || addSbt "set scalacOptions in ThisBuild += \"${scalac_args[@]}\""
|
||||
|
||||
# Update build.properties on disk to set explicit version - sbt gives us no choice
|
||||
[[ -n "$sbt_explicit_version" ]] && update_build_props_sbt "$sbt_explicit_version"
|
||||
[[ -n "$sbt_explicit_version" && -z "$sbt_new" ]] && update_build_props_sbt "$sbt_explicit_version"
|
||||
vlog "Detected sbt version $sbt_version"
|
||||
|
||||
[[ -n "$scala_version" ]] && vlog "Overriding scala version to $scala_version"
|
||||
if [[ -n "$sbt_script" ]]; then
|
||||
residual_args=( $sbt_script ${residual_args[@]} )
|
||||
else
|
||||
# no args - alert them there's stuff in here
|
||||
(( argumentCount > 0 )) || {
|
||||
vlog "Starting $script_name: invoke with -help for other options"
|
||||
residual_args=( shell )
|
||||
}
|
||||
fi
|
||||
|
||||
# no args - alert them there's stuff in here
|
||||
(( argumentCount > 0 )) || {
|
||||
vlog "Starting $script_name: invoke with -help for other options"
|
||||
residual_args=( shell )
|
||||
}
|
||||
|
||||
# verify this is an sbt dir or -create was given
|
||||
[[ -r ./build.sbt || -d ./project || -n "$sbt_create" ]] || {
|
||||
# verify this is an sbt dir, -create was given or user attempts to run a scala script
|
||||
[[ -r ./build.sbt || -d ./project || -n "$sbt_create" || -n "$sbt_script" || -n "$sbt_new" ]] || {
|
||||
cat <<EOM
|
||||
$(pwd) doesn't appear to be an sbt project.
|
||||
If you want to start sbt anyway, run:
|
||||
|
@ -458,6 +489,10 @@ EOM
|
|||
# pick up completion if present; todo
|
||||
[[ -r .sbt_completion.sh ]] && source .sbt_completion.sh
|
||||
|
||||
# directory to store sbt launchers
|
||||
[[ -d "$sbt_launch_dir" ]] || mkdir -p "$sbt_launch_dir"
|
||||
[[ -w "$sbt_launch_dir" ]] || sbt_launch_dir="$(mktemp -d -t sbt_extras_launchers.XXXXXX)"
|
||||
|
||||
# no jar? download it.
|
||||
[[ -r "$sbt_jar" ]] || acquire_sbt_jar || {
|
||||
# still no jar? uh-oh.
|
||||
|
@ -519,8 +554,8 @@ mainFiltered () {
|
|||
|
||||
echoLine () {
|
||||
local line="$1"
|
||||
local line1="$(echo "$line" | sed -r 's/\r\x1BM\x1B\[2K//g')" # This strips the OverwriteLine code.
|
||||
local line2="$(echo "$line1" | sed -r 's/\x1B\[[0-9;]*[JKmsu]//g')" # This strips all codes - we test regexes against this.
|
||||
local line1="$(echo "$line" | sed 's/\r\x1BM\x1B\[2K//g')" # This strips the OverwriteLine code.
|
||||
local line2="$(echo "$line1" | sed 's/\x1B\[[0-9;]*[JKmsu]//g')" # This strips all codes - we test regexes against this.
|
||||
|
||||
if [[ $line2 =~ $excludeRegex ]]; then
|
||||
[[ -n $debugUs ]] && echo "[X] $line1"
|
||||
|
|
Loading…
Reference in New Issue