Why IntelliJ IDEA uses scala 2.10.6 for play2 configuration? - scala

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.

Related

When is there a sbt version for 2.13?

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?

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

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.