Skip to content

Commit c132333

Browse files
committed
Handle the case where java arguments may have spaces.
* Add appropriate quotes to make sure java arguments (-D) are correctly handled. * Add a test to validate the fix works Fixes #205
1 parent 9e3b509 commit c132333

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/main/resources/com/typesafe/sbt/packager/archetypes/bash-template

+3-3
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,12 @@ run() {
249249
if [[ "$JAVA_OPTS" != "" ]]; then
250250
java_opts="${JAVA_OPTS}"
251251
fi
252-
252+
253253
# run sbt
254254
execRunner "$java_cmd" \
255255
$(get_mem_opts $app_mem) \
256-
${java_opts} \
257-
${java_args[@]} \
256+
${java_opts[@]} \
257+
"${java_args[@]}" \
258258
-cp "$(fix_classpath "$app_classpath")" \
259259
$app_mainclass \
260260
"${app_commands[@]}" \

src/sbt-test/debian/java-app-archetype/build.sbt

+3
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,7 @@ TaskKey[Unit]("check-script") <<= (stagingDirectory in Universal, name, streams)
3737
val output = Process("bash " + script.getAbsolutePath).!!
3838
val expected = "SUCCESS!"
3939
assert(output contains expected, "Failed to correctly run the main script!. Found ["+output+"] wanted ["+expected+"]")
40+
val expected2 = "Something with spaces"
41+
val output2 = Process(Seq("bash", script.getAbsolutePath, "-Dresult.string="+expected2)).!!
42+
assert(output2 contains expected2, "Failed to correctly run the main script with spaced java args!. Found ["+output2+"] wanted ["+expected2+"]")
4043
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package test
22

33
object Test extends App {
4-
println("SUCCESS!")
4+
Option(sys.props("result.string")) match {
5+
case Some(value) => println(value)
6+
case _ => println("SUCCESS!")
7+
}
8+
59
}

0 commit comments

Comments
 (0)