我如何告诉 sbt 使用 Scala 2.12 或 2.13 的夜间版本? [英] How do I tell sbt to use a nightly build of Scala 2.12 or 2.13?

查看:13
本文介绍了我如何告诉 sbt 使用 Scala 2.12 或 2.13 的夜间版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据最新的 Scala nightlies 测试我的代码.

2.13.1一出,nightly里的版本号就会涨到2.13.2,以此类推.

如果您有一个多项目构建,请确保在修改构建定义时在所有项目中设置这些设置.或者,您可以在 sbt shell 中使用 ++2.13.1-bin-abcd123 (sbt 0.13.x) 或 ++2.13.1-bin-abcd123! 临时设置它们code>(sbt 1.x;添加的感叹号是强制使用未包含在 crossScalaVersions 中的版本所必需的).

理想情况下,我们会建议一种自动方式来向 Travis-CI 询问正确的 SHA.这大概可以通过 Travis-CI 的 API 实现,但是(据我所知)还没有人研究过.(有志愿者吗?)

请注意,我们非正式地将这些称为夜间"构建,但从技术上讲,这是用词不当.为每个合并的 PR 构建一个所谓的夜间".

斯卡拉 2.11

没有进一步发布 2.11.x 的计划,因此我们(Lightbend 的 Scala 团队)也不再发布 2.11 nightlies.

I want to test my code against the latest bleeding edge Scala nightlies.

The answer for Scala 2.10 doesn't work anymore.

What do I do?

解决方案

Scala 2.12 or 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 e.g. 2.12.9 for 2.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.

longer explanation

The Scala team no longer publishes -SNAPSHOT versions of Scala. (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 e.g. 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.)

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.

To tell sbt to use one of these nightlies, you need to do three things.

First, add the resolver where the nightlies are kept:

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

Second, specify the Scala version:

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

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! (sbt 1.x; the added exclamation point is necessary to force a version not included in crossScalaVersions to be used).

Ideally, we would suggest an automated way to ask Travis-CI for the right SHA. This is presumably possible via Travis-CI's API, but (to my knowledge) nobody has looked into it yet. (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.

Scala 2.11

No further 2.11.x releases are planned, so we (the Scala team at Lightbend) aren't publishing 2.11 nightlies anymore, either.

这篇关于我如何告诉 sbt 使用 Scala 2.12 或 2.13 的夜间版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆