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

牧云@^-^@ 提交于 2019-12-23 17:01:36

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/24262952/how-to-set-up-multi-module-build-with-reference-to-external-local-sbt-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!