Skip to content

Instantly share code, notes, and snippets.

@jianwu
Last active October 27, 2021 12:50
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jianwu/9b36a3c9b47edd9c2304ccbf9ace081b to your computer and use it in GitHub Desktop.
Save jianwu/9b36a3c9b47edd9c2304ccbf9ace081b to your computer and use it in GitHub Desktop.
mshell: to run jshell for a maven project with all the dependancies injected.
# Run this script from the maven module directory to start a jshell with
# all dependent class paths injected.
# Please never run it on the parent maven project directory.
# It depends on java9 or above
if [ ! -d "target" ]; then
echo "Please run it under a module directory. And make sure it's not parent module directory. And make a maven install first"
exit
fi
mvn dependency:build-classpath -DincludeTypes=jar -Dmdep.outputFile=.cp.tmp
jshell --class-path `cat .cp.tmp`:target/classes "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment