【问题标题】:parboiled2 and Spray cause conflicting cross-version suffixesparboiled2 和 Spray 导致跨版本后缀冲突
【发布时间】:2015-02-23 20:16:35
【问题描述】:

我正在尝试将 parboiled2 作为依赖项添加到我的项目中,并按照 Calculator 示例进行操作,但它与 spray 冲突。

我当前的build.sbt 文件包括:

"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(),

当我添加时

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

我明白了

[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

所以做了一些谷歌搜索,像往常一样,人们建议使用 SBT 的 exclude 指令(我认为这在逻辑上没有意义,因为它不可避免地会导致像 ClassNotFoundExceptionNoSuchMethodError 这样的问题)。尽管如此,我还是尝试了:

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

当我尝试运行 assembly 时,我得到了惊喜

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

我还收到更多错误:

[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 ...

如果我注释掉 Spray 依赖项(和代码),我可以使用计算器示例成功组装一个 jar。

这对我使用 parboiled2 来说是一个主要的表演障碍。除了exclude 指令之外,还有其他方法可以使这些东西发挥作用吗?有没有人有一个带有 Spray 和 parboiled2 的工作构建文件?如果有人设法使用 onejar 或 ProGuard 绕过依赖地狱,如果他们能解释一下如何,我会很高兴。

更新:

我的构建文件:

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

插件文件:

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

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

斯卡拉 2.11

似乎“简单地”移动 2.11 可以解决这个问题,但如果有一些其他库还没有准备好 2.11,这并不总是那么容易。尽管如此,我还是尝试了,第二次我添加 parboiled2 作为依赖项,它再次破坏了我的构建,叹息,这是新问题:Parboiled2 causes "missing or invalid dependency detected while loading class file 'Prepender.class'"

【问题讨论】:

    标签: scala sbt spray sbt-assembly parboiled


    【解决方案1】:

    同样的answer as for Scala 2.11 也应该在这里工作:将spray-routing 替换为spray-routing-shapeless2

    【讨论】:

      【解决方案2】:

      我必须查看整个 build.sbt 文件才能了解发生了什么,但我可以使用您提到的依赖项,而 sbt 0.13.7 和 scala 2.11 没有问题。

      什么sbt版本?什么Scala版本? 2.10 好像。为什么?你还在坚持那些版本吗?

      作为参考,这里是我用来测试这个场景的 build.sbt、plugins.sbt 和 build.properties 文件。

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

      希望有帮助

      【讨论】:

      • 好的,我会尝试升级到 2.11。我已经尝试过了,但是我的单元测试依赖关系随后中断了——回想起来我可能忘记了做一个sbt clean。我会反馈结果...
      • 所以当我尝试升级到 2.11 时,我得到了[error] Modules were resolved with conflicting cross-version suffixes in ... org.specs2:specs2 _2.10, _2.11。我现在拥有与您相同版本的 sbt-assembly。 ("org.specs2" % "specs2_2.10" % "1.14")
      • 使用 2.10,我仍然遇到跨版本问题,我将更新 OP 以更具体地了解我的构建文件...
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-15
      • 2014-08-29
      • 2013-10-27
      • 2017-02-01
      • 1970-01-01
      • 2013-10-15
      相关资源
      最近更新 更多