SBT:排除资源子目录 [英] SBT: Exclude resource subdirectory
问题描述
在Gradle中,我会这样做:
sourceSets {
pre>
main {
资源{
exclude'com / example / export / dev'//排除开发资源
}
}
}
这将从最终版本中排除资源包
com.example.export.dev
包。 / p>
我如何在SBT中做同样的事情?我已经在编译 - =(编译中的resourceDirectory).value /com / example / export / dev中尝试了
unmanagedResourceDirectories in Compile -
但是这并没有做任何事情(我理解为什么,但这并没有什么帮助) 。并且SBT网站上的文档仅讨论排除文件模式(在类路径,来源,和资源)。
作为一个更具描述性的图片,假设我们有以下资源目录结构:
com
\ ---示例
\ --- export
\ --- dev
\ ---
在最后的输出中,我想要:
com
\ ---例子
\ ---出口
\ ---东西
解决方案From https://github.com/sbt/sbt-jshint/issues/14 :
< pre $excludeFilter in unmanagedResources:= {
val public =((compile中的resourceDirectory).value /com/example/export/dev)。 getCanonicalPath
新的SimpleFileFilter(_。getCanonicalPath startsWith public)
}
I've been using Gradle for most of my Scala projects, but I want to evaluate the suitability of SBT as a replacement. One of the things I've done in Gradle is to exclude a certain resource directory from the final build (for example, using CoffeeScript to write JavaScript files that will be included as final resources).
In Gradle, I'd do this by:
sourceSets {
main {
resources {
exclude 'com/example/export/dev' // exclude development resources
}
}
}
And this would exclude the resource package com.example.export.dev
package from the final build.
How would I do the same in SBT? I've tried
unmanagedResourceDirectories in Compile -= (resourceDirectory in Compile).value / "com/example/export/dev"
but that doesn't do a thing (I understand why, but that doesn't really help). And the documentation on the SBT web site only talks about excluding file patterns (at Classpaths, sources, and resources).
As a more descriptive image, say we have the following resource directory structure:
com
\---example
\---export
\---dev
\---something
In the final output, I want:
com
\---example
\---export
\---something
From https://github.com/sbt/sbt-jshint/issues/14:
excludeFilter in unmanagedResources := {
val public = ((resourceDirectory in Compile).value / "com" / "example" / "export" / "dev").getCanonicalPath
new SimpleFileFilter(_.getCanonicalPath startsWith public)
}
这篇关于SBT:排除资源子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!