Skip to content

Instantly share code, notes, and snippets.

@jianwu
Last active September 18, 2024 12:20
Show Gist options
  • 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