在SBT 0.10.x中更改项目布局 [英] Changing project layout in SBT 0.10.x
问题描述
我觉得自己是个白痴,但是我无法使用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等于多少?
至少,可以在Test
和Compile
范围内配置基本源目录,然后在Compile
范围内配置资源目录.该设置在Test
范围内将是正确的,因为默认情况下它是相对于sourceDirectory
的.同样,scala-source
和java-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
检查外壳中设置之间的关系;或通过浏览 SBT来源 >
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 ?
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
这篇关于在SBT 0.10.x中更改项目布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!