简体   繁体   English

使用2.10.0在SBT中交叉构建

[英]Cross building in sbt with 2.10.0

I am cross building a scala project with sbt 12.1. 我正在用sbt 12.1构建一个Scala项目。

crossScalaVersions := Seq("2.9.2", "2.10.0")

However, it can't find the dependencies because they are named _2.10 not _2.10.0 . 但是,它找不到依赖项,因为它们被命名为_2.10而不是_2.10.0 It seems like it's regular to name your library 2.10 instead of 2.10.0 with the exception of scala-language and scala-compiler . 除了scala-languagescala-compiler之外,将您的库命名为2.10而不是2.10.0似乎2.10.0 For example, scalaz is not found at http://repo1.maven.org/maven2/org/scalaz/scalaz-core_2.10.0/6.0.4/scalaz-core_2.10.0-6.0.4.pom but at http://repo1.maven.org/maven2/org/scalaz/scalaz-core_2.10/6.0.4/scalaz-core_2.10-6.0.4.pom . 例如,在http://repo1.maven.org/maven2/org/scalaz/scalaz-core_2.10.0/6.0.4/scalaz-core_2.10.0-6.0.4.pom上找不到scalaz,而在http:/ /repo1.maven.org/maven2/org/scalaz/scalaz-core_2.10/6.0.4/scalaz-core_2.10-6.0.4.pom

Is there an easy way to handle this without writing custom rules for all of my dependencies? 有没有一种简单的方法可以解决此问题,而无需为我的所有依赖项编写自定义规则?

The actual build.sbt is available online . 实际的build.sbt可在线获得

Since 2.10.x releases are binary compatible between each other, libraries need to be built only with one version of scala library - and they can (and must) drop the .0 part (if you publish with sbt, it is done automatically). 由于2.10.x版本彼此之间是二进制兼容的,因此只需要使用一个版本的scala库来构建库-并且它们可以(并且必须)删除.0部分(如果使用sbt发布,则它是自动完成的)。 When the maintainer of a library releases a library with _2.10.0 tag, it's a mistake and you should consider filing a bug. 当库的维护者发布带有_2.10.0标签的库时,这是一个错误,您应该考虑提交一个错误。

By the way, I looked on your build.sbt - running +compile on it works for me (sbt 0.12.1). 顺便说一句,我查看了您的build.sbt在其上运行+compile对我而言有效(sbt 0.12.1)。 Do you experience some errors? 您是否遇到一些错误?

To get the Scala version incorporated into the artifact name in the Scala way, you specify the dependency with the %% operator: 要以Scala方式将Scala版本合并到工件名称中,请使用%%运算符指定依赖项:

libraryDependencies += "io.backchat.jerkson" %% "jerkson" % "0.7.0"

When the exact match is not available, you can specify the Scala version explicitly (but remember compatibility only exists across patch releases of a given major/minor release of Scala): 当不存在完全匹配项时,可以显式指定Scala版本(但请记住,兼容性仅在给定的主要/次要Scala版本的补丁程序版本之间存在):

libraryDependencies += "io.backchat.jerkson" % "jerkson_2.9.2" % "0.7.0"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM