Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't the Def.inputTask macro work in Scala 2.11.1?

I'm using Scala 2.11.1 and sbt 0.13.5.

I have an sbt plugin that contains a helper function to create input tasks as follows (the implementation is stripped away as it's irrelevant to the problem):

def register(name: String, description: String): Def.Setting[InputTask[Unit]] = {
    InputKey[Unit](name, description) <<= Def.inputTask { 
        println("test")
    }
}

This function compiles and works just fine in Scala 2.10.4, however once I switch to 2.11.1 it fails with the following error:

can't expand macros compiled by previous versions of Scala

Is the Def.inputTask macro simply broken in Scala 2.11.1, or am I missing some glaring detail?

Right now the above function is residing in the simplest sbt plugin imaginable. There are no dependencies at all, either.

like image 496
Michael Zajac Avatar asked Jun 08 '14 04:06

Michael Zajac


2 Answers

sbt 0.13.x series uses Scala 2.10.x when it loads up, so sbt 0.13.x itself must be compiled against Scala 2.10, and so do all sbt plugins for 0.13.x.

Note: sbt 0.13 can define Scala projects using 2.11.x.

like image 195
Eugene Yokota Avatar answered Nov 12 '22 04:11

Eugene Yokota


If you're running scala 2.11.x, use this line in your build.sbt file .

libraryDependencies += "org.scalatest" % "scalatest_2.11" % "2.2.4" % "test"

like image 36
Rodrigo Dias Avatar answered Nov 12 '22 04:11

Rodrigo Dias