如何为非自定义源目录配置SBT

时间:2019-01-13 18:39:47

标签: sbt

我成功配置了SBT以查找其默认目录结构之外的源。

val absoluteDir = "/home/.../[fooProjectBaseDirectory]/"
unmanagedSourceDirectories in Compile += new File(absoluteDir + "jvm/src")
unmanagedSourceDirectories in Test += new File(absoluteDir + "jvm/test/src")

在现实世界中,我想通过使用相对目录来实现相同目的。

我尝试过:

sourceDirectory in Compile := baseDirectory.value / "jvm" / "src"
sourceDirectory in Test := baseDirectory.value / "jvm" / "test" / "src"

但是sbt似乎将 scala-2.12 scala java 目录附加到了我的路径,导致搜索失败。

  

sbt:foo> 检查编译:unmanagedSourceDirectories   [信息]   设置:scala.collection.Seq [java.io.File] =   列表(/ home /.../ [fooProjectBaseDirectory] ​​/ jvm / src / scala-2.12 ,   / home /.../ [fooProjectBaseDirectory] ​​/ jvm / src / scala ,   / home /.../ [fooProjectBaseDirectory] ​​/ jvm / src / java

有任何提示吗?

1 个答案:

答案 0 :(得分:0)

找到了解决方案。两者都在工作:

unmanagedSourceDirectories in Compile += baseDirectory.value / "jvm" / "src"
unmanagedSourceDirectories in Test += baseDirectory.value / "jvm" / "test" / "src"

Compile / unmanagedSourceDirectories += baseDirectory.value / "jvm" / "src"
Test / unmanagedSourceDirectories += baseDirectory.value / "jvm" / "test" / "src"