在 SBT 0.10.x 中更改项目布局 [英] Changing project layout in SBT 0.10.x

查看:12
本文介绍了在 SBT 0.10.x 中更改项目布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我觉得自己像个白痴,但我无法使用 SBT 0.10.x 更改我的项目布局.在我的 sbt 0.7.x 项目中,我添加了以下几行:

覆盖 def mainScalaSourcePath = "src"/"scala"覆盖 def testScalaSourcePath = "test"/"scala"覆盖 def mainResourcesPath = "资源"覆盖 def mainJavaSourcePath = "src"/"java"覆盖 def testJavaSourcePath = "test"/"java"覆盖 def testResourcesPath = "test"/"resources"

0.10.x 中的等价物是什么?

解决方案

至少可以在 TestCompile 范围内配置基本源目录,然后配置Compile 范围内的资源目录.该设置在 Test 范围内是正确的,因为默认情况下它是相对于 sourceDirectory 的.同样,scala-sourcejava-source 设置也是正确的.

编译中的sourceDirectory <<= baseDirectory(_/"src")测试中的源目录 <<= baseDirectory(_/"test")编译中的资源目录 <<= baseDirectory(_/"resources")

查看实际效果:

<代码>>在编译中设置 sourceDirectory <<= baseDirectory(_/"src")[信息] 重新应用设置...[info] 将当前项目设置为 default-fcf187(在构建文件中:/C:/temp/)>在测试中设置 sourceDirectory <<= baseDirectory(_/"test")[信息] 重新应用设置...[info] 将当前项目设置为 default-fcf187(在构建文件中:/C:/temp/)>在编译中设置资源目录 <<= baseDirectory(_/"resources")[信息] 重新应用设置...[info] 将当前项目设置为 default-fcf187(在构建文件中:/C:/temp/)>显示测试:资源目录[信息] C:	emp	est
esources>显示编译:资源目录[信息] C:	emp
esources>显示测试:scala-source[信息] C:	emp	estscala>显示测试:java-source[信息] C:	emp	estjava>显示编译:java-source[信息] C:	empsrcjava>显示测试:java-source[信息] C:	emp	estjava

您可以使用 inspect 来检查 shell 中设置之间的关系;或浏览 SBT 源代码p>

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:	emp	est
esources
> show compile:resource-directory
[info] C:	emp
esources
> show test:scala-source
[info] C:	emp	estscala
> show test:java-source
[info] C:	emp	estjava
> show compile:java-source
[info] C:	empsrcjava
> show test:java-source
[info] C:	emp	estjava

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

这篇关于在 SBT 0.10.x 中更改项目布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆