Skip to content

Commit fd69ae9

Browse files
committed
Add missing functions to the ash template
1 parent bed1349 commit fd69ae9

File tree

1 file changed

+46
-4
lines changed
  • src/main/resources/com/typesafe/sbt/packager/archetypes/scripts

1 file changed

+46
-4
lines changed

src/main/resources/com/typesafe/sbt/packager/archetypes/scripts/ash-template

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/bin/sh
22

3+
die() {
4+
echo "$@" 1>&2
5+
exit 1
6+
}
7+
38
realpath () {
49
(
510
TARGET_FILE="$1"
@@ -51,6 +56,19 @@ addResidual () {
5156
residual_args="$residual_args $(shellEscape "$1")"
5257
}
5358

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+
5472
# Allow user to specify java options. These get listed first per bash-template.
5573
if [ -n "$JAVA_OPTS" ]
5674
then
@@ -81,10 +99,6 @@ process_args () {
8199
case "$1" in
82100
--) shift && no_more_snp_opts=1 && break ;;
83101
-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 ;;
88102

89103
-mem) echo "!! WARNING !! -mem option is ignored. Please use -J-Xmx and -J-Xms" && shift 2 ;;
90104
-jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;;
@@ -106,6 +120,34 @@ process_args () {
106120
fi
107121
}
108122

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+
109151
app_commands=""
110152
residual_args=""
111153
real_script_path="$(realpath "$0")"

0 commit comments

Comments
 (0)