Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add addApp function to align with bash version #1339

Merged
merged 2 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ addJava () {
java_opts="$java_opts $1"
}

addApp () {
app_commands="$app_commands $1"
}

addResidual () {
residual_args="$residual_args \"$1\""
}
Expand Down Expand Up @@ -91,6 +95,7 @@ process_args () {
fi
}

app_commands=""
residual_args=""
real_script_path="$(realpath "$0")"
app_home="$(realpath "$(dirname "$real_script_path")")"
Expand All @@ -107,4 +112,4 @@ java_cmd="$(get_java_cmd)"
# If a configuration file exist, read the contents to $opts
[ -f "$script_conf_file" ] && opts=$(loadConfigFile "$script_conf_file")

eval "exec $java_cmd $java_opts -classpath $app_classpath $opts $app_mainclass $residual_args"
eval "exec $java_cmd $java_opts -classpath $app_classpath $opts $app_mainclass $app_commands $residual_args"
23 changes: 23 additions & 0 deletions src/sbt-test/ash/add-app-settings/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
enablePlugins(JavaAppPackaging, AshScriptPlugin)

name := "simple-app"

version := "0.1.0"

bashScriptExtraDefines ++= Seq("""addApp "info"""", """addApp "help"""")

TaskKey[Unit]("scriptCheck") := {
val startScript = (stagingDirectory in Universal).value / "bin" / executableScriptName.value
val options = IO.read(startScript)
assert(options contains """addApp "info"""", "Script doesn't contain app setting:\n" + options)
assert(options contains """addApp "help"""", "Script doesn't contain app setting:\n" + options)
}

TaskKey[Unit]("runCheck") := {
val cwd = (stagingDirectory in Universal).value
val cmd = Seq((cwd / "bin" / packageName.value).getAbsolutePath)
val output = (sys.process.Process(cmd, cwd).!!).replaceAll("\n", "")

assert(output.contains("info"), s"Application did not receive residual arg 'info'")
assert(output.contains("help"), s"Application did not receive residual arg 'help'")
}
1 change: 1 addition & 0 deletions src/sbt-test/ash/add-app-settings/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version"))
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object MainApp extends App {
println(args.mkString("|"))
}
5 changes: 5 additions & 0 deletions src/sbt-test/ash/add-app-settings/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Run the staging and check the script.
> stage
$ exists target/universal/stage/bin/simple-app
> scriptCheck
> runCheck