parboiled2 and Spray cause conflicting cross-version suffixes

1.3k views Asked by At

I'm trying to add parboiled2 as a dependency to my project, and follow the Calculator example but it conflicts with spray.

My current build.sbt file includes:

"io.spray" %% "spray-json" % "1.3.1" withSources() withJavadoc(),
"io.spray" %% "spray-can" % sprayV withSources() withJavadoc(),
"io.spray" %% "spray-routing" % sprayV withSources() withJavadoc(),
"io.spray" %% "spray-testkit" % sprayV  % "test" withSources() withJavadoc(),

When I add

"org.parboiled" %% "parboiled" % "2.0.1" withSources() withJavadoc(),

I get

[error] Modules were resolved with conflicting cross-version suffixes in {file:/blar/blar}blar-blar:
[error]    com.chuusai:shapeless _2.10.4, _2.10
[error]    org.scalamacros:quasiquotes _2.10, _2.10.3
java.lang.RuntimeException: Conflicting cross-version suffixes in: com.chuusai:shapeless, org.scalamacros:quasiquotes

So did some googling, and as usual people suggest using the exclude directive of SBT (which I don't believe makes logical sense as it will inevitably result in problems like ClassNotFoundException and NoSuchMethodError). I tried it nevertheless:

"org.parboiled" %% "parboiled" % "2.0.1" withSources() withJavadoc() 
  exclude("com.chuusai", "shapeless_2.10.4") exclude("org.scalamacros", "quasiquotes_2.10")

And surprise surprise when I try to run assembly I get

[error] java.lang.ClassNotFoundException: scala.quasiquotes.QuasiquoteCompat$

I also get a load more errors:

[error] bad symbolic reference
. A signature in RuleDSLBasics.class refers to term internal
[error] in package scala.reflect which is not available.
[error] It may be completely missing from the current classpath, or the version on
[error] the classpath might be incompatible with the version used when compiling RuleDSLBasics.class.
[error] error while loading RuleDSLBasics, Missing dependency 'bad symbolic reference. A signature in RuleDSLBasics.class refers to term annotations
[error] in value scala.reflect.internal which is not available.
[error] It may be completely missing from the current classpath, or the version on
[error] the classpath might be incompatible with the version used when compiling RuleDSLBasics.class.', required by ...

If I comment out the Spray dependencies (and code) I can successfully assembly a jar with the Calculator example.

This is a major show stopper for me using parboiled2. Is there some way other than exclude directives in order to make this stuff work? Does anyone have a working build file with both Spray and parboiled2? If someone has managed to get around dependency hell with onejar or ProGuard I'd love it if they could explain just how.

UPDATE:

My build file:

resolvers ++= Seq(
  "Concurrent Maven Repo" at "http://conjars.org/repo",
  "spray repo" at "http://repo.spray.io"
)

val akkaV = "2.3.6"
val sprayV = "1.3.2"

libraryDependencies ++= Seq(
  "org.parboiled" %% "parboiled" % "2.0.1" withSources() withJavadoc(),
  // Causes org.scalamacros:quasiquotes _2.10, _2.10.3 cross-version problem
  "io.spray" %% "spray-testkit" % sprayV  % "test" withSources() withJavadoc(),
  // Causes com.chuusai:shapeless _2.10.4, _2.10 cross-version problem
  "io.spray" %% "spray-routing" % sprayV withSources() withJavadoc()
)

scalaVersion := "2.10.4"

javaOptions ++= Seq("-target", "1.8", "-source", "1.8")

organization := domain + "." + companyName

Plugins file:

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.12.0")

addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")

Scala 2.11

It seems "simply" moving 2.11 may solve this, but this isn't always that easy if one has some other libraries that are not 2.11 ready. Nevertheless I tried it, and the second I added parboiled2 as a dependency it broke my build again, sigh, here is the new problem: Parboiled2 causes "missing or invalid dependency detected while loading class file 'Prepender.class'"

2

There are 2 answers

0
jrudolph On BEST ANSWER

The same answer as for Scala 2.11 should work here as well: replace spray-routing with spray-routing-shapeless2.

3
fedesilva On

I would have to look at the whole build.sbt file to understand what is happening but I can use the dependencies you mention without problem with sbt 0.13.7 and scala 2.11.

What sbt version? What Scala version? 2.10 it seems. Why? Are you stuck with those versions?

For reference, here are the build.sbt, plugins.sbt and build.properties files I used to test this scenario.

https://gist.github.com/fedesilva/ddd28a5b592eb88f41ae

Hope that helps