2

我有一个由三个项目 A、B 和 C 组成的项目树

B依赖于A,C同时依赖于A和B。

A 和 B 在 C 的 lib/ 中签出,并且都使用sbt compile

但是,当我编译 C 时,B 的构建失败,抱怨它找不到某些类型/包:

import org.scalatra.sbt._
import sbt.Keys._
import sbt._

object NwbApiBuild extends Build {
  val Organization = "org.nwb"
  val Name = "NWB API"
  val Version = "0.1.0-SNAPSHOT"
  val ScalaVersion = "2.10.3"
  val ScalatraVersion = "2.3.0"

  lazy val active_slick= Project (
    "active-slick",
    base = file("lib/active-slick")
  )

  lazy val slick_auth= Project (
    "slick-auth",
    base = file("lib/slick-auth")
  )

  lazy val project = Project (
    "root",
    file("."),
    settings = Defaults.defaultSettings ++ ScalatraPlugin.scalatraWithJRebel ++ Seq(
      organization := Organization,
      name := Name,
      version := Version,
      scalaVersion := ScalaVersion,
      resolvers += Classpaths.typesafeReleases,
      libraryDependencies ++= Seq(
        "org.scalatra" %% "scalatra" % ScalatraVersion,
        "org.scalatra" %% "scalatra-specs2" % ScalatraVersion % "test",
        "ch.qos.logback" % "logback-classic" % "1.0.6" % "runtime",
        "org.eclipse.jetty" % "jetty-webapp" % "8.1.8.v20121106" % "container",
        "org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "container;provided;test" artifacts (Artifact("javax.servlet", "jar", "jar")),
        "com.typesafe.slick" %% "slick" % "2.0.2",
        "mysql" % "mysql-connector-java" % "5.1.31",
        "joda-time" % "joda-time" % "2.3",
        "org.joda" % "joda-convert" % "1.5",
        "com.github.tototoshi" %% "slick-joda-mapper" % "1.1.0",
        "org.json4s" %% "json4s-native" % "3.2.10",
        "org.json4s"   %% "json4s-jackson" % "3.2.7",
        "c3p0" % "c3p0" % "0.9.1.2"
      )
    )
  ) aggregate(active_slick, slick_auth) dependsOn(active_slick, slick_auth)
}

光滑的身份验证有构建文件的地方

import org.scalatra.sbt._

name := "slick-auth"

version := "0.0.1-SNAPSHOT"

scalaVersion := "2.10.3"

val ScalatraVersion = "2.3.0"

lazy val active_slick = Project(
  "active-slick",
  base = file("lib/active-slick")
)

lazy val root = Project(
  "root",
  file("."),
  settings = Defaults.defaultSettings ++ ScalatraPlugin.scalatraSettings ++ Seq(
    libraryDependencies ++= Seq(
      "com.typesafe.slick" %% "slick" % "2.0.2",
      "org.slf4j" % "slf4j-nop" % "1.6.4",
      "org.scalatest" %% "scalatest" % "2.2.0" % "test",
      "org.scalatra" %% "scalatra" % ScalatraVersion,
      "org.scalatra" %% "scalatra-specs2" % ScalatraVersion % "test",
      "ch.qos.logback" % "logback-classic" % "1.0.6" % "runtime",
      "org.eclipse.jetty" % "jetty-webapp" % "8.1.8.v20121106" % "container",
      "org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "container;provided;test" artifacts (Artifact("javax.servlet", "jar", "jar")),
      "com.typesafe.slick" %% "slick" % "2.0.2",
      "joda-time" % "joda-time" % "2.3",
      "org.joda" % "joda-convert" % "1.5",
      "com.github.tototoshi" %% "slick-joda-mapper" % "1.1.0",
      "org.json4s" %% "json4s-native" % "3.2.10",
      "org.json4s"   %% "json4s-jackson" % "3.2.7",
      "c3p0" % "c3p0" % "0.9.1.2"
    )
  )
).aggregate(active_slick).dependsOn(active_slick)

和active_slick:

name := "active-slick"

version := "0.0.1-SNAPSHOT"

scalaVersion := "2.10.3"

libraryDependencies ++= Seq(
  "com.typesafe.slick" %% "slick" % "2.0.2",
  "org.slf4j" % "slf4j-nop" % "1.6.4",
  "org.scalatest" %% "scalatest" % "2.2.0" % "test",
  "com.h2database" % "h2" % "1.3.166" % "test"
)
4

1 回答 1

2

如果您想使用另一个项目作为依赖项(而不是其二进制版本),您可以使用项目引用。有两种类型的引用,ProjectRef或者是 的更简单版本ProjectRef,即RootProject.

您应该更改构建定义以引用slick_auth

lazy val slick_auth = RootProject(file("lib/slick-auth"))

并且active_slick作为

lazy val active_slick = RootProject(file("lib/active-slick"))
于 2014-07-23T04:29:38.933 回答