1

我正在尝试使用 sbt 设置一个多项目。目前它非常简单(我这样做是为了学习)但我遇到了一些麻烦。

这是文件夹结构

MyProject
 |
 |-project
      |
      |- Build.scala

Build.scala 文件的内容:

import sbt._
import Keys._

object RootBuild extends Build {
    lazy val root = Project(id = "root", base = file(".")) aggregate(bar, foo)

    lazy val foo = Project(id = "foo", base = file("foo"), dependsOn(bar))

    lazy val bar = Project(id = "bar", base = file("bar"))
}

当我运行时,sbt clean compile我收到以下错误:

[info] Done updating.
[info] Compiling 1 Scala source to C:\MyProject\project\target\scala-2.9.2\sbt-0.12\classes...
[error] C:\MyProject\project\Build.scala:7: parameter specified twice: aggregate
[error]     lazy val foo = Project(id = "foo", base = file("foo"), dependsOn(bar))
[error]                    ^
[error] one error found
[error] (compile:compile) Compilation failed
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? qTerminate batch job (Y/N)? 

我不确定为什么会收到此错误,有关如何解决此问题的任何想法?

4

1 回答 1

2

搬出dependsOn项目Project(id = "foo", base = file("foo")).dependsOn(bar)。如果要在项目声明中添加项目依赖项,请使用项目案例类的依赖项参数:

dependencies: => Seq[ClasspathDep[ProjectReference]]

lazy val foo = Project(id = "foo", base = file("foo"), dependencies = Seq(bar))
于 2013-07-03T13:42:46.970 回答