I'm developing a Scalatra web app with Scalate Jade and using sbt 0.11.0
I've been packaging the web app with "com.github.siasia" %% "xsbt-web-plugin" % "0.1.2".
I've also been experimenting with "com.zentrope" %% "xsbt-scalate-precompile-plugin" % "1.6" to compile the Jade files.
Unfortunately if I use the xsbt-web-plugin to package my war it clears the target directory from any precompiled Scalate files.
What is the best way to package a war with precompiled Scalate files?
Thanks to Keith Irwin, the author of xsbt-scalate-precompile-plugin, I now have a solution to my problem.
My Jade/Scalate files are in webapp/WEB-INF/template and webapp/WEB-INF/scalate/layouts directories.
I'm using the xsbt-web-plugin and xsbt-scalate-precompile-plugin sbt plugins.
In my plugins.sbt file.
resolvers += "Web plugin repo" at "http://siasia.github.com/maven2"
addSbtPlugin("com.github.siasia" %% "xsbt-web-plugin" % "0.1.2")
resolvers += "zentrope" at "http://zentrope.com/maven"
addSbtPlugin("com.zentrope" %% "xsbt-scalate-precompile-plugin" % "1.7")
In my build.scala file.
import WebPlugin._
import Keys._
import com.zentrope.ScalatePlugin._
...
// WebApp Settings
val webAppSettings = Seq(
jettyPort := 8083,
jettyContext := "/MyWebApp"
)
// Scalate Compile Settings
val scalateCompileSettings = scalateTemplateSettings ++ Seq(
scalateTemplateDirectories in Compile <<= (scalateTemplateDirectories in Compile, baseDirectory) {
(dirs, basedir) => dirs ++ Seq(new File(basedir, "/src/main/webapp/WEB-INF/template"),
new File(basedir, "/src/main/webapp/WEB-INF/scalate/layouts"))
}
)
...
lazy val MyWebApp =
Project("MyWebApp", file("MyWebApp"), settings = shared ++ webAppSettings ++ scalateCompileSettings ++ Seq(
resolvers ++= Seq(sonatypeNexusReleases, scalaToolsNexus, novusRels, scalaToolsSnapshots),
libraryDependencies ++= Seq(
scalatra,
scalate,
...
)
))
The 1.7 version of Keiths' plugin allows for the setting of specific template directories which is what I really needed. The only caveat is that I must do a clean right before I call package-war or my compiled Jade files get removed.