#scala #sbt
#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
s, но я не могу избавиться от тех, которые вы все еще видите. Что я делаю не так? Я смог использовать https://github.com/jrudolph/sbt-dependency-graph чтобы выяснить, что WISP импортирует зависимости, которые, в свою очередь, импортируют org.scala-lang.modules:scala-parser-combinators_2.11:1.0.1
и org.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
Комментарии:
1. Я скопировал ваш
build.sbt
, и он разрешил все зависимости без каких-либо предупреждений. Какую версию sbt вы используете? Используете ли вы какие-либо плагины sbt? Когда вы получаете предупреждения,sbt update
?2. @laughedelic: Помогает ли это?
3. первый плагин не разрешает, вам следует добавить для него какой-нибудь распознаватель. Игнорируя это, я не могу воспроизвести никаких проблем, все решается и обновляется нормально.
4. @laughedelic: У меня есть распознаватель
resolvers = "Sonatype Releases" at "https://oss.sonatype.org/content/repositories/releases/"
— он упоминается вbuild.sbt
.5. этот преобразователь находится в
build.sbt
, я говорю оcom.artima.supersafe:sbtplugin:1.1.0
преобразователе плагинов. В любом случае, я не думаю, что этот плагин как-то связан. Я пытался и не смог воспроизвести ваши проблемы. Было бы полезно иметь минимальный проект (клонируемый репозиторий где-нибудь вроде github), который воспроизводит ситуацию.