Changing project layout in SBT 0.10.x

前端 未结 1 1476
情歌与酒
情歌与酒 2021-02-07 18:13

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          


        
1条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-07 18:52

    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 讨论(0)
提交回复
热议问题