导致冲突的跨版本后缀

导致冲突的跨版本后缀

本文介绍了parboiled2 和 Spray 导致冲突的跨版本后缀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 parboiled2 作为依赖项添加到我的项目中,并遵循 Calculator 示例,但它与 Spray 冲突.

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

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

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

当我添加

"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 指令(我认为这不合逻辑,因为它不可避免地会导致诸如 ClassNotFoundException 之类的问题code> 和 NoSuchMethodError).不过我还是试了一下:

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

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

And surprise surprise when I try to run assembly I get

[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 依赖项(和代码),我可以成功地使用 Calculator 示例组装一个 jar.

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

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

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.

更新:

我的构建文件:

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

Scala 2.11

似乎简单"移动 2.11 可以解决这个问题,但是如果有一些其他库不是 2.11 准备好,这并不总是那么容易.尽管如此,我还是尝试了,第二次我添加了 parboiled2 作为依赖项,它再次破坏了我的构建,唉,这是新问题:Parboiled2 导致加载类文件 'Prepender.class' 时检测到的依赖项缺失或无效"

推荐答案

与 Scala 2.11 相同的 答案 应该可以工作这里也一样:用 spray-routing-shapeless2 替换 spray-routing.

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

这篇关于parboiled2 和 Spray 导致冲突的跨版本后缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 20:01