Which version of SBT ? scala2.13.3 - scala

According to the SBT website, the latest version of SBT is 1.3.13. Is this available in 2.13.3, the latest version of Scala?

Yes.
You can download the latest version of sbt (1.3.13 for now)
https://www.scala-sbt.org/download.html
and use it for your project if you write in the file project/build.properties
sbt.version = 1.3.13
Also you can write in the file build.sbt
scalaVersion := "2.13.3"
Currently it's the latest version of Scala
https://www.scala-lang.org/download/all.html
So you will be using the latest versions both of Scala and sbt.
Some sideways remarks. Sbt is written in Scala itself. For sbt 1.3.13 it's Scala 2.12.10. Most probably this version of Scala is irrelevant to you. It's relevant only to those who develop sbt or write plugins to sbt etc. Also the file build.sbt is a script in Scala using version of Scala specified in project/build.sbt i.e. in the build file of meta-project (sbt is recursive). It should be Scala 2.12.x because of the binary compatibility with the version of Scala sbt is written in, i.e. from 2.12.0 to 2.12.12. So you can write val x: 1 = 1 (singleton types, a Scala-2.13 feature) in your project Scala code but can't in build.sbt. In this sense the answer is No.

Related

SBT - How to mix/create separate Scala 2.11 and Scala 2.12 folders in same project?

I have an sbt project with deprecated libraries (ex. Spray, pre-release macro paradise, etc) that I cannot upgrade to Scala 2.12. It compiles with Scala 2.11.8 now. I want to continue development with non-deprecated libraries (ex. Akka HTTP, latest Scala macros, etc.) by creating a folder called "2.12" and a folder called "2.11" and putting the deprecated 2.11 code in the "2.11" folder and continuing development in the "2.12" folder. The code in the "2.12" folder can cross-compile with both Scala 2.11 and Scala 2.12, but the code in the "2.11" folder can only compile with Scala 2.11. I want to be able to mix the deprecated code and the non-deprecated code in the same project, at least at first, and gradually move things over to the "2.12" folder. How do I do that with sbt?
Right now the project uses sbt 0.13 and it won't compile with sbt 1.X, but if I clean/fix up the Build.scala file and maybe convert it to a build.sbt file, I think I will be able to upgrade from 0.13 to 1.X
It is possible to change the default Scala source directory via: https://www.scala-sbt.org/1.0/docs/Howto-Customizing-Paths.html

What's the relationship of the versions of scala when I use sbt to build a scala project?

I'm building a scala project(writen in scala 2.11) with SBT 1.x.There are a few "versions of scala" which made me puzzle.
SBT 1.x => scala 2.12
SBT plugin => scala 2.x
My project => scala 2.11
Please help me to figure out what's the difference or relationship between them.And how SBT tells them apart when compiling or running the project?
The Scala version used by sbt itself and its plugins is completely independent from the Scala version used to compile the code in your project. The sbt version determines the Scala version it uses:
sbt 0.13 uses Scala 2.10
sbt 1.x uses Scala 2.12
You can set this version in project/build.properties, for example:
sbt.version = 1.1.1
The sbt plugins you want to use have to be compatible with the given version of sbt (and many are cross-compiled with both 0.13 and 1.x).
To set the version of Scala you want to use for the code in you project, use scalaVersion setting in your build.sbt:
scalaVersion := "2.12.4"
Again, it's independent from the version for sbt. You can also cross-compile your code for several Scala versions:
scalaVersion := "2.12.4"
crossScalaVersions := Seq("2.11.12", "2.12.4")
Then if you run compile in sbt, it will use Scala 2.12.4, and if you run +compile, it will first compile it with Scala 2.11.12 and then with 2.12.4. See sbt docs for more about Cross-building.

scala sbt version of plugin

I need to run a sbt plugin compiled for scala 2.11.
However, sbt tries to download the plugin for scala 2.12. How I force sbt to use scala 2.11?
ps: adding scalaVersion := "2.11.11" to build.sbt does not solve the problem, as the sbt plugin is not affected by this.
You cannot choose what Scala runtime is the SBT built against, you need to use the version compatible with the SBT you have. The only choice you have is which SBT version you use. See also How to change Scala version for build definition?
Sbt 1.x.x requires you to use Java 8 and Scala 2.12 - see SBT 1.0.0
sbt 1.0 uses Scala 2.12 for build definitions and plugins. This also requires JDK 8.
Previous 0.13 versions used Scala 2.10, see 0.13.1 notes:
The Scala version for sbt and sbt plugins is now 2.10.3.
There is no version using 2.11.x

sbt is using wrong scala version rather than using the configuration in build.sbt

I have put these in the build.sbt file under current project's root directory
scalaHome := Some(file("/Users/ddam/scala-2.10.2"))
scalaVersion := "2.10.2"
And I ran sbt using
$ sbt --version
sbt launcher version 0.12.4
But still, I am seeing both the wrong version for sbt and scala when a particular dependency cannot be resolved
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] com.typesafe.sbteclipse:sbteclipse-plugin:2.4.0 (sbtVersion=0.12, scalaVersion=2.9.2)
Please help me.
It looks like sbteclipse requires SBT 0.13.0, and you are using version 0.12.4.
You can specify the SBT version by following the directions on this page.
Some other notes: You probably want to use Scala 2.10.3, not 2.10.2.
Also, it's strange to specify scalaHome; usually SBT will automatically fetch the needed Scala jars for you.
So to bootstrap a Scala environment, all you need to have installed are SBT and a JDK.
EDIT: (addressing comment below):
When you build code with SBT, you may actually use two different versions of Scala.
There is the version for SBT (what version of Scala the build system runs on), and the version for the code in your project (what version of Scala your code will run on).
The Scala version for SBT is determined by the SBT version you use.
If you use 0.12.4, SBT will run on Scala 2.9.3.
If you use 0.13.0, SBT will run on Scala 2.10.3.
You control the SBT version by following these instructions.
To control the version of Scala your project will run on, you can set scalaVersion in <projectRoot>/build.sbt.
So, you're getting that error because you're using SBT 0.12.4, which uses Scala 2.9.3.
SBT tries to find the sbteclipse plugin for 2.9.3, but it doesn't exist because it requires SBT 0.13.0 (=> Scala 2.10.3).
It seems you've correctly specified the use of Scala 2.10.2 for compiling your project.
sbt 0.12.4 always uses Scala 2.9.x to compile the build files (i.e. build.sbt and the stuff under project/). This means that plugins for sbt 0.12.x must also be compiled against 2.9.x, which explains what you're seeing.
sbteclipse 2.4.0 requires sbt 0.13. Try sbteclipse 2.2.0 if you want to stay on sbt 0.12.4.
emchristiansen's answer has good additional points.

SBT 0.10 - remove dependency on Scala 2.8.1

My project uses Scala 2.9 so I've added
scalaVersion := "2.9.0-1"
to my build.sbt file, and run gen-idea. However IDEA still shows Scala 2.8.1 (in addition to 2.9) in External Libraries. Why, and how to remove it?
Your application will be compiled with whatever Scala version or versions you choose. However, SBT is also a Scala application, and it was compiled with Scala 2.8.1, so it needs Scala 2.8.1's libraries to work. This will not have any impact on your application.