Which scala version am I using?

Does anyone know how to find out which Scala version a project is using when using IntelliJ.
I don’t find any mention in the build.sbt file nor in the build.properties file. However build.properties does indicate sbt version 1.1.2.

If this is an SBT project, I think the easiest is to open the SBT shell and type “scalaVersion”.

Indeed, I can’t find it anywhere in the IntelliJ settings.

How can I know whether it is an sbt project? If I start sbt in the project directory and type (as you suggested scalaVersion) I see that it is 2.12.4, even thought the default version in my path seems to be 2.12.8.

[geminiani:algo/tp-theg/scala] jimka% cd theg
[geminiani:tp-theg/scala/theg] jimka% sbt
[info] Loading settings from idea.sbt ...
[info] Loading global plugins from /Users/jimka/.sbt/1.0/plugins
[info] Loading project definition from /Users/jimka/Repos/algo/tp-theg/scala/theg/project
[info] Loading settings from build.sbt ...
[info] Set current project to theg (in build file:/Users/jimka/Repos/algo/tp-theg/scala/theg/)
[info] sbt server started at local:///Users/jimka/.sbt/1.0/server/10b32f9c8a81f5e7440a/sock
sbt:theg> scalaVersion
[info] 2.12.4
sbt:theg> exit
[info] shutting down server
[geminiani:tp-theg/scala/theg] jimka% which scala
[geminiani:tp-theg/scala/theg] jimka% scala
Welcome to Scala 2.12.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_101).
Type in expressions for evaluation. Or try :help.

The version of Scala you have installed locally is totally irrelevant. SBT handles these things for you; the version is just a setting.

BTW, if you want to find out in IntelliJ, simply click on some class part of the Scala library, it takes you to the definition. Look at the bread crumb below the menu bar. It shows you which file it found it, the file name includes the version number.

1 Like

Good question. I don’t know where to find that in IntelliJ, but when you import a project by having IntelliJ reading the SBT build definition, then IntelliJ will delegate to SBT.

1 Like

Navigating to a standard library class works usually but if you have multiple modules in your project with different versions I’ve seen IntelliJ navigate to an incorrect version.

Best way I know is to look at the dependencies for your module and find the scala-(compiler | library | reflect) jars.

Project Structure -> Modules -> {module} -> Dependencies -> {type scala to search and press the down arrow to move to next match}