After adding
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" % "test"
to build.sbt , and refreshed the project, I got this msg.
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-xml_2.11:(1.0.5, 1.0.4)
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.0.0" % "test"
exclude("org.scala-lang", "scala-reflect")
exclude("org.scala-lang.modules", "scala-xml_2.11")
)
solves the issue. However, instead of excluding scala-xml_2.11 version 1.0.5 from scalatest, I would like to force the scala compiler to use scala-xml_2.11 version 1.0.5 instead of version 1.0.4. (I researched the versions at https://mvnrepository.com .) Thus I tried substituting scalaVersion := "2.11.8"
for
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % "2.11.8",
"org.scala-lang.modules" % "scala-xml_2.11" % "1.0.5"
)
This however results in
SBT project import
[warn] Binary version (2.11) for dependency org.scala-lang#scala-reflect;2.11.8
[warn] in default#myproject$sources_javadoc_2.10;1.0 differs from Scala binary version in project (2.10).
[warn] Binary version (2.11) for dependency org.scala-lang#scala-library;2.11.8
[warn] in default#myproject$sources_javadoc_2.10;1.0 differs from Scala binary version in project (2.10).
[warn] Multiple dependencies with the same organization/name but different versions. To avoid conflict, pick one version:
[warn] * org.scala-lang:scala-library:(2.11.8, 2.10.4)
[warn] * org.scala-lang:scala-reflect:(2.11.8, 2.10.4)
[warn] [FAILED ] com.artima.supersafe#supersafe_2.10.4;1.1.0!supersafe_2.10.4.jar(src): (0ms)
[warn] ==== local: tried
[warn]
/home/user/.ivy2/local/com.artima.supersafe/supersafe_2.10.4/1.1.0/srcs/supersafe_2.10.4-sources.jar[warn] ==== activator-local: tried [warn] /Development/Activator/activator-dist-1.3.10/repository/com.artima.supersafe/supersafe_2.1... (show balloon)
What am I supposed to do?
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.scalatest" %% "scalatest" % "3.0.0" % "test"
[warn] Multiple dependencies with the same organization/name but different versions. To avoid conflict, pick one version: [warn] * org.scala-lang.modules:scala-xml_2.11:(1.0.5, 1.0.4)
scalaVersion := "2.11.8"
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scala-lang.modules" %% "scala-xml_2.11" % "1.0.5"
)
// ScalaTest
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" % "test"
Error:Error while importing SBT project:
...[info] \nResolving org.scala-sbt#run;0.13.8 ... [info] Resolving\norg.scala-sbt#task-system;0.13.8 ... [info] Resolving \norg.scala-sbt#tasks;0.13.8 ... [info] Resolving \norg.scala-sbt#tracking;0.13.8 ... [info] Resolving \norg.scala-sbt#cache;0.13.8 ... [info] Resolving \norg.scala-sbt#testing;0.13.8 ... [info] Resolving \norg.scala-sbt#test-agent;0.13.8 ... [info] Resolving \norg.scala-sbt#test-interface;1.0 ... [info] Resolving \norg.scala-sbt#main-settings;0.13.8 ... [info] Resolving \norg.scala-sbt#apply-macro;0.13.8 ... [info] Resolving \norg.scala-sbt#command;0.13.8 ... [info] Resolving \norg.scala-sbt#logic;0.13.8 ... [info] Resolving \norg.scala-sbt#precompiled-2_8_2;0.13.8 ... [info] Resolving \norg.scala-sbt#precompiled-2_9_2;0.13.8 ... [info] Resolving \norg.scala-sbt#precompiled-2_9_3;0.13.8 ... [trace] Stack trace \nsuppressed: run 'last *:update' for the full output. [trace] Stack \ntrace suppressed: run 'last :ssExtractDependencies' for the full\noutput. [error] ( :update) sbt.ResolveException: unresolved \ndependency: org.scala-lang.modules#scala-xml_2.11_2.11;1.0.5: not\nfound [error] (*:ssExtractDependencies) sbt.ResolveException:\nunresolved dependency:\norg.scala-lang.modules#scala-xml_2.11_2.11;1.0.5: not found [error] \nTotal time: 4 s, completed 01.10.2016 17:46:55
scalaVersion := "2.11.8"
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scala-lang.modules" %% "scala-xml" % "1.0.5"
)
// ScalaTest
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.0.0" % "test"
exclude("org.scala-lang", "scala-reflect")
exclude("org.scala-lang.modules", "scala-xml")
)
[warn] Multiple dependencies with the same organization/name but different versions. To avoid conflict, pick one version: [warn] * org.scala-lang.modules:scala-xml_2.11:(1.0.5, 1.0.4)
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_2.11")
)
The way to exclude specific transitive dependency is this:
Run sbt evicted
to figure out which of the project dependencies is pulling in outdated library, let's assume the problematic library is: com.typesafe.slick
.
Add the following exclude (the parentheses are important):
("com.typesafe" %% "slick" % "3.1.1").exclude("org.scala-lang.modules", "scala-xml_2.11")
Add this normally as you would be listing dependencies.
This will prevent sbt from including any version of scala-xml
that was coming in as a transitive dependency of Slick.
Don't substitute; you need both scalaVersion
and libraryDependencies
. Though use
scalaVersion := "2.11.8"
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scala-lang.modules" %% "scala-xml" % "1.0.5"
)
to avoid bugs when you eventually change scalaVersion
.
By removing scalaVersion
you get default scalaVersion := "2.10.4"
(with your version/settings of SBT, at least) but your libraryDependencies
still require 2.11.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.