我可以在Play上使用什么SBT构建设置! 2个框架,将包括来自类路径中源树的特定资源 [英] What SBT build setting can I use with the Play! 2 framework that will include specific resources from the source tree on the class path
问题描述
我想在构建中添加一个设置,该设置将从src树中的某个位置复制特定文件,以便在开发和生产模式下的类路径中可以使用它们.我不想将它们放在public
文件夹中,因为我不希望它们可供下载.而且我不想将它们放在conf
文件夹中,因为我想保持配置文件的清洁.
I would like to add a setting to the build that will copy specific files from a location within src tree so that they are available on the class path in dev and production mode. I don’t want to put them in the public
folder because I don’t want them to be available to download. And I don’t want to put them in the conf
folder because I want to keep that clean for configuration files.
例如:
app
-- views
-- website
-- view.scala.html
-- header-module.widget
-- footer-module.widget
在编译应用程序时,我希望类路径在classpath:views/website/
下同时包含*.widget
文件,而不包括view.scala.html
,因为它们是分开处理的.
When the application is compiled I would like the class path to include both the *.widget
files under classpath:views/website/
and not the view.scala.html
because that is processed separately.
我想通过添加一个可以设置过滤器的sbt设置来做到这一点,我已经尝试过这种方法和一些变体,但是到目前为止还没有奏效:
I would like to do this by adding an sbt setting where I can provide a filter, I’ve already tried this and some variations, but have not had it working so far:
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
})
推荐答案
.settings()
中的以下内容应该起作用:
The following inside .settings()
should work:
// 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"
我有……像这样在Build.scala中将mybatis xml文件包含在类路径中,并且对我们有用.
I have s.th. like this in our Build.scala to have mybatis xml files in the classpath and it's working for us.
这篇关于我可以在Play上使用什么SBT构建设置! 2个框架,将包括来自类路径中源树的特定资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!