为什么在一种环境下而不在另一种环境下sbt的交叉版本冲突

为什么在一种环境下而不在另一种环境下sbt的交叉版本冲突

本文介绍了为什么在一种环境下而不在另一种环境下sbt的交叉版本冲突?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有以下依赖项的sbt项目:

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

在一台机器上,我可以毫无问题地运行./sbt;另一方面,我得到

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

我已经隔离了问题和解决方法. Sorm取决于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)

通过将exclude("org.scala-lang","scala-compiler")添加到sorm依赖项中,可以使项目在两个位置都可以构建.但是为什么行为不一致?两种环境都使用相同版本的sbt(0.13.8)和scala(2.11.6).有什么不同?

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?

推荐答案

给出 com.github.nikita-volkov:embrace ,我猜这是由于使用了版本范围和缓存:

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>

特别考虑到Scala 2.12.0-M1是昨天发布的:

Particularly given that Scala 2.12.0-M1 was release yesterday:

要解决不一致问题,您要清除常春藤缓存:

To fix the inconsistency you want to clear your ivy cache:

rm -r ~/.ivy2/cache

但是,您还想修复scala-compiler使用的版本,并且希望它与您配置的scalaVersion相匹配:

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.

这篇关于为什么在一种环境下而不在另一种环境下sbt的交叉版本冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 18:16