在SBT 0.10.x中更改项目布局

时间:2011-08-16 16:00:43

标签: scala migration sbt

我觉得自己像个白痴,但我无法用SBT 0.10.x改变我的项目布局。在我的sbt 0.7.x项目中,我添加了以下行:

override def mainScalaSourcePath = "src" / "scala"
override def testScalaSourcePath = "test" / "scala"
override def mainResourcesPath = "resources"

override def mainJavaSourcePath = "src" / "java"
override def testJavaSourcePath = "test" / "java"
override def testResourcesPath = "test" / "resources"

0.10.x中的等价物是什么?

1 个答案:

答案 0 :(得分:17)

最低限度,您可以在TestCompile范围中配置基本源目录,然后在Compile范围内配置资源目录。该设置在Test范围内是正确的,因为默认情况下它相对于sourceDirectory。同样,scala-sourcejava-source设置也是正确的。

sourceDirectory in Compile <<= baseDirectory(_ / "src")

sourceDirectory in Test <<= baseDirectory(_ / "test")

resourceDirectory in Compile <<= baseDirectory(_ / "resources")

要看到这一点:

> set sourceDirectory in Compile <<= baseDirectory(_ / "src")
[info] Reapplying settings...
[info] Set current project to default-fcf187 (in build file:/C:/temp/)

> set sourceDirectory in Test <<= baseDirectory(_ / "test")
[info] Reapplying settings...
[info] Set current project to default-fcf187 (in build file:/C:/temp/)

> set resourceDirectory in Compile <<= baseDirectory(_ / "resources")
[info] Reapplying settings...
[info] Set current project to default-fcf187 (in build file:/C:/temp/)

> show test:resource-directory
[info] C:\temp\test\resources
> show compile:resource-directory
[info] C:\temp\resources
> show test:scala-source
[info] C:\temp\test\scala
> show test:java-source
[info] C:\temp\test\java
> show compile:java-source
[info] C:\temp\src\java
> show test:java-source
[info] C:\temp\test\java

您可以使用inspect检查shell中设置之间的关系;或浏览source of SBT