sbt - 非法动态参考

时间:2017-04-22 18:45:51

标签: scala dynamic build sbt

下面是我的build.sbt中使用的代码,用于添加其他测试源目录,并且工作正常: -

unmanagedSourceDirectories in Test ++= Seq ( (baseDirectory( _ / "abc" )).value, (baseDirectory( _ / "xyz" )).value )

但是,以下版本提供非法动态错误

val folderList = Seq("abc", "xyz")
unmanagedSourceDirectories in Test ++= folderList map { src => (baseDirectory( _ / src )).value }

根据建议here,我尝试了动态任务也没有运气: -

val folderList = Seq("abc", "xyz")
val dynamic = Def.taskDyn{
  Def.task{
    folderList
  }
}
unmanagedSourceDirectories in Test ++= dynamic.value map { src => (baseDirectory( _ / src )).value }

请建议正确的语法。

1 个答案:

答案 0 :(得分:0)

您不需要为此用例定义动态任务。只需使用.value宏:

val folderList = Seq("abc", "xyz")
unmanagedSourceDirectories in Test ++=
  folderList.map { src => (baseDirectory in Test).value / src }