我正在使用Scalate Jade和sbt 0.11.0开发一个Scalatra web应用程序
我一直在用"com.github.siasia“%% "xsbt- web -plugin”% "0.1.2“打包web应用程序。
我也一直在尝试使用"com.zentrope“%% "xsbt-scalate-precompile-plugin”% "1.6“来编译Jade文件。
不幸的是,如果我使用xsbt-web-plugin来打包我的war,它会清除所有预编译的Scalate文件中的目标目录。
用预编译的Scalate文件打包war的最好方法是什么?
发布于 2012-01-10 18:54:38
多亏了xsbt-scalate-precompile-plugin的作者Keith Irwin,我现在有了我的问题的解决方案。
我的Jade/Scalate文件位于webapp/WEB-INF/template和webapp/WEB-INF/scalate/layout目录中。
我使用的是xsbt-web-plugin和xsbt-scalate-precompile-plugin sbt插件。
在我的plugins.sbt文件中。
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")在我的build.scala文件中。
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,
...
)
))Keiths的1.7版本的插件允许设置特定的模板目录,这正是我真正需要的。唯一需要注意的是,我必须在调用package-war之前做一次清理,否则编译后的Jade文件将被删除。
发布于 2011-12-15 02:38:05
我不太明白你的意思。任何源代码都应该在src中。任何人都不应该把任何东西放在target中。资源自然会进入src/main/resources。那么,这些“预编译”文件是自动生成的吗,还是应该放在资源目录中?
https://stackoverflow.com/questions/8508903
复制相似问题