SBT:排除资源子目录 [英] SBT: Exclude resource subdirectory

查看:212
本文介绍了SBT:排除资源子目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用Gradle来处理我的大部分Scala项目,但我想评估SBT作为替代品的适用性。我在Gradle中完成的一件事是从最终构建中排除某个资源目录(例如,使用CoffeeScript编写将作为最终资源包含的JavaScript文件)。



在Gradle中,我会这样做:

  sourceSets {
main {
资源{
exclude'com / example / export / dev'//排除开发资源
}
}
}
pre>

这将从最终版本中排除资源包 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆