I'm newish to SBT and am not sure what to do about a rather scary warning from the evicted task: [warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
The full task output is...
sbt:Sprout> evicted
[info] Updating ...
[info] Done updating.
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[warn] Found version conflict(s) in library dependencies; some are suspected to be binary incompatible:
[warn] * org.scala-lang.modules:scala-xml_2.12:1.1.0 is selected over 1.0.6
[warn] +- org.json4s:json4s-xml_2.12:3.6.3 (depends on 1.1.0)
[warn] +- org.scalatra:scalatra_2.12:2.6.5 (depends on 1.0.6)
[warn] +- com.typesafe.play:twirl-api_2.12:1.3.13 (depends on 1.0.6)
[info] Here are other dependency conflicts that were resolved:
[info] * org.json4s:json4s-core_2.12:3.6.5 is selected over 3.6.3
[info] +- org.json4s:json4s-jackson_2.12:3.6.5 (depends on 3.6.5)
[info] +- org.json4s:json4s-xml_2.12:3.6.3 (depends on 3.6.3)
[info] +- org.scalatra:scalatra-json_2.12:2.6.5 (depends on 3.6.3)
[info] * org.json4s:json4s-scalap_2.12:3.6.5 is selected over 3.6.3
[info] +- org.json4s:json4s-core_2.12:3.6.5 (depends on 3.6.5)
[info] +- org.json4s:json4s-core_2.12:3.6.3 (depends on 3.6.3)
[info] * org.json4s:json4s-ast_2.12:3.6.5 is selected over 3.6.3
[info] +- org.json4s:json4s-core_2.12:3.6.5 (depends on 3.6.5)
[info] +- org.json4s:json4s-core_2.12:3.6.3 (depends on 3.6.3)
[success] Total time: 1 s, completed Apr 13, 2019 12:53:54 PM
"suspected binary incompatible" sound serious. Is it?
Is there just some exclude that I can tag onto the dependencies to get the dependencies in agreement as to what the correct versions are?
The SBT dependencies are like...
libraryDependencies ++= Seq(
"org.scalatra" %% "scalatra" % ScalatraVersion exclude("org.slf4j","slf4j-api"),
"org.scalatra" %% "scalatra-scalatest" % ScalatraVersion % "test",
"org.slf4j" % "slf4j-api" % "1.7.26",
"ch.qos.logback" % "logback-classic" % "1.2.3" % "runtime",
"org.eclipse.jetty" % "jetty-webapp" % "9.4.9.v20180320" % "container",
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
"org.scalatra" %% "scalatra-json" % ScalatraVersion,
"org.json4s" %% "json4s-jackson" % "3.6.5",
)
This warning appears because org.scalatra:scalatra_2.12:2.6.5 & com.typesafe.play:twirl-api_2.12:1.3.13 depends on org.scala-lang.modules:scala-xml_2.12:1.0.6, but org.json4s:json4s-xml_2.12:3.6.3 uses org.scala-lang.modules:scala-xml_2.12:1.1.0
In order to hide this warning, you can use dependencyOverrides:
dependencyOverrides += "org.scala-lang.modules" % "scala-xml_2.12" % "1.0.6"
Again, it will just hide the warning, but it doesn't guarantee compatibility between your libraries and the version you set.
Ideally we should resolve evection warnings instead of override, if at all possible, due to potentially introducing hard-to-trace bugs. In this case it is possible if we are willing to drop scalatra and json4s-jackson versions to 2.6.4 and 3.5.2, respectively, like so:
val ScalatraVersion = "2.6.4"
libraryDependencies ++= Seq(
"org.scalatra" %% "scalatra" % ScalatraVersion exclude("org.slf4j","slf4j-api"),
"org.scalatra" %% "scalatra-scalatest" % ScalatraVersion % "test",
"org.slf4j" % "slf4j-api" % "1.7.26",
"ch.qos.logback" % "logback-classic" % "1.2.3" % "runtime",
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
"org.scalatra" %% "scalatra-json" % ScalatraVersion,
"org.json4s" %% "json4s-jackson" % "3.5.2",
)
Related
I'm new in scala world (coming from android world), I have created scala project with play-framework, everything works fine now I need to add database and for that I decided to chose slick, but when I'm trying to add dependency like that
libraryDependencies ++= Seq(
"com.typesafe.slick" %% "slick" % "3.1.0",
"org.slf4j" % "slf4j-nop" % "1.6.4"
)
I'm getting this error log
Error:Error while importing SBT project:<br/>...<br/><pre>[info] Resolving com.typesafe#jse_2.10;1.2.3 ...
[info] Resolving org.scala-sbt#run;0.13.15 ...
[info] Resolving org.scala-sbt.ivy#ivy;2.3.0-sbt-48dd0744422128446aee9ac31aa356ee203cc9f4 ...
[info] Resolving com.typesafe.play#play-exceptions;2.6.5 ...
[info] Resolving org.scala-sbt#test-interface;1.0 ...
[info] Resolving com.jcraft#jsch;0.1.50 ...
[info] Resolving org.scala-lang#scala-compiler;2.10.6 ...
[info] Resolving jline#jline;2.14.3 ...
[info] Resolving org.scala-sbt#compiler-ivy-integration;0.13.15 ...
[info] Resolving org.scala-sbt#incremental-compiler;0.13.15 ...
[info] Resolving org.scala-sbt#logic;0.13.15 ...
[info] Resolving com.typesafe#config;1.3.1 ...
[info] Resolving org.scala-sbt#main-settings;0.13.15 ...
[info] Resolving com.lightbend.play#play-file-watch_2.10;1.0.0 ...
[info] Resolving com.typesafe.play#sbt-plugin;2.6.5 ...
[trace] Stack trace suppressed: run 'last *:ssExtractDependencies' for the full output.
[trace] Stack trace suppressed: run 'last *:update' for the full output.
[error] (*:ssExtractDependencies) sbt.ResolveException: unresolved dependency: com.typesafe.slick#slick_2.12;3.1.0: not found
[error] (*:update) sbt.ResolveException: unresolved dependency: com.typesafe.slick#slick_2.12;3.1.0: not found
[error] Total time: 4 s, completed Sep 28, 2017 12:21:57 PM</pre><br/>See complete log in file:/home/dev-00/.IntelliJIdea2017.1/system/log/sbt.last.log
here is my hole sbt build script
name := """play-scala-starter-example"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
resolvers += Resolver.sonatypeRepo("snapshots")
scalaVersion := "2.12.2"
libraryDependencies ++= Seq(
"com.typesafe.slick" %% "slick" % "3.1.0",
"org.slf4j" % "slf4j-nop" % "1.6.4"
)
libraryDependencies ++= Seq(
jdbc,
"com.typesafe.play" %% "anorm" % "2.5.3"
)
libraryDependencies += guice
libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "3.0.0" % Test
libraryDependencies += "com.h2database" % "h2" % "1.4.194"
libraryDependencies += jdbc
libraryDependencies += "mysql" % "mysql-connector-java" % "5.1.41"
From what I find on maven, it seems only few versions of slick are compiled against scala 2.12:
3.2.1
3.2.0
2.1.0
see: http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.typesafe.slick%22%20AND%20a%3A%22slick_2.12%22
Either use a more recent version of slick or another scala version (2.11.x).
Add the following line to your build.sbt
resolvers += "typesafe" at "http://repo.typesafe.com/typesafe/releases/"
I'm working on Spark application which is build using sbt,scalatra when i compile a project, i get following error
$ my-spark-app git:(master) ✗ sbt
[info] Loading project definition from /home/limitless/Documents/projects/test/my-spark-app/project
[info] Updating {file:/home/limitless/Documents/projects/test/my-spark-app/project/}my-spark-app-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Compiling 1 Scala source to /home/limitless/Documents/projects/test/my-spark-app/project/target/scala-2.10/sbt-0.13/classes...
[info] Set current project to My Spark App Server (in build file:/home/limitless/Documents/projects/test/my-spark-app/)
> ~;jetty:stop;jetty:stop
[success] Total time: 0 s, completed Aug 31, 2017 4:43:47 PM
[success] Total time: 0 s, completed Aug 31, 2017 4:43:47 PM
1. Waiting for source changes... (press enter to interrupt)
> ~;jetty:stop;jetty:start
[success] Total time: 0 s, completed Aug 31, 2017 4:43:53 PM
[info] Updating {file:/home/limitless/Documents/projects/test/my-spark-app/}my-spark-app-server...
[info] Generating /home/limitless/Documents/projects/test/my-spark-app/target/scala-2.11/resource_managed/main/rebel.xml.
[info] Resolving org.scala-lang#scala-reflect;2.11.0 ...
[info] Done updating.
[info] Compiling Templates in Template Directory: /home/limitless/Documents/projects/test/my-spark-app/src/main/webapp/WEB-INF/templates
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[info] Compiling 5 Scala sources to /home/limitless/Documents/projects/test/my-spark-app/target/scala-2.11/classes...
[info] Packaging /home/limitless/Documents/projects/test/my-spark-app/target/scala-2.11/my-spark-app-server_2.11-0.1.0-SNAPSHOT.jar ...
[info] Done packaging.
[info] starting server ...
[success] Total time: 29 s, completed Aug 31, 2017 4:44:22 PM
1. Waiting for source changes... (press enter to interrupt)
2017-08-31 16:44:22.686:INFO::main: Logging initialized #106ms
2017-08-31 16:44:22.691:INFO:oejr.Runner:main: Runner
2017-08-31 16:44:22.766:INFO:oejs.Server:main: jetty-9.2.1.v20140609
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/limitless/Documents/projects/test/my-spark-app/target/webapp/WEB-INF/lib/slf4j-log4j12-1.7.16.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/limitless/Documents/projects/test/my-spark-app/target/webapp/WEB-INF/lib/logback-classic-1.1.5.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.Log4jLoggerFactory]
2017-08-31 16:44:31.657:WARN:oejuc.AbstractLifeCycle:main: FAILED org.eclipse.jetty.annotations.ServletContainerInitializersStarter#59309333: java.lang.NoClassDefFoundError: com/sun/jersey/spi/inject/InjectableProvider
java.lang.NoClassDefFoundError: com/sun/jersey/spi/inject/InjectableProvider
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
build.scala
import sbt._
import Keys._
import org.scalatra.sbt._
import org.scalatra.sbt.PluginKeys._
import com.earldouglas.xwp.JettyPlugin
import com.mojolly.scalate.ScalatePlugin._
import ScalateKeys._
object MySparkAppServerBuild extends Build {
val Organization = "com.learning"
val Name = "My Spark App Server"
val Version = "0.1.0-SNAPSHOT"
val ScalaVersion = "2.11.8"
val ScalatraVersion = "2.5.1"
val SparkVersion = "2.2.0"
lazy val project = Project (
"my-spark-app-server",
file("."),
settings = ScalatraPlugin.scalatraWithJRebel ++ scalateSettings ++ Seq(
organization := Organization,
name := Name,
version := Version,
scalaVersion := ScalaVersion,
resolvers += Classpaths.typesafeReleases,
resolvers += "Scalaz Bintray Repo" at "http://dl.bintray.com/scalaz/releases",
resolvers += Resolver.mavenLocal,
libraryDependencies ++= Seq(
"junit" % "junit" % "4.12" % "test",
"org.scalatra" %% "scalatra" % ScalatraVersion,
"org.scalatra" %% "scalatra-scalate" % ScalatraVersion,
"org.scalatra" %% "scalatra-specs2" % ScalatraVersion % "test",
"ch.qos.logback" % "logback-classic" % "1.1.5" % "runtime",
"org.eclipse.jetty" % "jetty-webapp" % "9.2.15.v20160210" % "container",
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
"org.apache.spark" %% "spark-core" % SparkVersion
),
scalateTemplateConfig in Compile <<= (sourceDirectory in Compile){ base =>
Seq(
TemplateConfig(
base / "webapp" / "WEB-INF" / "templates",
Seq.empty, /* default imports should be added here */
Seq(
Binding("context", "_root_.org.scalatra.scalate.ScalatraRenderContext", importMembers = true, isImplicit = true)
), /* add extra bindings here */
Some("templates")
)
)
}
)
).enablePlugins(JettyPlugin)
}
I added this "com.sun.jersey" % "jersey-bundle" % "1.19.2" library in my build.scala file and my problem is resolved
libraryDependencies ++= Seq(
"junit" % "junit" % "4.12" % "test",
"org.scalatra" %% "scalatra" % ScalatraVersion,
"org.scalatra" %% "scalatra-scalate" % ScalatraVersion,
"org.scalatra" %% "scalatra-specs2" % ScalatraVersion % "test",
"ch.qos.logback" % "logback-classic" % "1.1.5" % "runtime",
"org.eclipse.jetty" % "jetty-webapp" % "9.2.15.v20160210" % "container",
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
"org.apache.spark" %% "spark-core" % SparkVersion,
"com.sun.jersey" % "jersey-bundle" % "1.19.2"
)
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)
Changing the above to
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?
Edit: What else I tried and did not work:
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]
Resolving org.scala-sbt#run;0.13.8 ... [info] Resolving
org.scala-sbt#task-system;0.13.8 ... [info] Resolving
org.scala-sbt#tasks;0.13.8 ... [info] Resolving
org.scala-sbt#tracking;0.13.8 ... [info] Resolving
org.scala-sbt#cache;0.13.8 ... [info] Resolving
org.scala-sbt#testing;0.13.8 ... [info] Resolving
org.scala-sbt#test-agent;0.13.8 ... [info] Resolving
org.scala-sbt#test-interface;1.0 ... [info] Resolving
org.scala-sbt#main-settings;0.13.8 ... [info] Resolving
org.scala-sbt#apply-macro;0.13.8 ... [info] Resolving
org.scala-sbt#command;0.13.8 ... [info] Resolving
org.scala-sbt#logic;0.13.8 ... [info] Resolving
org.scala-sbt#precompiled-2_8_2;0.13.8 ... [info] Resolving
org.scala-sbt#precompiled-2_9_2;0.13.8 ... [info] Resolving
org.scala-sbt#precompiled-2_9_3;0.13.8 ... [trace] Stack trace
suppressed: run 'last *:update' for the full output. [trace] Stack
trace suppressed: run 'last :ssExtractDependencies' for the full
output. [error] (:update) sbt.ResolveException: unresolved
dependency: org.scala-lang.modules#scala-xml_2.11_2.11;1.0.5: not
found [error] (*:ssExtractDependencies) sbt.ResolveException:
unresolved dependency:
org.scala-lang.modules#scala-xml_2.11_2.11;1.0.5: not found [error]
Total 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)
My 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.
My sbt project takes more than 15 minutes when I do
sbt clean compile
I am on a beefy machine on AWS. I am fairly certain its not a resource issue on cpu or internet bandwidth. Also, I have run this command a few times and hence the ivy cache is populated.
Here is all my build related files
/build.sbt
name := "ProjectX"
version := "1.0"
scalaVersion := "2.10.5"
libraryDependencies += ("org.apache.spark" %% "spark-streaming" % "1.4.1")
.exclude("org.slf4j", "slf4j-log4j12")
.exclude("log4j", "log4j")
.exclude("commons-logging", "commons-logging")
.%("provided")
libraryDependencies += ("org.apache.spark" %% "spark-streaming-kinesis-asl" % "1.4.1")
.exclude("org.slf4j", "slf4j-log4j12")
.exclude("log4j", "log4j")
.exclude("commons-logging", "commons-logging")
libraryDependencies += "org.mongodb" %% "casbah" % "2.8.1"
//test
libraryDependencies += "org.scalatest" %% "scalatest" % "2.2.4" % "test"
//logging
libraryDependencies ++= Seq(
//facade
"org.slf4j" % "slf4j-api" % "1.7.12",
"org.clapper" %% "grizzled-slf4j" % "1.0.2",
//jcl (used by aws sdks)
"org.slf4j" % "jcl-over-slf4j" % "1.7.12",
//log4j1 (spark)
"org.slf4j" % "log4j-over-slf4j" % "1.7.12",
//log4j2
"org.apache.logging.log4j" % "log4j-api" % "2.3",
"org.apache.logging.log4j" % "log4j-core" % "2.3",
"org.apache.logging.log4j" % "log4j-slf4j-impl" % "2.3"
//alternative to log4j2
//"org.slf4j" % "slf4j-simple" % "1.7.5"
)
/project/build.properties
sbt.version = 0.13.8
/project/plugins.sbt
logLevel := Level.Warn
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.7.0")
resolvers += "sonatype-releases" at "https://oss.sonatype.org/content/repositories/releases/"
/project/assembly.sbt
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.13.0")
On the log do you see entries like:
[info] [SUCCESSFUL ] org.apache.spark#spark-streaming-kinesis-asl_2.10;1.4.1!spark-streaming-kinesis-asl_2.10.jar (239ms)
That's a sign that you're downloading these artifacts. In other words, the AMI you're launching doesn't have the Ivy cache populated.
Using sbt 0.13.12 on my laptop with SSD, I get about 5s for clean and then update.
so-31956971> update
[info] Updating {file:/xxx/so-31956971/}app...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[success] Total time: 5 s, completed Aug 25, 2016 4:00:00 AM
I have an sbt project with these dependencies:
libraryDependencies ++= Seq(
"org.scalatra" %% "scalatra" % ScalatraVersion,
"org.scalatra" %% "scalatra-scalate" % ScalatraVersion,
"org.scalatra" %% "scalatra-specs2" % ScalatraVersion % "test",
"ch.qos.logback" % "logback-classic" % "1.1.2" % "runtime",
"org.eclipse.jetty" % "jetty-webapp" % "9.1.5.v20140505" % "container",
"org.eclipse.jetty" % "jetty-plus" % "9.1.5.v20140505" % "container",
"javax.servlet" % "javax.servlet-api" % "3.1.0",
"org.sorm-framework" % "sorm" % "0.3.18",
"com.h2database" % "h2" % "1.4.187",
"org.fusesource.scalamd" % "scalamd_2.10" % "1.6"
)
On one machine, I can run ./sbt without issue; on the other, I get
[error] Modules were resolved with conflicting cross-version suffixes in {file:/C:/dev/scalaspace/game-tracker/}game-tracker:
[error] org.scala-lang.modules:scala-xml _2.11, _2.12.0-M1
[error] org.scala-lang.modules:scala-parser-combinators _2.11, _2.12.0-M1
I've already isolated the problem and the fix. Sorm depends on the 2.12.0-M1 compiler:
[info] +-org.sorm-framework:sorm:0.3.18 [S]
[info] +-com.github.nikita-volkov:embrace:0.1.4 [S]
[info] | +-org.scala-lang:scala-compiler:2.12.0-M1 [S]
[info] | +-org.scala-lang.modules:scala-parser-combinators_2.12.0-M1:1.0.4 [S]
[info] | +-org.scala-lang.modules:scala-xml_2.12.0-M1:1.0.4 [S]
[info] | +-org.scala-lang:scala-reflect:2.11.0 [S] (evicted by: 2.11.6)
[info] | +-org.scala-lang:scala-reflect:2.11.6 [S]
[info] | +-org.scala-lang:scala-reflect:2.12.0-M1 (evicted by: 2.11.0)
I can make the project build in both locations by adding exclude("org.scala-lang","scala-compiler") to the sorm dependency. But why is the behavior inconsistent? Both environments are using the same version of sbt (0.13.8) and scala (2.11.6). What's different?
Given the pom for com.github.nikita-volkov:embrace, I'm guessing it's due to the use of version ranges combined with caching:
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>[2.10,3)</version>
<scope>compile</scope>
</dependency>
Particularly given that Scala 2.12.0-M1 was release yesterday:
http://www.scala-lang.org/news/2.12.0-M1
To fix the inconsistency you want to clear your ivy cache:
rm -r ~/.ivy2/cache
However you also want to fix the version of scala-compiler use, and you want it to match your configured scalaVersion:
dependencyOverrides += "org.scala-lang" % "scala-compiler" % scalaVersion.value
See more details in the Overriding a version section of the Library Management docs.