开发者

Changing project layout in SBT 0.10.x

开发者 https://www.devze.com 2023-03-28 17:10 出处:网络
I feel like an idiot, but I am n开发者_如何学Pythonot able to change my project layout with SBT 0.10.x. In my sbt 0.7.x project I added the lines:

I feel like an idiot, but I am n开发者_如何学Pythonot able to change my project layout with SBT 0.10.x. In my sbt 0.7.x project I added the lines:

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"

What would be the equivalent in 0.10.x ?


Minimally, you can configure the base source directory in the Test and Compile scopes, then configure the resource directory in the Compile scope. That setting will be correct in the Test scope because by default it is relative to the sourceDirectory. Similarly, the scala-source and java-source settings will be correct.

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

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

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

To see this in action:

> 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

You can inspect the relationships between settings in the shell with inspect; or by browsing the source of SBT

0

精彩评论

暂无评论...
验证码 换一张
取 消