0

I am trying to setup a multi-project that includes a sub-project that does an import of a class that is defined in a Dependencies.scala file in its project directory. When I run sbt on the sub-project everything is fine but when I run sbt on the root project I get an error stating that Dependencies is not found. Here is my root build.sbt:

name         := "sbtTest"

organization := "com.test"

version      := "0.1"



lazy val foo = project

Here is foo's build.sbt:

import Dependencies._

name := "foo"

version := "0.2"


scalaVersion := "2.10.6"

Dependencies.scala is in foo/projects and here is the exact error I get:

/Users/xyz/git/sbtTest/foo/build.sbt:1: error: not found: object Dependencies

import Dependencies._
       ^
[error] Type error in expression

Has anyone run into this problem?

Antonio Ye
  • 51
  • 5

2 Answers2

0

I fixed this by making my build.sbt look like this..

lazy val otherProject = RootProject(file("../otherproject"))

lazy val rootProject = (project in file("."))
    // dependsOn allows the root project to use functions from
    .dependsOn(otherProject)
    // aggregation runs tasks of root project on aggregated projects as well
    .aggregate(otherProject)
Losmoges
  • 1
  • 1
  • I tried this but project foo does not get included when I use RootProject. If I compile foo does not compile and if I run 'sbt projects' foo is not listed. – Antonio Ye May 12 '17 at 17:04
  • You will need .dependsOn and .aggregate on your root project. I will edit my answer with the whole solution. – Losmoges May 15 '17 at 19:47
-1

In sbt you can also define all dependencies in a separated file. This file tends to be in /project/Dependencies.scala In the same directory than plugins.sbt.

Then import Dependencies._ can be easy imported in build.sbt file.

thor-tech
  • 62
  • 3