1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-12-29 15:47:57 +01:00
Smack/repl

49 lines
1.1 KiB
Text
Raw Normal View History

2016-02-10 14:09:13 +01:00
#!/usr/bin/env bash
set -e
set -u
set -o pipefail
JDWP=false
JDWP_PORT=8000
2016-06-06 11:05:05 +02:00
while getopts djp: OPTION "$@"; do
2016-02-10 14:09:13 +01:00
case $OPTION in
d)
set -x
;;
j)
JDWP=true
;;
p)
JDWP_PORT=$OPTARG
;;
2016-02-10 14:09:13 +01:00
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
2016-06-06 11:05:05 +02:00
PROJECT_ROOT=$(dirname "${BASH_SOURCE[0]}")
cd "${PROJECT_ROOT}"
2016-02-10 14:09:13 +01:00
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
2016-06-06 11:05:05 +02:00
GRADLE_CLASSPATH="$(gradle :smack-repl:printClasspath --quiet |\
2016-02-10 14:09:13 +01:00
tail -n1)"
echo "Finished, starting REPL"
java "${EXTRA_JAVA_ARGS[@]}" \
2016-02-10 14:09:13 +01:00
-Dscala.usejavacp=true \
-classpath "${GRADLE_CLASSPATH}" \
2016-12-08 08:29:36 +01:00
ammonite.Main \
2018-10-27 15:40:50 +02:00
--predef "smack-repl/scala.repl"