When is there a sbt version for 2.13? - scala

I would like to develop a sbt plugin that has dependencies that are only available for Scala 2.13.
I found on https://github.com/sbt/sbt/issues/5032 this list:
SBT 0.x runs only on Scala 2.10.x
SBT 1.x runs only on Scala 2.12.x
SBT 2.x will run only on Scala 2.13.x or 3.0.x
SBT 3.x will run only on Scala 3.0.x or Scala 3.1.x
Where the last two lines was a guess by the author mr-git.
However I did not find any other glue if there is actually a version for Scala 2.13.
Does anybody know?
Update: Added it here: https://discuss.lightbend.com/t/when-is-there-a-sbt-version-for-2-13/5623

If afraid you are out of luck. Your plugin needs to be binary compatible with the SBT, which currently means 2.12 for SBT 1.x.x or 2.10 for SBT 0.13.x. There is no trace of any SBT 2 version anywhere on the Internet, certainly no such version exists in the SBT GitHub repository
The situation was similar with Scala 2.11 before, see Does sbt build against scala 2.11? and What's the relationship of the versions of scala when I use sbt to build a scala project?

Related

Which version of SBT ? scala2.13.3

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.

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

Why IntelliJ IDEA uses scala 2.10.6 for play2 configuration?

I use:
scala version 2.11.8 everywhere in the project, this version is explicitly specified in build.sbt
sbt version 0.13.13, which specified both in project/build.properties and IDE settings
IntelliJ IDEA uses the correct version of scala for tests running and project building (output is in ...target/scala-2.11...), but not for play2 application. The latter one for some reason uses scala 2.10: [info] Compiling 86 Scala sources to .../target/scala-2.10/classes....
The only idea I have is that IDEA uses the default scala of the sbtlauncher (it uses 2.10.6 when run from console), despite the explicit declaration in build file.

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.