Skip to content

Commit

Permalink
repl: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Flowdalic committed Oct 19, 2024
1 parent bcaf379 commit 020e232
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions repl
Original file line number Diff line number Diff line change
@@ -1,29 +1,46 @@
#!/usr/bin/env bash
set -e
set -u
set -o pipefail
set -euo pipefail

while getopts d OPTION "$@"; do
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.
GRADLE_CLASSPATH="$(gradle :minidns-repl:printClasspath --quiet |\
# 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} :minidns-repl:printClasspath --quiet |\
tail -n1)"
echo "Classpath computed, starting REPL"
echo "Finished, starting REPL"

java \
-ea \
exec java \
"${EXTRA_JAVA_ARGS[@]}" \
-Dscala.usejavacp=true \
-classpath "${GRADLE_CLASSPATH}" \
ammonite.Main \
Expand Down

0 comments on commit 020e232

Please sign in to comment.