2011-12-14 88 views
1

我發展與Scalate的玉石Scalatra的web應用程序,並使用SBT 0.11.0Scalate的SBT 0.11.0插件的幫助

我已經打包的Web應用程序與「com.github.siasia」 %%「 xsbt-web-plugin「%」0.1.2「。我也一直在試用「com.zentrope」%%「xsbt-scalate-precompile-plugin」%「1.6」來編譯Jade文件。

不幸的是,如果我使用xsbt-web-plugin打包我的war,它會從任何預編譯的Scalate文件中清除目標目錄。

用預編譯的Scalate文件打包戰爭的最佳方式是什麼?

回答

1

感謝Keith Irwin,作者xsbt-scalate-precompile-plugin,我現在可以解決我的問題。

我的Jade/Scalate文件位於webapp/WEB-INF/template和webapp/WEB-INF/scalate/layouts目錄中。

我正在使用xsbt-web-plugin和xsbt-scalate-precompile-plugin sbt插件。

  • xsbt-web-plugin爲我提供了package-war命令。
  • xsbt-scalate-precompile-plugin預編譯我的Jade文件。

在我的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版本允許設置特定的模板目錄,這是我真正需要的。唯一需要注意的是,在我打包打包或者編譯的Jade文件被移除之前,我必須做一個乾淨的權利。

0

我不知道我在這裏瞭解你。任何來源應該在src。一個人不應該把任何東西放在target。資源自然會進入src/main/resources。那麼,這些「預編譯」文件是自動生成的,還是應該放在資源目錄中呢?