You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.1KB

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