我可以在Play中使用什么SBT构建设置!2框架将包含类路径上源树的特定资源

Jam*_*wry 4 sbt playframework-2.0

我想在构建中添加一个设置,它将从src树中的某个位置复制特定文件,以便它们在开发和生产模式的类路径中可用.我不想把它们放在public文件夹中,因为我不希望它们可以下载.而且我不想把它们放在conf文件夹中,因为我想保持配置文件的干净.

例如:

app
  -- views
     -- website
        -- view.scala.html
        -- header-module.widget
        -- footer-module.widget
Run Code Online (Sandbox Code Playgroud)

编译应用程序时,我希望类路径包含下面的*.widget文件,classpath:views/website/而不是view.scala.html因为单独处理的文件.

我想通过添加一个sbt设置来实现这一点,我可以提供一个过滤器,我已经尝试了这个和一些变化,但到目前为止还没有工作:

val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings(
  // Add your own project settings here
  unmanagedResources in Compile <++= (sourceDirectory in Compile) map {
    base: File => ( base / "views" ** "*. widget ").get
})
Run Code Online (Sandbox Code Playgroud)

Mar*_*zke 5

以下内部.settings()应该工作:

// Add app folder as resource directory so that widget files are in the classpath
unmanagedResourceDirectories in Compile <+= baseDirectory( _ / "app" ),
// but filter out java and html files that would then also be copied to the classpath
excludeFilter in Compile in unmanagedResources := "*.java" || "*.html"
Run Code Online (Sandbox Code Playgroud)

我有s.th. 像我们的Build.scala中这样在类路径中有mybatis xml文件,它对我们有用.