Skip to content

Commit f13589a

Browse files
committed
Pass JVM options to app directly.
1 parent 9de3905 commit f13589a

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

dist/bin/dotr

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,41 @@ if [ -z "$PROG_HOME" ] ; then
2727
cd "$saveddir"
2828
fi
2929

30+
addJvmOptions () {
31+
jvm_options+=("$1")
32+
}
33+
3034
source "$PROG_HOME/bin/common"
3135

3236
declare -a residual_args
33-
run_repl=false
37+
execute_repl=false
38+
execute_run=false
39+
class_path_count=0
3440
CLASS_PATH=""
3541

3642
while [[ $# -gt 0 ]]; do
3743
case "$1" in
3844
-repl)
39-
run_repl=true
45+
execute_repl=true
46+
shift
47+
;;
48+
-run)
49+
execute_run=true
4050
shift
4151
;;
4252
-classpath)
4353
CLASS_PATH="$2"
54+
class_path_count+=1
4455
shift
4556
shift
4657
;;
4758
-d)
4859
DEBUG="$DEBUG_STR"
4960
shift
5061
;;
62+
-J*)
63+
addJvmOptions "${1:2}"
64+
shift ;;
5165
*)
5266
residual_args+=("$1")
5367
shift
@@ -56,18 +70,23 @@ while [[ $# -gt 0 ]]; do
5670
esac
5771
done
5872

59-
if [ $run_repl == true ] || [ ${#residual_args[@]} -eq 0 ]; then
73+
if [ $execute_repl == true ] || ([ $execute_run == false ] && [ ${#residual_args[@]} -eq 0 ]); then
6074
if [ "$CLASS_PATH" ]; then
6175
cp_arg="-classpath \"$CLASS_PATH\""
6276
fi
6377
echo "Starting dotty REPL..."
6478
eval "\"$PROG_HOME/bin/dotc\" $cp_arg -repl ${residual_args[@]}"
65-
else
79+
elif [ $execute_repl == true ] || [ ${#residual_args[@]} -ne 0 ]; then
6680
cp_arg="$DOTTY_LIB$PSEP$SCALA_LIB"
6781
if [ -z "$CLASS_PATH" ]; then
6882
cp_arg+="$PSEP."
6983
else
7084
cp_arg+="$PSEP$CLASS_PATH"
7185
fi
72-
eval exec "\"$JAVACMD\"" "$DEBUG" "-classpath \"$cp_arg\"" "${residual_args[@]}"
86+
if [ $class_path_count > 1 ]; then
87+
echo "warning: multiple classpaths are found, dotr only use the last one."
88+
fi
89+
eval exec "\"$JAVACMD\"" "$DEBUG" "-classpath \"$cp_arg\"" "${jvm_options[@]}" "${residual_args[@]}"
90+
else
91+
echo "warning: command option is not correct."
7392
fi

0 commit comments

Comments
 (0)