有没有办法在 build.sbt 中定义所需的 sbt 版本? [英] Is there a way to define the required sbt version in build.sbt?
问题描述
在 Scala 项目的 build.sbt 定义中,是否可以定义构建项目所需的最低 sbt 版本?
In the build.sbt definition of a Scala project, is it possible to define the minimum version of sbt that is required to build the project?
推荐答案
project/build.properties
允许您强制 sbt 使用特定版本.如果安装的 sbt 的当前版本不同 - sbt 本身将下载(如果需要)您在那里指定的版本:
project/build.properties
allows you to force sbt to use particular version. If current version of installed sbt is different - sbt itself will download (if needed) the version you've specified there:
sbt.version=0.12.0
例如 Hello.所以实际上你可能已经在你的系统中安装了多个版本的 sbt——它只是 jars,放在 .sbt/boot/scala-{sbt 所需的 {scala.version}/org.scala-sbt/sbt/{sbt.version}
文件夹.Sbt 可执行文件实际上查找 project/build.properties
中指定的版本或(如果未指定)系统中安装的最高版本.
See, Hello for instance. So actually you may have installed several versions of sbt in your system - it's just jars, that placed in .sbt/boot/scala-{scala.version required by this sbt}/org.scala-sbt/sbt/{sbt.version}
folder. Sbt executable actually looks for version specified in project/build.properties
or (if it's not specified) highest version installed in the system.
附言从 sbt-launcher
的角度来看,sbt 只是一个依赖项,与 ansi.jar
等小的不相交的其他依赖项,因此指定版本范围,例如 [0.13.1, 0.13.8]
没有多大意义,因为它仅对冲突的传递 deps 有效.否则,指定更高的可能版本就足够了(可以编译)-您甚至可以选择您已经拥有的某个版本(并以这种方式更新项目的 sbt).
P.S. From sbt-launcher
perspective, sbt is only one dependency with small non-intersecting others like ansi.jar
, so specifying the range of versions like [0.13.1, 0.13.8]
have no much sense as it would be efective only for conflicting transitive deps. Otherwise it's enough to specify higher possible version (which would compile) - you may even choose some version that you already have (and update project's sbt that way).
这篇关于有没有办法在 build.sbt 中定义所需的 sbt 版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!