1
1
#! /bin/sh
2
2
3
+ die () {
4
+ echo " $@ " 1>&2
5
+ exit 1
6
+ }
7
+
3
8
realpath () {
4
9
(
5
10
TARGET_FILE=" $1 "
@@ -51,6 +56,19 @@ addResidual () {
51
56
residual_args=" $residual_args $( shellEscape " $1 " ) "
52
57
}
53
58
59
+ addDebugger () {
60
+ addJava " -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:$1 "
61
+ }
62
+
63
+ require_arg () {
64
+ local type=" $1 "
65
+ local opt=" $2 "
66
+ local arg=" $3 "
67
+ if [[ -z " $arg " ]] || [[ " ${arg: 0: 1} " == " -" ]]; then
68
+ die " $opt requires <$type > argument"
69
+ fi
70
+ }
71
+
54
72
# Allow user to specify java options. These get listed first per bash-template.
55
73
if [ -n " $JAVA_OPTS " ]
56
74
then
@@ -81,10 +99,6 @@ process_args () {
81
99
case " $1 " in
82
100
--) shift && no_more_snp_opts=1 && break ;;
83
101
-h|-help) usage; exit 1 ;;
84
- -v|-verbose) verbose=1 && shift ;;
85
- -d|-debug) debug=1 && shift ;;
86
-
87
- -no-version-check) no_version_check=1 && shift ;;
88
102
89
103
-mem) echo " !! WARNING !! -mem option is ignored. Please use -J-Xmx and -J-Xms" && shift 2 ;;
90
104
-jvm-debug) require_arg port " $1 " " $2 " && addDebugger $2 && shift 2 ;;
@@ -106,6 +120,34 @@ process_args () {
106
120
fi
107
121
}
108
122
123
+ usage () {
124
+ cat << EOM
125
+ Usage: $script_name [options]
126
+
127
+ -h | -help print this message
128
+ -main <classname> Define a custom main class
129
+ -jvm-debug <port> Turn on JVM debugging, open at the given port.
130
+
131
+ # java version (default: java from PATH, currently $( java -version 2>&1 | grep version) )
132
+ -java-home <path> alternate JAVA_HOME
133
+
134
+ # jvm options and output control
135
+ JAVA_OPTS environment variable, if unset uses "$java_opts "
136
+ -Dkey=val pass -Dkey=val directly to the java runtime
137
+ -J-X pass option -X directly to the java runtime
138
+ (-J is stripped)
139
+
140
+ # special option
141
+ -- To stop parsing built-in commands from the rest of the command-line.
142
+ e.g.) enabling debug and sending -d as app argument
143
+ \$ ./start-script -d -- -d
144
+
145
+ In the case of duplicated or conflicting options, basically the order above
146
+ shows precedence: JAVA_OPTS lowest, command line options highest except "--".
147
+ ${{available_main_classes} }
148
+ EOM
149
+ }
150
+
109
151
app_commands=" "
110
152
residual_args=" "
111
153
real_script_path=" $( realpath " $0 " ) "
0 commit comments