-
Notifications
You must be signed in to change notification settings - Fork 443
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Define addJava in ash-template (#944)
* Define addJava in ash-template Previously, there was no addJava function defined in the ash-template. This resulted in warnings when the ash script ran because template declares expects the function to be defined. Now, the addJava function is defined. It adds options to java_opts. As a convenience, if JAVA_OPTS is set then it is added to java_opts. This makes the ash script behave more like the bash script. The result is then passed to java at the end of the script. * Add tests for ashscript and use extraBashScriptDefines
- Loading branch information
Showing
6 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
enablePlugins(JavaAppPackaging, AshScriptPlugin) | ||
|
||
name := "simple-app" | ||
|
||
version := "0.1.0" | ||
|
||
bashScriptExtraDefines ++= Seq( | ||
"""addJava "-Xms64m"""", | ||
"""addJava "-Xmx64m"""" | ||
) | ||
|
||
TaskKey[Unit]("script-check") := { | ||
val startScript = (stagingDirectory in Universal).value / "bin" / executableScriptName.value | ||
val options = IO.read(startScript) | ||
assert(options contains """addJava "-Xms64m"""", "Script doesn't contain xmx setting:\n" + options) | ||
assert(options contains """addJava "-Xmx64m"""", "Script doesn't contain xms setting:\n" + options) | ||
} | ||
|
||
TaskKey[Unit]("run-check") := { | ||
val cwd = (stagingDirectory in Universal).value | ||
val cmd = Seq((cwd / "bin" / packageName.value).getAbsolutePath) | ||
val memory = (Process(cmd, cwd).!!).replaceAll("\n", "") | ||
assert(memory.toLong <= 64, "Runtime memory is bigger then 64m < " + memory + "m") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version")) |
4 changes: 4 additions & 0 deletions
4
src/sbt-test/ash/memory-settings/src/main/scala/MainApp.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
object MainApp extends App { | ||
val memory = Runtime.getRuntime.maxMemory() / (1024L * 1024L) | ||
print(memory) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
> script-check | ||
> run-check |