Skip to content

Commit

Permalink
Handle the case where java arguments may have spaces.
Browse files Browse the repository at this point in the history
* Add appropriate quotes to make sure java arguments (-D) are correctly handled.
* Add a test to validate the fix works

Fixes #205
  • Loading branch information
jsuereth committed Apr 1, 2014
1 parent 9e3b509 commit c132333
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,12 @@ run() {
if [[ "$JAVA_OPTS" != "" ]]; then
java_opts="${JAVA_OPTS}"
fi

# run sbt
execRunner "$java_cmd" \
$(get_mem_opts $app_mem) \
${java_opts} \
${java_args[@]} \
${java_opts[@]} \
"${java_args[@]}" \
-cp "$(fix_classpath "$app_classpath")" \
$app_mainclass \
"${app_commands[@]}" \
Expand Down
3 changes: 3 additions & 0 deletions src/sbt-test/debian/java-app-archetype/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ TaskKey[Unit]("check-script") <<= (stagingDirectory in Universal, name, streams)
val output = Process("bash " + script.getAbsolutePath).!!
val expected = "SUCCESS!"
assert(output contains expected, "Failed to correctly run the main script!. Found ["+output+"] wanted ["+expected+"]")
val expected2 = "Something with spaces"
val output2 = Process(Seq("bash", script.getAbsolutePath, "-Dresult.string="+expected2)).!!
assert(output2 contains expected2, "Failed to correctly run the main script with spaced java args!. Found ["+output2+"] wanted ["+expected2+"]")
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package test

object Test extends App {
println("SUCCESS!")
Option(sys.props("result.string")) match {
case Some(value) => println(value)
case _ => println("SUCCESS!")
}

}

0 comments on commit c132333

Please sign in to comment.