Ryoichiro Oka Ryoichiro Oka - 6 months ago 55
Scala Question

Let build.sbt define dependency on another local library

There lines up two modules in the same directory, and I want the one to depend on another. I know how to do it in Scala files in the project directory, however, I want the build.sbt to perform the same job with itself. Here is a not-working code that would hopefully communicate to you what I mean:

name := "foo"

libraryDependencies += ProjectRef(file("../bar"), "bar")

The error says:

No implicit for Append.Value[Seq[sbt.ModuleID], sbt.ProjectRef] found, so sbt.ProjectRef cannot be appended to Seq[sbt.ModuleID].


I tend to prefer a build definition in project/Build.scala, instead of build.sbt. But the following code within the object Build should also do for a standard build.sbt.

import sbt._

object Build extends Build {
  lazy val projectA = project.in(file("a"))
  lazy val projectB = project.in(file("b")).dependsOn(projectA)


//your root build.scala
name := "test"

version := "1.0"

scalaVersion := "2.11.4"

val projectA = project.in(file("a"))
val projectB = project.in(file("b")).dependsOn(projectA)