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

发布于 2024-11-29 21:16:34 字数 425 浏览 1 评论 0原文

我感觉自己像个白痴,但我无法使用 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 中的等效项是什么?

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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

残龙傲雪 2024-12-06 21:16:34

至少,您可以在 TestCompile 范围中配置基本源目录,然后在 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 检查 shell 中设置之间的关系;或者浏览SBT 来源

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文