Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 239
Rajish Avatar asked Sep 01 '12 22:09

Rajish


3 Answers

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.

like image 153
Roland Kuhn Avatar answered Nov 05 '22 20:11

Roland Kuhn


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"
)
like image 5
Rebecca Grenier Avatar answered Nov 05 '22 22:11

Rebecca Grenier


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.

like image 2
ndeverge Avatar answered Nov 05 '22 21:11

ndeverge