Denis Rosca
Denis Rosca

Reputation: 3469

"parameter specified twice: aggregate" in sbt multiproject definition

I'm trying to setup a multi project with sbt. At the moment it is very simple (I'm doing for learning purposes) but I have some trouble with it.

This is the folder structure

MyProject
 |
 |-project
      |
      |- Build.scala

The contents of the Build.scala file:

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"))
}

When I run sbt clean compile i get the following error:

[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)? 

I'm not sure why I'm getting this error, any ideas on how this can be fixed?

Upvotes: 1

Views: 317

Answers (1)

4lex1v
4lex1v

Reputation: 21557

Move dependsOn out of project Project(id = "foo", base = file("foo")).dependsOn(bar). If you want to add project dependency in project declaration then use dependancies parameter of Project case class:

dependencies: => Seq[ClasspathDep[ProjectReference]]

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

Upvotes: 2

Related Questions