-
Notifications
You must be signed in to change notification settings - Fork 887
/
repl
executable file
·47 lines (41 loc) · 1.15 KB
/
repl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
set -euo pipefail
JDWP=false
JDWP_PORT=8000
while getopts djp: OPTION "$@"; do
case $OPTION in
d)
set -x
;;
j)
JDWP=true
;;
p)
JDWP_PORT=$OPTARG
;;
esac
done
EXTRA_JAVA_ARGS=()
if $JDWP; then
EXTRA_JAVA_ARGS+=("-Xdebug")
EXTRA_JAVA_ARGS+=("-Xrunjdwp:server=y,transport=dt_socket,address=${JDWP_PORT},suspend=n")
fi
PROJECT_ROOT=$(dirname "${BASH_SOURCE[0]}")
cd "${PROJECT_ROOT}"
echo "Compiling and computing classpath (May take a while)"
# Sadly even with the --quiet option Gradle (or some component of)
# will print the number of warnings/errors to stdout if there are
# any. So the result could look like
# 52 warnings\n1 warning\n12 warnings\n
# /smack/smack-repl/build/classes/main:/smack/smack-repl/build/
# resources/main:/smack/smack-tcp/build/libs/smack-tcp-4.2.0-alpha4-SNAPSHOT.jar
# So perform a "tail -n1" on the output of gradle
GRADLE_CLASSPATH="$(${GRADLE_BIN:-./gradlew} :smack-repl:printClasspath --quiet |\
tail -n1)"
echo "Finished, starting REPL"
exec java \
"${EXTRA_JAVA_ARGS[@]}" \
-Dscala.usejavacp=true \
-classpath "${GRADLE_CLASSPATH}" \
ammonite.Main \
--predef smack-repl/scala.repl