Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to define the required sbt version in build.sbt?

Tags:

scala

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?

like image 756
Bar Avatar asked Feb 10 '15 10:02

Bar


People also ask

Which version of Scala does sbt use?

sbt uses that same version of Scala to compile the build definitions that you write for your project because they use sbt APIs. This version of Scala is fixed for a specific sbt release and cannot be changed. For sbt 1.7. 1, this version is Scala 2.12.

What is a build sbt file?

sbt is an open-source build tool for Scala and Java projects, similar to Apache's Maven and Ant.

What is build sbt in Scala?

sbt is a popular tool for compiling, running, and testing Scala projects of any size. Using a build tool such as sbt (or Maven/Gradle) becomes essential once you create projects with dependencies or more than one code file.


1 Answers

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

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.

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

like image 65
dk14 Avatar answered Sep 28 '22 09:09

dk14