简体   繁体   中英

How to set up multi-module build with reference to external local sbt project?

I just started with Scala and Play and I'm trying to set up a multi build with sbt 0.13.5 My project structure is the following:

/AnormCypher
   -> /src
      ->/main
        ->/scala
          ->org.anormcypher[package]
              ->[Some classes]
   -> [other dirs/files]
   -> build.sbt
/sample
   -> /src
      ->/main
        ->/scala
          ->/controllers[package]
              ->Application.scala
              ->[Some classes]
   -> [other dirs/files]
   -> build.sbt

The sample project depends on the AnormCypher project. I tried to set up the dependency following this SO post . My build.sbt in sample looks like this:

name := """sample"""

version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayScala)

scalaVersion := "2.11.1"

libraryDependencies ++= Seq(
  jdbc,
  anorm,
  cache,
  ws
)

lazy val core = ProjectRef(file("../AnormCypher"), "anormcypher")

val main = root.dependsOn(core)

When I go into my console and type

activator

sbt is able to load the project. But when I try to compile the sources and try to use classes from the org.anormcypher package, they can't be resolved:

object anormcypher is not a member of package org
[error] import org.anormcypher._
[error]            ^

Running a clean compile also brought no results.

Change

lazy val root = (project in file(".")).enablePlugins(PlayScala)

to

lazy val root = (project in file(".")).enablePlugins(PlayScala).dependsOn(core)

and remove

val main = root.dependsOn(core)

reload and the project should work fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM