简体   繁体   English

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

[英]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: 我刚开始使用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

The sample project depends on the AnormCypher project. 示例项目取决于AnormCypher项目。 I tried to set up the dependency following this SO post . 我尝试在此SO帖子之后设置依赖项。 My build.sbt in sample looks like this: 我的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)

When I go into my console and type 当我进入我的控制台并输入

activator

sbt is able to load the project. sbt能够加载项目。 But when I try to compile the sources and try to use classes from the org.anormcypher package, they can't be resolved: 但是当我尝试编译源代码并尝试使用org.anormcypher包中的类时,它们无法解析:

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

Running a clean compile also brought no results. 运行clean compile也没有带来任何结果。

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. reload ,项目应该正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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