How to make Play! framework dist command adding some files/folders to the final package?
Asked Answered
T

5

25

I wanted the Play! framework dist command to add some folders and files to the final zip file. They are needed for the application to work.

Is there a magic project/Build.scala configuration to make it possible? I couldn't find it in the Play! documentation.

Tidemark answered 1/9, 2012 at 22:19 Comment(0)
J
29

Play uses sbt-native-packager, which supports the inclusion of arbitrary files by adding them to the mappings:

mappings in Universal ++=
  (baseDirectory.value / "scripts" * "*" get) map
    (x => x -> ("scripts/" + x.getName))

The syntax assumes Play 2.2.x.

Jewfish answered 24/10, 2013 at 14:38 Comment(6)
At last :) This question was long lost.Tidemark
@Roland can you post the code to copy nested sub-directories and its contents.Gt
See scala-sbt.org/0.13.7/docs/Detailed-Topics/Mapping-Files.html: (baseDirectory.value / "scripts" ***).get pair relativeTo(baseDirectory.value)Jewfish
@Roland Kuhn: Your provided link is unfortunatly dead. Can you maybe adjust?White
This is one of the more useful answers I've come across. Thanks for sharing @RolandPya
For sbt 1.3.4, import com.typesafe.sbt.SbtNativePackager.autoImport.NativePackagerHelper._ mappings in Universal ++= directory(baseDirectory.value / "resources")Hagood
L
5

My Play application was not including template files (in app/views/) in the distributable, and I added them with this in Build.scala:

val main = play.Project(appName, appVersion, appDependencies).settings(
  // Add your own project settings here   
  playAssetsDirectories <+= baseDirectory / "app/views"
)
Lowry answered 29/4, 2013 at 20:26 Comment(0)
D
2

By looking at the dist source code, I think it is not possible.

But you can use the play clean compile stage command to package the app and its dependencies (from doc):

This cleans and compiles your application, retrieves the required dependencies and copies them to the target/staged directory. It also creates a target/start script that runs the Play server.

Then you'll have to write your own script to add your directories and build a zip.

Destination answered 2/9, 2012 at 12:14 Comment(0)
P
2

Not sure since which Play version this has been supported, but Play! 2.5 documentation suggests that you can add any arbitrary files you want to package under a 'dist' folder (at the root of the project). I'm using SBT native packager to build my project into an RPM and this work perfectly out-of-the-box.

Phonation answered 23/5, 2017 at 10:56 Comment(1)
Just tested this and it appears to work. Albeit the editor Atom seems not to like (as in hides) a root folder called Dist so unsure if that conflicts with something else (in MY environment...) (Update: My bad - was just a folder in .gitignore for some reason)Ankylose
S
0

I can bet that I won't satisfy you, but maybe you won't waste your time for searching. As Nico pointed there's no such possibility, the fastest approach you can use is to write a bash script (or *.bat file) to do that.

I spent an hour for looking the solution... and 15 minutes for writing script which unzips, modifies, zips and send a file to the remote destination, so consider if it will not be better option for you as well.

Spiritualize answered 2/9, 2012 at 17:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.