通过排除依赖关系来调试sbt中的依赖性地狱

时间:2016-10-24 11:02:45

标签: scala sbt

我正在尝试调试我的sbt依赖地狱,但是几个小时后,我想我只是在我的深度。我的build.sbt

name := "MyProject"
version := "0.1.0"
scalaVersion := "2.11.8"

libraryDependencies ++= Seq(
  "org.scala-lang" % "scala-reflect" % scalaVersion.value,
  "org.scala-lang.modules" %% "scala-xml" % "1.0.5"
)

// ScalaTest
//libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.0"
//libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" % "test"
libraryDependencies ++= Seq(
  "org.scalatest" %% "scalatest" % "3.0.0" % "test"
  exclude("org.scala-lang", "scala-reflect")
  exclude("org.scala-lang.modules", "scala-xml")
)

// Linear Algebra Library Breeze
libraryDependencies  ++= Seq(
  // Last stable release
  "org.scalanlp" %% "breeze" % "0.12" exclude("junit", "junit"),

  // Native libraries are not included by default. add this if you want them (as of 0.7)
  // Native libraries greatly improve performance, but increase jar sizes.
  // It also packages various blas implementations, which have licenses that may or may not
  // be compatible with the Apache License. No GPL code, as best I know.
  "org.scalanlp" %% "breeze-natives" % "0.12",

  // The visualization library is distributed separately as well.
  // It depends on LGPL code
  "org.scalanlp" %% "breeze-viz" % "0.12"


)
resolvers += "Sonatype Releases" at "https://oss.sonatype.org/content/repositories/releases/"

// Plotting with WISP
libraryDependencies ++= Seq(
  "com.quantifind" %% "wisp" % "0.0.4"
    exclude("org.scala-lang", "scala-compiler")
    exclude("org.scala-lang.modules", "scala-parser-combinators")
    exclude("org.scala-lang.modules", "scala-xml")
)

// Logging
libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.5.0"
libraryDependencies += "ch.qos.logback" %  "logback-classic" % "1.1.7"

// My Dependencies
libraryDependencies += "junit" % "junit" % "4.11" % Test // https://mvnrepository.com/artifact/junit/junit
libraryDependencies += "org.slf4j" % "slf4j-simple" % "1.7.21" // https://mvnrepository.com/artifact/org.slf4j/slf4j-simple
libraryDependencies += "org.apache.commons" % "commons-math3" % "3.2" // https://mvnrepository.com/artifact/org.apache.commons/commons-math3
libraryDependencies += "net.java.dev.jna" % "jna" % "4.0.0" // https://mvnrepository.com/artifact/net.java.dev.jna/jna
libraryDependencies += "net.java.dev.jna" % "jna-platform" % "4.0.0" // https://mvnrepository.com/artifact/net.java.dev.jna/jna-platform
libraryDependencies += "commons-lang" % "commons-lang" % "2.6" // https://mvnrepository.com/artifact/commons-lang/commons-lang
libraryDependencies += "com.google.guava" % "guava" % "19.0" // https://mvnrepository.com/artifact/com.google.guava/guava

我收到了警告

SBT project import
            [warn] Multiple dependencies with the same organization/name but different versions. To avoid conflict, pick one version:
            [warn]  * org.scala-lang.modules:scala-parser-combinators_2.11:(1.0.1, 1.0.4)
            [warn]  * org.scala-lang.modules:scala-xml_2.11:(1.0.5, 1.0.4)
            [warn]  [FAILED     ] com.github.fommil.netlib#netlib-native_ref-osx-x86_64;1.1!netlib-native_ref-osx-x86_64.jar:  (0ms)
            [warn] ==== local: tried
            [warn]   /home/user/.ivy2/local/com.github.fommil.netlib/netlib-native_ref-osx-x86_64/1.1/jars/netlib-native_ref-osx-x86_64.jar
            [warn] ==== activator-local: tried
            [warn]   /Development/Activator/activator-dist-1.3.10/repository/com.github.fommil.netlib/netlib-native_ref-osx-x86_64/1.1/jars/netlib-native_ref-osx-x86_64.jar
            [warn] ==== activator-launcher-local: tried
            [warn]   /home/user/.activator/repository/com.github.fommil.netlib/netlib-native_ref-osx-x86_64/1.1/jars/netlib-native_ref-osx-x86_64.jar
            [warn] ==== public: tried
            [warn]   https://repo1.maven.org/maven2/com/git... 

还有更多东西。

1)首先,我试图摆脱有关多个版本的警告,我能够摆脱exclude的一些,但我无法摆脱你仍然看到的那些。我究竟做错了什么?我能够使用https://github.com/jrudolph/sbt-dependency-graph来查明WISP正在导入依赖项,而这些依赖项又会导入org.scala-lang.modules:scala-parser-combinators_2.11:1.0.1org.scala-lang.modules:scala-xml_2.11:1.0.1,但如何解决这些警告?

2)奇怪的是,我还有org.slf4j:slf4j-api的多个版本(通过org.scalanlp:breeze,ch.qos.logback:logback-classic和org.slf4j:slf4j-simple),但我没有得到任何警告。我在运行测试时只收到警告:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/raeg/.ivy2/cache/org.slf4j/slf4j-simple/jars/slf4j-simple-1.7.21.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/raeg/.ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.1.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]

为什么呢?我试图通过将我的各自build.sbt重写为

来摆脱这种情况
"org.scalanlp" %% "breeze" % "0.12" exclude("junit", "junit") exclude("org.slf4j", "slf4j-api"),

libraryDependencies += "ch.qos.logback" %  "logback-classic" % "1.1.7" exclude("org.slf4j", "slf4j-api")

但这没有帮助。

3)其他警告如何,我如何摆脱所有这些?还有更多,主要与com/github/fommil/netlib/netlib-native_ref-osx-x86_64/1.1/netlib-native_ref-osx-x86_64-1.1.jar

有关

我正在使用sbt.version = 0.13.8(来自project/build.properties)。

我的project/plugins.sbt

logLevel := Level.Warn

addSbtPlugin("com.artima.supersafe" % "sbtplugin" % "1.1.0")
// siehe http://www.scalatest.org/supersafe

addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.8.2")
// siehe https://github.com/jrudolph/sbt-dependency-graph

addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.8.0")
// siehe http://www.scalastyle.org/sbt.html

0 个答案:

没有答案