【发布时间】:2013-12-09 04:27:20
【问题描述】:
我有多个项目 A、B、C。有些是实用程序库,有些是应用程序。
如果我有依赖层次结构 A->B->C 并使用本地发布,我必须在 A 中包含依赖 B 和 C。即使 A 不直接使用 C 中的任何内容(仅通过代理)。就好像所有项目 B 依赖项都添加了提供的范围。
为什么这些依赖项不会被解析并添加到类路径中?
这不是一个多项目 Build.scala(故意)我有几个简化的构建文件,我希望它们能够独立构建。
我在启动应用程序 A 时使用了命令 re-start (Revolver)。
/马格纳斯
示例配置 在此示例中,我必须包含多个库(充气城堡),这些库仅在以下库之一中真正使用(均使用 publish-local 发布)
"mollyware" %% "fulla-utils" % fulla,
"mollyware" %% "brage-http" % brage,
"mollyware" %% "saga-domain" % saga,
串联的 build.sbt 文件
scalaVersion := "2.10.3"
name := "mimer-idp"
organization := "mollyware"
version := "0.0.1"
import scalariform.formatter.preferences._
net.virtualvoid.sbt.graph.Plugin.graphSettings
// compile options
scalacOptions ++= Seq(
"-encoding",
"UTF-8",
"-optimise",
"-deprecation",
"-unchecked",
"-feature",
"-Yinline-warnings"
)
javacOptions ++= Seq(
"-Xlint:unchecked",
"-Xlint:deprecation"
)
resolvers += Classpaths.typesafeReleases
resolvers ++= Seq(
"Spray repo" at "http://repo.spray.io",
"Spray nightlies" at "http://nightlies.spray.io",
"Sonatype Snapshot Repo" at "http://oss.sonatype.org/content/repositories/snapshots/"
)
scalariformSettings
ScalariformKeys.preferences := FormattingPreferences()
.setPreference( RewriteArrowSymbols, true )
.setPreference( AlignParameters, true )
.setPreference( AlignSingleLineCaseStatements, true )
.setPreference( SpaceInsideParentheses, true )
.setPreference( DoubleIndentClassDeclaration, true )
.setPreference( PreserveDanglingCloseParenthesis, true )
libraryDependencies <<= scalaVersion { scala_version =>
val akka = "2.2.1"
val ampq = "1.3-SNAPSHOT"
val spray = "1.2.0"
val sprayJson = "1.2.5"
val fulla = "0.0.1"
val brage = "0.0.1"
val saga = "0.0.1"
val scalaTest = "2.0.RC2"
val commons = "1.7"
val bcastle = "1.49"
Seq(
"io.spray" % "spray-routing" % spray,
"io.spray" % "spray-can" % spray,
"io.spray" % "spray-http" % spray,
"io.spray" % "spray-client" % spray,
"io.spray" % "spray-testkit" % spray % "test",
"io.spray" %% "spray-json" % sprayJson,
"com.typesafe.akka" %% "akka-actor" % akka,
"com.typesafe.akka" %% "akka-remote" % akka,
"com.github.sstone" %% "amqp-client" % ampq,
"mollyware" %% "fulla-utils" % fulla,
"mollyware" %% "brage-http" % brage,
"mollyware" %% "saga-domain" % saga,
"commons-codec" % "commons-codec" % commons,
"org.scalatest" % "scalatest_2.10" % scalaTest % "test",
"org.bouncycastle" % "bcprov-jdk15on" % bcastle,
"org.bouncycastle" % "bcpkix-jdk15on" % bcastle
)
}
import sbtassembly.Plugin._
import AssemblyKeys._
import spray.revolver.RevolverPlugin._
assemblySettings
assembleArtifact in packageScala := false
assembleArtifact in packageDependency := true
assemblyOption in packageDependency ~= { _.copy(includeScala = false) }
Revolver.settings
【问题讨论】:
-
您的问题对于具体发生的事情非常模糊。也许你可以添加一些真实的配置源和日志输出。
-
它非常模糊,因为它是一个普遍的问题,与一个特定的包无关。完成此评论后,我将在上面添加一个示例配置。例如,如果我在上面的“B”中依赖 spray-json,我需要在“A”中包含 spray-json,否则我会得到 class not found 异常。它不会包含任何两次删除的依赖项。当我使用本地发布时,这似乎是某种东西。因为我没有得到相同的第 3 方包(如果 spray-json 反过来取决于它的工作原理)。