Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing project layout in SBT 0.10.x

I feel like an idiot, but I am not 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 ?

like image 588
paradigmatic Avatar asked Aug 16 '11 16:08

paradigmatic


1 Answers

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

like image 151
retronym Avatar answered Oct 04 '22 03:10

retronym