@@ -3,7 +3,7 @@ package packager
3
3
package archetypes
4
4
5
5
import sbt ._
6
- import sbt .Keys .{ target , mainClass , sourceDirectory , streams }
6
+ import sbt .Keys .{ target , mainClass , sourceDirectory , streams , javaOptions , run }
7
7
import SbtNativePackager .{ Debian , Rpm , Universal }
8
8
import packager .Keys .{ packageName }
9
9
import linux .{ LinuxFileMetaData , LinuxPackageMapping , LinuxSymlink , LinuxPlugin }
@@ -46,6 +46,7 @@ object JavaServerAppPackaging extends AutoPlugin {
46
46
* - config directory
47
47
*/
48
48
def linuxSettings : Seq [Setting [_]] = Seq (
49
+ javaOptions in Linux := Nil ,
49
50
// === logging directory mapping ===
50
51
linuxPackageMappings <+= (packageName in Linux , defaultLinuxLogsLocation, daemonUser in Linux , daemonGroup in Linux ) map {
51
52
(name, logsDir, user, group) => packageTemplateMapping(logsDir + " /" + name)() withUser user withGroup group withPerms " 755"
@@ -60,7 +61,7 @@ object JavaServerAppPackaging extends AutoPlugin {
60
61
if (overrideScript.exists) overrideScript.toURI.toURL
61
62
else etcDefaultTemplateSource
62
63
},
63
- makeEtcDefault <<= (packageName in Linux , target in Universal , linuxEtcDefaultTemplate, linuxScriptReplacements)
64
+ makeEtcDefault <<= (packageName in Linux , target in Universal , linuxEtcDefaultTemplate, linuxScriptReplacements, javaOptions in Linux )
64
65
map makeEtcDefaultScript,
65
66
linuxPackageMappings <++= (makeEtcDefault, bashScriptConfigLocation) map { (conf, configLocation) =>
66
67
configLocation.flatMap { path =>
@@ -259,10 +260,26 @@ object JavaServerAppPackaging extends AutoPlugin {
259
260
Some (script)
260
261
}
261
262
262
- protected def makeEtcDefaultScript (name : String , tmpDir : File , source : java.net.URL , replacements : Seq [(String , String )]): Option [File ] = {
263
+ /**
264
+ * Creates the etc-default file, which will contain the basic configuration
265
+ * for an app.
266
+ *
267
+ * @param name of the etc-default config file
268
+ * @param tmpDir to store the resulting file in (e.g. target in Universal)
269
+ * @param source of etc-default script
270
+ * @param replacements for placeholders in etc-default script
271
+ * @param javaOptions that get appended to the etc-default script
272
+ *
273
+ * @return Some(file: File)
274
+ */
275
+ protected def makeEtcDefaultScript (name : String , tmpDir : File , source : java.net.URL ,
276
+ replacements : Seq [(String , String )], javaOptions : Seq [String ]): Option [File ] = {
263
277
val scriptBits = TemplateWriter .generateScript(source, replacements)
264
278
val script = tmpDir / " tmp" / " etc" / " default" / name
265
279
IO .write(script, scriptBits)
280
+ if (javaOptions.nonEmpty) {
281
+ IO .writeLines(script, " # java options from build" +: javaOptions, append = true )
282
+ }
266
283
Some (script)
267
284
}
268
285
0 commit comments