Skip to content

Commit 6510d23

Browse files
Removed unneccessary scripts and replaced some of them with tmuxinator
1 parent 24f88b2 commit 6510d23

9 files changed

+141
-188
lines changed

.tmuxinator.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: catnip
2+
root: .
3+
4+
# Optional tmux socket
5+
socket_name: catnip
6+
7+
# Note that the pre and post options have been deprecated and will be replaced by
8+
# project hooks.
9+
10+
# Project hooks
11+
# Runs on project start, always
12+
# on_project_start: command
13+
# Run on project start, the first time
14+
# on_project_first_start: command
15+
# Run on project start, after the first time
16+
# on_project_restart: command
17+
# Run on project exit ( detaching from tmux session )
18+
# on_project_exit: command
19+
# Run on project stop
20+
# on_project_stop: command
21+
22+
# Runs in each window and pane before window/pane specific commands. Useful for setting up interpreter versions.
23+
pre_window:
24+
- export JVM_OPTS="-Xms2G -Xss5m"
25+
- alias sbt=$PWD/sbt
26+
27+
# Pass command line options to tmux. Useful for specifying a different tmux.conf.
28+
# tmux_options: -f ~/.tmux.mac.conf
29+
30+
# Change the command to call tmux. This can be used by derivatives/wrappers like byobu.
31+
# tmux_command: byobu
32+
33+
# Specifies (by name or index) which window will be selected on project startup. If not set, the first window is used.
34+
# startup_window: common
35+
36+
# Specifies (by index) which pane of the specified window will be selected on project startup. If not set, the first pane is used.
37+
# startup_pane: 1
38+
39+
# Controls whether the tmux session should be attached to automatically. Defaults to true.
40+
# attach: false
41+
42+
windows:
43+
- catnip:
44+
root: .
45+
layout: main-horizontal
46+
panes:
47+
- sbt
48+
- git status

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ install:
1313
- sudo apt-get update
1414
- sudo apt-get install zsh
1515
- sudo chmod +x scripts/*
16-
- scripts/sbt update
17-
script: scripts/run-all-tests.sh
16+
- ./sbt update
17+
script: ./sbt fullCoverageTest
1818
after_script:
1919
- scripts/prepare-test-results-for-ci.sh
2020
- find $HOME/.sbt -name "*.lock" | xargs rm

project/build.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.3.0-RC2
1+
sbt.version=1.3.0-RC3

scripts/sbt sbt

+90-44
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66

77
set -o pipefail
88

9-
declare -r sbt_release_version="0.13.17"
10-
declare -r sbt_unreleased_version="0.13.17"
9+
declare -r sbt_release_version="1.2.8"
10+
declare -r sbt_unreleased_version="1.3.0-RC1"
1111

12-
declare -r latest_213="2.13.0-M5"
13-
declare -r latest_212="2.12.7"
12+
declare -r latest_213="2.13.0"
13+
declare -r latest_212="2.12.9"
1414
declare -r latest_211="2.11.12"
1515
declare -r latest_210="2.10.7"
1616
declare -r latest_29="2.9.3"
1717
declare -r latest_28="2.8.2"
1818

1919
declare -r buildProps="project/build.properties"
2020

21-
declare -r sbt_launch_ivy_release_repo="http://repo.typesafe.com/typesafe/ivy-releases"
21+
declare -r sbt_launch_ivy_release_repo="https://repo.typesafe.com/typesafe/ivy-releases"
2222
declare -r sbt_launch_ivy_snapshot_repo="https://repo.scala-sbt.org/scalasbt/ivy-snapshots"
23-
declare -r sbt_launch_mvn_release_repo="http://repo.scala-sbt.org/scalasbt/maven-releases"
24-
declare -r sbt_launch_mvn_snapshot_repo="http://repo.scala-sbt.org/scalasbt/maven-snapshots"
23+
declare -r sbt_launch_mvn_release_repo="https://repo.scala-sbt.org/scalasbt/maven-releases"
24+
declare -r sbt_launch_mvn_snapshot_repo="https://repo.scala-sbt.org/scalasbt/maven-snapshots"
2525

2626
declare -r default_jvm_opts_common="-Xms512m -Xss2m"
2727
declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy"
@@ -43,11 +43,12 @@ declare -a extra_jvm_opts extra_sbt_opts
4343

4444
echoerr () { echo >&2 "$@"; }
4545
vlog () { [[ -n "$verbose" ]] && echoerr "$@"; }
46-
die () { echo "Aborting: $@" ; exit 1; }
46+
die () { echo "Aborting: $*" ; exit 1; }
4747

4848
setTrapExit () {
4949
# save stty and trap exit, to ensure echo is re-enabled if we are interrupted.
50-
export SBT_STTY="$(stty -g 2>/dev/null)"
50+
SBT_STTY="$(stty -g 2>/dev/null)"
51+
export SBT_STTY
5152

5253
# restore stty settings (echo in particular)
5354
onSbtRunnerExit() {
@@ -67,16 +68,18 @@ get_script_path () {
6768
local path="$1"
6869
[[ -L "$path" ]] || { echo "$path" ; return; }
6970

70-
local target="$(readlink "$path")"
71+
local -r target="$(readlink "$path")"
7172
if [[ "${target:0:1}" == "/" ]]; then
7273
echo "$target"
7374
else
7475
echo "${path%/*}/$target"
7576
fi
7677
}
7778

78-
declare -r script_path="$(get_script_path "$BASH_SOURCE")"
79-
declare -r script_name="${script_path##*/}"
79+
script_path="$(get_script_path "${BASH_SOURCE[0]}")"
80+
declare -r script_path
81+
script_name="${script_path##*/}"
82+
declare -r script_name
8083

8184
init_default_option_file () {
8285
local overriding_var="${!1}"
@@ -90,8 +93,8 @@ init_default_option_file () {
9093
echo "$default_file"
9194
}
9295

93-
declare sbt_opts_file="$(init_default_option_file SBT_OPTS .sbtopts)"
94-
declare jvm_opts_file="$(init_default_option_file JVM_OPTS .jvmopts)"
96+
sbt_opts_file="$(init_default_option_file SBT_OPTS .sbtopts)"
97+
jvm_opts_file="$(init_default_option_file JVM_OPTS .jvmopts)"
9598

9699
build_props_sbt () {
97100
[[ -r "$buildProps" ]] && \
@@ -108,7 +111,7 @@ url_base () {
108111
local version="$1"
109112

110113
case "$version" in
111-
0.7.*) echo "http://simple-build-tool.googlecode.com" ;;
114+
0.7.*) echo "https://simple-build-tool.googlecode.com" ;;
112115
0.10.* ) echo "$sbt_launch_ivy_release_repo" ;;
113116
0.11.[12]) echo "$sbt_launch_ivy_release_repo" ;;
114117
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"
@@ -130,7 +133,7 @@ make_url () {
130133
0.10.* ) echo "$base/org.scala-tools.sbt/sbt-launch/$version/sbt-launch.jar" ;;
131134
0.11.[12]) echo "$base/org.scala-tools.sbt/sbt-launch/$version/sbt-launch.jar" ;;
132135
0.*) echo "$base/org.scala-sbt/sbt-launch/$version/sbt-launch.jar" ;;
133-
*) echo "$base/org/scala-sbt/sbt-launch/$version/sbt-launch.jar" ;;
136+
*) echo "$base/org/scala-sbt/sbt-launch/$version/sbt-launch-${version}.jar" ;;
134137
esac
135138
}
136139

@@ -142,9 +145,9 @@ addResidual () { vlog "[residual] arg = '$1'" ; residual_args+=("$1"); }
142145
addResolver () { addSbt "set resolvers += $1"; }
143146
addDebugger () { addJava "-Xdebug" ; addJava "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$1"; }
144147
setThisBuild () {
145-
vlog "[addBuild] args = '$@'"
148+
vlog "[addBuild] args = '$*'"
146149
local key="$1" && shift
147-
addSbt "set $key in ThisBuild := $@"
150+
addSbt "set $key in ThisBuild := $*"
148151
}
149152
setScalaVersion () {
150153
[[ "$1" == *"-SNAPSHOT" ]] && addResolver 'Resolver.sonatypeRepo("snapshots")'
@@ -159,7 +162,7 @@ setJavaHome () {
159162
}
160163

161164
getJavaVersion() {
162-
local str=$("$1" -version 2>&1 | grep -E -e '(java|openjdk) version' | awk '{ print $3 }' | tr -d '"')
165+
local -r str=$("$1" -version 2>&1 | grep -E -e '(java|openjdk) version' | awk '{ print $3 }' | tr -d '"')
163166

164167
# java -version on java8 says 1.8.x
165168
# but on 9 and 10 it's 9.x.y and 10.x.y.
@@ -191,14 +194,14 @@ checkJava() {
191194
}
192195

193196
java_version () {
194-
local version=$(getJavaVersion "$java_cmd")
197+
local -r version=$(getJavaVersion "$java_cmd")
195198
vlog "Detected Java version: $version"
196199
echo "$version"
197200
}
198201

199202
# MaxPermSize critical on pre-8 JVMs but incurs noisy warning on 8+
200203
default_jvm_opts () {
201-
local v="$(java_version)"
204+
local -r v="$(java_version)"
202205
if [[ $v -ge 8 ]]; then
203206
echo "$default_jvm_opts_common"
204207
else
@@ -240,22 +243,18 @@ execRunner () {
240243

241244
jar_url () { make_url "$1"; }
242245

243-
is_cygwin () [[ "$(uname -a)" == "CYGWIN"* ]]
246+
is_cygwin () { [[ "$(uname -a)" == "CYGWIN"* ]]; }
244247

245248
jar_file () {
246249
is_cygwin \
247-
&& echo "$(cygpath -w $sbt_launch_dir/"$1"/sbt-launch.jar)" \
250+
&& cygpath -w "$sbt_launch_dir/$1/sbt-launch.jar" \
248251
|| echo "$sbt_launch_dir/$1/sbt-launch.jar"
249252
}
250253

251254
download_url () {
252255
local url="$1"
253256
local jar="$2"
254257

255-
echoerr "Downloading sbt launcher for $sbt_version:"
256-
echoerr " From $url"
257-
echoerr " To $jar"
258-
259258
mkdir -p "${jar%/*}" && {
260259
if command -v curl > /dev/null 2>&1; then
261260
curl --fail --silent --location "$url" --output "$jar"
@@ -274,10 +273,57 @@ acquire_sbt_jar () {
274273
[[ -r "$sbt_jar" ]]
275274
} || {
276275
sbt_jar="$(jar_file "$sbt_version")"
277-
download_url "$(make_url "$sbt_version")" "$sbt_jar"
276+
jar_url="$(make_url "$sbt_version")"
277+
278+
echoerr "Downloading sbt launcher for ${sbt_version}:"
279+
echoerr " From ${jar_url}"
280+
echoerr " To ${sbt_jar}"
281+
282+
download_url "${jar_url}" "${sbt_jar}"
283+
284+
case "${sbt_version}" in
285+
0.*) vlog "SBT versions < 1.0 do not have published MD5 checksums, skipping check"; echo "" ;;
286+
*) verify_sbt_jar "${sbt_jar}" ;;
287+
esac
278288
}
279289
}
280290

291+
verify_sbt_jar() {
292+
local jar="${1}"
293+
local md5="${jar}.md5"
294+
295+
download_url "$(make_url "${sbt_version}").md5" "${md5}" > /dev/null 2>&1
296+
297+
if command -v md5sum > /dev/null 2>&1; then
298+
if echo "$(cat "${md5}") ${jar}" | md5sum -c -; then
299+
rm -rf "${md5}"
300+
return 0
301+
else
302+
echoerr "Checksum does not match"
303+
return 1
304+
fi
305+
elif command -v md5 > /dev/null 2>&1; then
306+
if [ "$(md5 -q "${jar}")" == "$(cat "${md5}")" ]; then
307+
rm -rf "${md5}"
308+
return 0
309+
else
310+
echoerr "Checksum does not match"
311+
return 1
312+
fi
313+
elif command -v openssl > /dev/null 2>&1; then
314+
if [ "$(openssl md5 -r "${jar}" | awk '{print $1}')" == "$(cat "${md5}")" ]; then
315+
rm -rf "${md5}"
316+
return 0
317+
else
318+
echoerr "Checksum does not match"
319+
return 1
320+
fi
321+
else
322+
echoerr "Could not find an MD5 command"
323+
return 1
324+
fi
325+
}
326+
281327
usage () {
282328
set_sbt_version
283329
cat <<EOM
@@ -420,7 +466,7 @@ process_args "$@"
420466
readConfigFile() {
421467
local end=false
422468
until $end; do
423-
read || end=true
469+
read -r || end=true
424470
[[ $REPLY =~ ^# ]] || [[ -z $REPLY ]] || echo "$REPLY"
425471
done < "$1"
426472
}
@@ -429,10 +475,10 @@ readConfigFile() {
429475
# can supply args to this runner
430476
if [[ -r "$sbt_opts_file" ]]; then
431477
vlog "Using sbt options defined in file $sbt_opts_file"
432-
while read opt; do extra_sbt_opts+=("$opt"); done < <(readConfigFile "$sbt_opts_file")
478+
while read -r opt; do extra_sbt_opts+=("$opt"); done < <(readConfigFile "$sbt_opts_file")
433479
elif [[ -n "$SBT_OPTS" && ! ("$SBT_OPTS" =~ ^@.*) ]]; then
434480
vlog "Using sbt options defined in variable \$SBT_OPTS"
435-
extra_sbt_opts=( $SBT_OPTS )
481+
IFS=" " read -r -a extra_sbt_opts <<< "$SBT_OPTS"
436482
else
437483
vlog "No extra sbt options have been defined"
438484
fi
@@ -452,18 +498,18 @@ checkJava
452498
setTraceLevel() {
453499
case "$sbt_version" in
454500
"0.7."* | "0.10."* | "0.11."* ) echoerr "Cannot set trace level in sbt version $sbt_version" ;;
455-
*) setThisBuild traceLevel $trace_level ;;
501+
*) setThisBuild traceLevel "$trace_level" ;;
456502
esac
457503
}
458504

459505
# set scalacOptions if we were given any -S opts
460-
[[ ${#scalac_args[@]} -eq 0 ]] || addSbt "set scalacOptions in ThisBuild += \"${scalac_args[@]}\""
506+
[[ ${#scalac_args[@]} -eq 0 ]] || addSbt "set scalacOptions in ThisBuild += \"${scalac_args[*]}\""
461507

462508
[[ -n "$sbt_explicit_version" && -z "$sbt_new" ]] && addJava "-Dsbt.version=$sbt_explicit_version"
463509
vlog "Detected sbt version $sbt_version"
464510

465511
if [[ -n "$sbt_script" ]]; then
466-
residual_args=( $sbt_script ${residual_args[@]} )
512+
residual_args=( "$sbt_script" "${residual_args[@]}" )
467513
else
468514
# no args - alert them there's stuff in here
469515
(( argumentCount > 0 )) || {
@@ -484,6 +530,7 @@ EOM
484530
}
485531

486532
# pick up completion if present; todo
533+
# shellcheck disable=SC1091
487534
[[ -r .sbt_completion.sh ]] && source .sbt_completion.sh
488535

489536
# directory to store sbt launchers
@@ -493,7 +540,7 @@ EOM
493540
# no jar? download it.
494541
[[ -r "$sbt_jar" ]] || acquire_sbt_jar || {
495542
# still no jar? uh-oh.
496-
echo "Download failed. Obtain the jar manually and place it at $sbt_jar"
543+
echo "Could not download and verify the launcher. Obtain the jar manually and place it at $sbt_jar"
497544
exit 1
498545
}
499546

@@ -518,13 +565,13 @@ fi
518565

519566
if [[ -r "$jvm_opts_file" ]]; then
520567
vlog "Using jvm options defined in file $jvm_opts_file"
521-
while read opt; do extra_jvm_opts+=("$opt"); done < <(readConfigFile "$jvm_opts_file")
568+
while read -r opt; do extra_jvm_opts+=("$opt"); done < <(readConfigFile "$jvm_opts_file")
522569
elif [[ -n "$JVM_OPTS" && ! ("$JVM_OPTS" =~ ^@.*) ]]; then
523570
vlog "Using jvm options defined in \$JVM_OPTS variable"
524-
extra_jvm_opts=( $JVM_OPTS )
571+
IFS=" " read -r -a extra_jvm_opts <<< "$JVM_OPTS"
525572
else
526573
vlog "Using default jvm options"
527-
extra_jvm_opts=( $(default_jvm_opts) )
574+
IFS=" " read -r -a extra_jvm_opts <<< "$(default_jvm_opts)"
528575
fi
529576

530577
# traceLevel is 0.12+
@@ -546,13 +593,12 @@ main () {
546593
# we're not going to print those lines anyway. We strip that bit of
547594
# line noise, but leave the other codes to preserve color.
548595
mainFiltered () {
549-
local ansiOverwrite='\r\x1BM\x1B[2K'
550-
local excludeRegex=$(egrep -v '^#|^$' ~/.sbtignore | paste -sd'|' -)
596+
local -r excludeRegex=$(grep -E -v '^#|^$' ~/.sbtignore | paste -sd'|' -)
551597

552598
echoLine () {
553-
local line="$1"
554-
local line1="$(echo "$line" | sed 's/\r\x1BM\x1B\[2K//g')" # This strips the OverwriteLine code.
555-
local line2="$(echo "$line1" | sed 's/\x1B\[[0-9;]*[JKmsu]//g')" # This strips all codes - we test regexes against this.
599+
local -r line="$1"
600+
local -r line1="${line//\r\x1BM\x1B\[2K//g}" # This strips the OverwriteLine code.
601+
local -r line2="${line1//\x1B\[[0-9;]*[JKmsu]//g}" # This strips all codes - we test regexes against this.
556602

557603
if [[ $line2 =~ $excludeRegex ]]; then
558604
[[ -n $debugUs ]] && echo "[X] $line1"
@@ -569,7 +615,7 @@ mainFiltered () {
569615
# Obviously this is super ad hoc but I don't know how to improve on it. Testing whether
570616
# stdin is a terminal is useless because most of my use cases for this filtering are
571617
# exactly when I'm at a terminal, running sbt non-interactively.
572-
shouldFilter () { [[ -f ~/.sbtignore ]] && ! egrep -q '\b(shell|console|consoleProject)\b' <<<"${residual_args[@]}"; }
618+
shouldFilter () { [[ -f ~/.sbtignore ]] && ! grep -E -q '\b(shell|console|consoleProject)\b' <<<"${residual_args[@]}"; }
573619

574620
# run sbt
575621
if shouldFilter; then mainFiltered; else main; fi

scripts/.common.sh

-8
This file was deleted.

scripts/.sbt-helpers.sh

-3
This file was deleted.

0 commit comments

Comments
 (0)