Scala 如何在SBT1.x中使用WatchSource来过滤文件?

Scala 如何在SBT1.x中使用WatchSource来过滤文件?,scala,intellij-idea,sbt,intellij-scala,Scala,Intellij Idea,Sbt,Intellij Scala,我有如下代码,类似于之前的工作: .settings(watchSources := watchSources.value.filterNot(_.getPath.contains("target"))) 在SBT 1.x中,这导致: error: value getPath is not a member of sbt.Watched.WatchSource x.getPath.contains("target") 通过在filterNot的函数参数中添加类型,稍微扩展代码: .setti

我有如下代码,类似于之前的工作:

.settings(watchSources := watchSources.value.filterNot(_.getPath.contains("target")))
在SBT 1.x中,这导致:

error: value getPath is not a member of sbt.Watched.WatchSource
x.getPath.contains("target")
通过在
filterNot
的函数参数中添加类型,稍微扩展代码:

.settings(watchSources := (watchSources.value.filterNot{x: File =>
  x.getPath.contains("target")
}))
我们得到一个单独的错误:

[info] Loading project definition from /home/brandon/workspace/CCRS/project
/home/brandon/workspace/CCRS/build.sbt:111: error: type mismatch;
 found   : sbt.File => Boolean
    (which expands to)  java.io.File => Boolean
 required: sbt.Watched.WatchSource => Boolean
    (which expands to)  sbt.internal.io.Source => Boolean
  .settings(watchSources := watchSources.value.filterNot{x: File =>
                                                             ^
奇怪的是IntelliJ似乎认为代码看起来很好(我在用最新版本的SBT更新了
build.properties
后重新启动了IntelliJ)-它将值
x
视为
文件,而不是
监视源代码,它表示
watchSources.value
的类型为
Seq[File]


到目前为止,这个相关但更一般的问题()似乎没有引起任何关注。

源代码的
基:File
构造函数参数最近已更改为
val
,但不幸的是,修补后的版本似乎还没有发布:谢谢,听起来很有希望,但是我对SBT一无所知,所以我不理解它的直接含义。我可以确认它在0.13.7中不是问题,而且很高兴我的构建设置中的其他所有内容也都适用于0.13.7。是的,这种情况可以解释如下:
WatchSources
类型为
TaskKey[Seq[File]]
在0.13中,而它在1.x中是类型为
TaskKey[Seq[WatchSource]]
WatchSource
是sbt.internal.io.Source
的别名,直到最近才允许我们访问其
文件
组件
base
。@Benmcann感谢您提醒我。根据GitHub的说法,上面的提交已经被合并到SBT1.2.0中。因此,我认为OP的代码现在可以按如下方式编写:
.settings(watchSources:=watchSources.value.filterNot(u.base.getPath.contains(“target”))