简体   繁体   English

我如何告诉 sbt 使用 Scala 2.12 或 2.13 的夜间版本?

[英]How do I tell sbt to use a nightly build of Scala 2.12 or 2.13?

I want to test my code against the latest bleeding edge Scala nightlies.我想针对最新的 Scala nightlies 测试我的代码。

The answer for Scala 2.10 doesn't work anymore. Scala 2.10答案不再适用。

What do I do?我该怎么办?

Scala 2.12 or 2.13 Scala 2.12 或 2.13

quick version快速版

Global / resolvers += "scala-integration" at
  "https://scala-ci.typesafe.com/artifactory/scala-integration/"
scalaVersion := "2.13.1-bin-abcd123"

for a 2.12 nightly, substitute eg 2.12.9 for 2.13.1 ;对于 2.12 每晚,替换例如2.12.92.13.1 in either case, it's the version number of the next release on that branch在任何一种情况下,它都是该分支上下一个版本的版本号

for abcd123 , manually substitute the first 7 characters of the SHA of the latest green build on the 2.13.x or 2.12.x branch on Travis-CI .对于abcd123 ,手动替换Travis-CI 上 2.13.x 或 2.12.x 分支上最新绿色版本的 SHA 的前 7 个字符。

longer explanation更长的解释

The Scala team no longer publishes -SNAPSHOT versions of Scala. Scala 团队不再发布 Scala 的-SNAPSHOT版本。 (Starting that again could be a community contribution; see this ticket .) (再次开始可能是社区贡献;请参阅这张票。)

But the team does publish nightly builds, each with its own fixed version number.但是该团队确实会在每晚发布版本,每个版本都有自己的固定版本号。 The version number of a nightly looks like eg 2.13.1-bin-abcd123 . nightly 的版本号看起来像2.13.1-bin-abcd123 ( -bin- signals binary compatibility to sbt; all 2.13.x releases since 2.13.0 are binary compatible with each other.) -bin-表示与 sbt 的二进制兼容性;自 2.13.0 以来的所有 2.13.x 版本都彼此二进制兼容。)

The old Jenkins-based answer that used to be here no longer works, since we (in 2018) moved publishing of nightlies off Jenkins and onto Travis-CI.过去基于 Jenkins 的旧答案不再有效,因为我们(在 2018 年)将夜生活的发布从 Jenkins 转移到 Travis-CI。

To tell sbt to use one of these nightlies, you need to do three things.要告诉 sbt 使用这些 nightlies 之一,您需要做三件事。

First, add the resolver where the nightlies are kept:首先,添加保存 nightlies 的解析器:

Global / resolvers += "scala-integration" at
  "https://scala-ci.typesafe.com/artifactory/scala-integration/"

Second, specify the Scala version:其次,指定Scala版本:

scalaVersion := "2.13.1-bin-abcd123"

But that isn't a real version number.但这不是真正的版本号。 Manually substitute a version number containing the 7-character SHA of the last commit in the scala/scala repository for which a nightly build was published.手动替换包含发布夜间构建的scala/scala 存储库中最后一次提交的 7 字符 SHA 的版本号。 Look at https://travis-ci.org/scala/scala/branches and you'll see the SHA in the upper right corner of the 2.13.x (or 2.12.x) section.查看https://travis-ci.org/scala/scala/branches ,您将在 2.13.x(或 2.12.x)部分的右上角看到 SHA。 For example:例如:

在此处输入图片说明

As soon as 2.13.1 is released, the version number in the nightly will bump to 2.13.2, and so on. 2.13.1一发布,nightly的版本号就会涨到2.13.2,以此类推。

If you have a multiproject build, be sure you set these settings across all projects when you modify your build definition.如果您有一个多项目构建,请确保在修改构建定义时在所有项目中设置这些设置。 Or, you may set them temporarily in the sbt shell with ++2.13.1-bin-abcd123 (sbt 0.13.x) or ++2.13.1-bin-abcd123!或者,您可以使用++2.13.1-bin-abcd123 (sbt 0.13.x) 或++2.13.1-bin-abcd123!在 sbt shell 中临时设置它们++2.13.1-bin-abcd123! (sbt 1.x; the added exclamation point is necessary to force a version not included in crossScalaVersions to be used). (sbt 1.x;必须添加感叹号以强制使用未包含在crossScalaVersions的版本)。

Ideally, we would suggest an automated way to ask Travis-CI for the right SHA.理想情况下,我们会建议一种自动化的方式来向 Travis-CI 询问正确的 SHA。 This is presumably possible via Travis-CI's API, but (to my knowledge) nobody has looked into it yet.这大概可以通过 Travis-CI 的 API 实现,但是(据我所知)还没有人研究过它。 (Is there a volunteer?) (有志愿者吗?)

Note that we call these “nightly” builds informally, but technically it's a misnomer.请注意,我们非正式地称这些为“夜间”构建,但从技术上讲,这是用词不当。 A so-called “nightly” is built for every merged PR.为每个合并的 PR 构建一个所谓的“夜间”。

Scala 2.14斯卡拉 2.14

There may never be a 2.14.x branch in the Scala repo, but if there is, the following instructions will apply: Scala 存储库中可能永远不会有 2.14.x 分支,但如果有,以下说明将适用:

As above, but look on the 2.14.x branch for the SHA, and the version number begins with 2.14.0-pre- (note -pre- not -bin- , since binary compatibility isn't frozen yet for 2.14).如上所述,但查看 SHA 的2.14.x 分支,版本号以2.14.0-pre-开头(注意-pre-不是-bin- ,因为 2.14 的二进制兼容性尚未冻结)。

So for example, 2.14.0-pre-abcd123 .例如, 2.14.0-pre-abcd123

Scala 2.11斯卡拉 2.11

Though further 2.11.x releases remain possible, none are planned, so we (the Scala team at Lightbend) aren't publishing 2.11 nightlies anymore.尽管仍有可能发布 2.11.x 版本,但没有任何计划,因此我们(Lightbend 的 Scala 团队)不再发布 2.11 nightlies。

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

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