scalaSource
和sourceDirectories
之间有什么区别?我有一个非标准的目录结构,源代码位于src/
,
此行适用于build.sbt
:
scalaSource in Compile := file("src/")
但不是
sourceDirectories in Compile := Seq(file("src/"))
答案 0 :(得分:2)
源代码有很多种:Scala和Java,托管和非托管。 sourceDirectories in Compile
结合了所有这些,但通常不想直接设置它;通常你会设置更具体的设置,适用于你试图告诉它的位置的特定类型的来源。
请注意baseDirectory.value / "src"
比file("src")
更正确(它适用于更多场景:子项目,外部项目等)。
答案 1 :(得分:1)
我不能告诉你整个情况,有人在sbt上工作可能会在稍后看到这篇文章。 到那时,我就是这样做的理由:inspect
> inspect actual compile:scalaSource
[info] Description:
[info] Default Scala source directory.
[info] Dependencies:
[info] compile:sourceDirectory
[info] Reverse dependencies:
[info] compile:unmanagedSourceDirectories
[info] Delegates:
[info] compile:scalaSource
> inspect actual compile:sourceDirectories
[info] Description:
[info] List of all source directories, both managed and unmanaged.
[info] Dependencies:
[info] compile:unmanagedSourceDirectories
[info] compile:managedSourceDirectories
[info] Delegates:
[info] compile:sourceDirectories
[info] *:sourceDirectories
[info] {.}/compile:sourceDirectories
现在我就是这样解释的: sourceDirectories ......嗯......完全非正式......
让我们看看这与compile
:
> inspect compile
[info] Dependencies:
[info] compile:compile::compileInputs <----
[info] compile:compile::streams
> inspect compile:compile::compileInputs
[info] Dependencies:
...
[info] compile:compile::sources <----
...
> inspect compile:compile::sources
[info] Provided by:
[info] {file:<build-uri>}<project-id>/compile:sources
[info] Delegates:
[info] compile:compile::sources
[info] compile:sources <----
此任务已委派,我们可以通过Reverse dependencies
查看我们来自inspect actual
的位置,定期检查不会显示它们。
> inspect actual compile:sources
[info] Description:
[info] All sources, both managed and unmanaged.
[info] Reverse dependencies:
[info] compile:doc
[info] compile:compile::compileInputs
[info] Dependencies:
[info] compile:unmanagedSources <----
[info] compile:managedSources
> inspect compile:unmanagedSources
[info] Dependencies:
[info] compile:unmanagedSourceDirectories
...
> inspect compile:unmanagedSourceDirectories
[info] Dependencies:
[info] compile:javaSource
[info] compile:scalaSource <----
[info] Reverse dependencies:
[info] compile:sourceDirectories
[info] compile:unmanagedSources
希望这有帮助。