如何参考外部本地sbt项目设置多模块构建?

时间:2014-06-17 11:46:20

标签: scala playframework playframework-2.0 sbt

我刚开始使用Scala和Play,我正在尝试使用sbt 0.13.5设置多重构建 我的项目结构如下:

/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

示例项目取决于AnormCypher项目。我尝试在this SO post之后设置依赖项。样本中的build.sbt如下所示:

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)

当我进入我的控制台并输入

activator

sbt能够加载项目。但是当我尝试编译源代码并尝试使用org.anormcypher包中的类时,它们无法解析:

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

运行clean compile也没有带来任何结果。

1 个答案:

答案 0 :(得分:4)

更改

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

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

并删除

val main = root.dependsOn(core)

reload,项目应该可以正常工作。