如何在SBT 1.x中使用WatchSource来过滤文件?

时间:2018-02-14 16:26:41

标签: 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的函数参数添加类型来轻微扩展代码:

.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视为File,而不是WatchSource,表明watchSources.value属于Seq[File]类型。

这个相关但更一般的问题(Remove or Exclude WatchSource in sbt 1.0.x)到目前为止似乎没有得到任何关注。

0 个答案:

没有答案