Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the default scalaVersion sbt uses?

Tags:

scala

sbt

Just out of curiosity, I would like to know whether the default scalaVersion that sbt uses is somehow hard-coded in the source? I mean the version for all projects that don't specify a scala version explicitly (via the scalaVersion setting key)

I ask this because, on my machine, I'm using sbt 0.12.4 and no build.sbt files anywhere (neither project root, nor in project or ~/.sbt/plugins), and when I type sbt about I get this:

...
[info] sbt, sbt plugins, and build definitions are using Scala 2.9.2

I'm already using scala 2.10.2 (in my PATH) but I reckon this install has nothing to do with sbt, as it downloads scala from the official repos.

There are many similar questions like this and this, but they only refer to a specific project.

Any thoughts?

like image 700
rodolfo42 Avatar asked Nov 23 '25 15:11

rodolfo42


1 Answers

By default, sbt will build projects with the same version of Scala used to run sbt itself. But the ~/.sbt/boot directory downloads scala jars from the repository, similarly to plugin jars - so the default scala version is a dependency of sbt configured in the repository. Means that as sbt versions march forward, so the default scala version will march forward, as configured by sbt devs.

This can be confirmed by viewing plugins/target/resolution-cache/reports/default-global-plugins-scala-tool.xml (and also same content in runtime-resolved.xml):

<module organisation="org.scala-lang" name="scala-compiler">
<revision name="2.10.2" status="release" pubdate="20130607040625" resolver="sbt-chain" artresolver="sbt-chain" homepage="http://www.scala-lang.org/" downloaded="false" searched="false" default="false" conf="default, optional, compile, runtime, optional(default), master" position="0">
    <license name="BSD-like" url="http://www.scala-lang.org/downloads/license.html    "/>
    <metadata-artifact status="no" details="" size="2843" time="0" location="C:\Users\Bestos\.ivy2\cache\org.scala-lang\scala-compiler\ivy-2.10.2.xml" searched="false" origin-is-local="false" origin-location="http://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.10.2/scala-compiler-2.10.2.pom"/>
    <caller organisation="default" name="global-plugins" conf="scala-tool" rev="2.10.2" rev-constraint-default="2.10.2" rev-constraint-dynamic="2.10.2" callerrev="0.0"/>
    <artifacts>
        <artifact name="scala-compiler" type="jar" ext="jar" status="no" details="" size="14411577" time="0" location="C:\Users\Bestos\.ivy2\cache\org.scala-lang\scala-compiler\jars\scala-compiler-2.10.2.jar">
            <origin-location is-local="false" location="http://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.10.2/scala-compiler-2.10.2.jar"/>
        </artifact>
    </artifacts>
</revision>
</module>

Of course, the scala version used for individual projects can be configured differently to the "bootstrap scala version" via the setting scalaVersion. Within build.sbt:

scalaVersion := "2.10.1"
like image 103
Glen Best Avatar answered Nov 26 '25 15:11

Glen Best



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!