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

爷,独闯天下 提交于 2019-12-17 15:58:11

问题


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?


回答1:


Scala 2.12 or 2.13

quick version

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:

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

As of July 2019 there isn't yet a 2.14.x branch in the Scala repo, but once there is, the following instructions will apply:

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

So for example, 2.14.0-pre-abcd123.

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



来源:https://stackoverflow.com/questions/40622878/how-do-i-tell-sbt-to-use-a-nightly-build-of-scala-2-12-or-2-13

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!