-
Notifications
You must be signed in to change notification settings - Fork 443
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
Overridable bash template #635
Comments
I'm afraid this is not possible without overriding the task that generates the bash script. |
With overriding the task, you mean something like this? |
I have this now (added to build.sbt) and it works (bash-template is located in the {
object Override extends JavaAppStartScript {
val bashTemplate = "bash-template"
def settings: Seq[Setting[_]] = Seq(
makeBashScript <<= (baseDirectory, bashScriptDefines, target in Universal, executableScriptName, sourceDirectory) map makeCustomUniversalBinScript
)
import JavaAppPackaging.autoImport._
def makeCustomUniversalBinScript(baseDir: File, defines: Seq[String], tmpDir: File, name: String, sourceDir: File): Option[File] =
if (defines.isEmpty) None
else {
val defaultTemplateLocation = baseDir / "conf" / bashTemplate
val defaultTemplateSource = getClass getResource bashTemplate
val template = if (defaultTemplateLocation.exists)
defaultTemplateLocation.toURI.toURL
else defaultTemplateSource
val scriptBits = JavaAppBashScript.generateScript(defines, template)
val script = tmpDir / "tmp" / "bin" / name
IO.write(script, scriptBits)
// TODO - Better control over this!
script.setExecutable(true)
Some(script)
}
}
Override.settings
} |
Hm. I'm not sure if this setting really makes sense as it's more a cosmetic thing. Would creating a src folder have cause any issues? On the other hand, separating is not that of a big deal. |
And thanks for sharing your code snippet. A few notes/questions
|
If it's not a lot of hassle, I'd would rather add it, as it's nice to stick to the directory convention of the project you're using (in my case, Play, which doesn't have a src folder). I am not sure why the check for |
You can change the play layout structure since 2.4 if that helps. I keep this issue then as a feature request. Happy to merge a pr from you ;)
That's weird. I have to look closer. |
Implemented in #646 |
I'm using the Play framework and I want to override the bash template. Is there currently a way to override the bash template without placing it under
src/templates/bash-template
?It seems from this that it uses
sourceDirectory
to determine the base. I tried settingsourceDirectory in makeBashScript := baseDirectory.value / "app"
and that doesn't work (as I expected). Play defines the following:sourceDirectory in Compile := baseDirectory.value / "app",
. SettingsourceDirectory := baseDirectory.value / "app"
works but then I get also other folders in the package.The text was updated successfully, but these errors were encountered: