3

I'm developing a simple SBT project that includes InputTasks for benchmarking Scala Parallel collections.

I have defined the InputKeys and started writing the tasks when I encountered a problem.

Since my benchmarks require Scala 2.10.0-M5, I tried doing this in my build.sbt:

name := "scala-parallel-collection-benchmark"

version := "1.0.0"

organization := "com.google.summer"

scalaVersion := "2.10.0-M5"

However, at compilation I get the following error:

[info] Loading project definition from C:\Users\Administrator\scala-parallel-collection-benchmark\project
[info] Compiling 1 Scala source to C:\Users\Administrator\scala-parallel-collection-benchmark\project\target\scala-2.9.1\sbt-0.11.3\classes...
[error] C:\Users\Administrator\scala-parallel-collection-benchmark\project\Build.scala:47: value tasksupport is not a member of scala.collection.parallel.mutable.ParArray[Int]
[error]                 collection.tasksupport = new ForkJoinTaskSupport(new ForkJoinPool(par))
[error]                            ^
[error] one error found
[error] {file:/C:/Users/Administrator/scala-parallel-collection-benchmark/project/}default-e0b2a2/compile:compile: Compilation failed

It appears that it still uses Scala 2.9.1 to compile it.

How can I set up SBT so it compiles my code using Scala 2.10.0-M5?

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
ioreskovic
  • 5,531
  • 5
  • 39
  • 70
  • 3
    To be clear: You really want to use Scala 2.10 to write your BUILD DEFINITION? The error is in project/Build.scala, which is supposed to contain your project definition, not the actual source code. This gets compiled with the Scala version sbt was built with, not with the one you specify with scalaVersion, which is for the stuff in src/... – themel Aug 14 '12 at 08:03
  • You might want to post that as an answer so I might accept it :D – ioreskovic Aug 14 '12 at 08:38

3 Answers3

7

scalaVersion only impacts the version of Scala used to compile the "actual" source code (usually located in src/...). Your error comes from a part of the build definition (under project/), which is always compiled with the Scala version that sbt was built with.

themel
  • 8,825
  • 2
  • 32
  • 31
4

You can't modify the version of Scala that is used to to compile the project definition, because it must be a version binary compatible with the version used to compile SBT itself. There's some flexibility being studied in this regard, but, right now, it's fixed.

The setting scalaVersion will change the version of Scala used to compile the project itself. The project can be compiled with completely different versions and, in fact, you can even have SBT compile your project with multiple Scala versions.

Daniel C. Sobral
  • 295,120
  • 86
  • 501
  • 681
-5

you can change the scala version in file "project/build.properties" e.g. sbt.version=0.11.2

Joe Yang
  • 23
  • 4