Skip to content

Commit

Permalink
Merge pull request #526 from knshiro/env-config
Browse files Browse the repository at this point in the history
Added support for environment configuration file.
  • Loading branch information
muuki88 committed Mar 22, 2015
2 parents e9cfbe4 + 6e3a5ec commit 3a2a576
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ object JavaAppPackaging extends AutoPlugin with JavaAppStartScript {
scriptClasspath <<= scriptClasspathOrdering map makeRelativeClasspathNames,
bashScriptExtraDefines := Nil,
bashScriptConfigLocation <<= bashScriptConfigLocation ?? None,
bashScriptEnvConfigLocation <<= bashScriptEnvConfigLocation ?? None,
bashScriptExtraDefines <++= (bashScriptEnvConfigLocation in Universal) map { _.map { config =>
"[[ -f '" + config +"' ]] && source " + config
}.toSeq },
bashScriptDefines <<= (Keys.mainClass in (Compile, bashScriptDefines), scriptClasspath in bashScriptDefines, bashScriptExtraDefines, bashScriptConfigLocation) map { (mainClass, cp, extras, config) =>
val hasMain =
for {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ trait JavaAppKeys {
val bashScriptDefines = TaskKey[Seq[String]]("bashScriptDefines", "A list of definitions that should be written to the bash file template.")
val bashScriptExtraDefines = TaskKey[Seq[String]]("bashScriptExtraDefines", "A list of extra definitions that should be written to the bash file template.")
val bashScriptConfigLocation = TaskKey[Option[String]]("bashScriptConfigLocation", "The location where the bash script will load default argument configuration from.")
val bashScriptEnvConfigLocation = TaskKey[Option[String]]("bashScriptEnvConfigLocation", "The location of a bash script that will be sourced before running the app.")
val batScriptExtraDefines = TaskKey[Seq[String]]("batScriptExtraDefines", "A list of extra definitions that should be written to the bat file template.")
val scriptClasspathOrdering = TaskKey[Seq[(File, String)]]("scriptClasspathOrdering", "The order of the classpath used at runtime for the bat/bash scripts.")
val projectDependencyArtifacts = TaskKey[Seq[Attributed[File]]]("projectDependencyArtifacts", "The set of exported artifacts from our dependent projects.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import debian.DebianPlugin
import debian.DebianPlugin.autoImport.{ debianMakePreinstScript, debianMakePostinstScript, debianMakePrermScript, debianMakePostrmScript }
import rpm.RpmPlugin
import rpm.RpmPlugin.autoImport.{ rpmPre, rpmPost, rpmPostun, rpmPreun, rpmScriptsDirectory }
import JavaAppPackaging.autoImport.{ bashScriptConfigLocation }
import JavaAppPackaging.autoImport.{ bashScriptConfigLocation, bashScriptEnvConfigLocation }

/**
* This class contains the default settings for creating and deploying an archetypical Java application.
Expand Down Expand Up @@ -55,6 +55,9 @@ object JavaServerAppPackaging extends AutoPlugin {
},
// === etc config mapping ===
bashScriptConfigLocation <<= (packageName in Linux) map (name => Some("/etc/default/" + name)),
bashScriptEnvConfigLocation <<= (bashScriptConfigLocation, bashScriptEnvConfigLocation) map { (configLocation, envConfigLocation) =>
envConfigLocation orElse (configLocation map (_ + "_env"))
},
linuxEtcDefaultTemplate <<= sourceDirectory map { dir =>
val overrideScript = dir / "templates" / "etc-default"
if (overrideScript.exists) overrideScript.toURI.toURL
Expand Down

0 comments on commit 3a2a576

Please sign in to comment.