我有以下代码,如下所示:
.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 似乎认为代码看起来很好(我在build.properties
用最新版本的 SBT 更新我的之后确实重新启动了 IntelliJ) - 它认为值x
是 a File
,而不是 a WatchSource
,它表明它watchSources.value
是 type Seq[File]
。
到目前为止,这个相关但更普遍的问题(Remove or Exclude WatchSource in sbt 1.0.x)似乎没有引起任何关注。