3

SBT 0.12.2 always attempts to resolve plugins using Scala 2.9.2 when using the %% syntax on plugin imports.

I have tried setting older versions of Scala in build.sbt, newer versions, etc. Even deleting target folder each time... nothing seems to make a difference.

name := "Game"

version := "1.0"

scalaVersion := "2.9.1" // SBT is ignoring the scala version
Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
Lawrence Wagerfield
  • 6,471
  • 5
  • 42
  • 84

2 Answers2

3

SBT is recursive, so you need to specify scala version for project, that build your project. Another words, you need to add appropriate scalaVersion to the plugins.sbt file.

4e6
  • 10,696
  • 4
  • 52
  • 62
  • This worked, thank you. However, if SBT is recursive, why doesn't it pick up the version from build.sbt, which is presumably parent to plugins.sbt? – Lawrence Wagerfield Apr 27 '13 at 13:52
  • 2
    Inner project is just another sbt project inside `project` folder, and doesn't inherit settings of outer one. You can ask on sbt mailing list why this approach was chosen. – 4e6 Apr 27 '13 at 18:27
  • So in what sense is SBT recursive? If settings are not inherited, then what? Is it purely in the sense that an SBT project is used to compile and SBT project? – Lawrence Wagerfield Apr 27 '13 at 21:50
  • 1
    Recursion is about __repeating__ things, not about __relations__ between things. sbt project is defined in scala, so it itself need to be built. Another sbt project is used to build first one. And latter one need to be built too. And so on. Thereby we have a __recursive__ project definition. – 4e6 Apr 27 '13 at 23:28
1

For all plugins in your project, you set scalaVersion in project/plugins.sbt file that configures the build project definition for your project and where you define plugins.

$ cat project/plugins.sbt
scalaVersion := "2.9.3"

There's however a way to set up a more specific version of sbt and Scala for a plugin.

Instead of using addSbtPlugin that accepts a single ModuleID (constructed with % and %%), use addSbtPlugin(dependency: ModuleID, sbtVersion: String) or even addSbtPlugin(dependency: ModuleID, sbtVersion: String, scalaVersion: String), e.g.

$ cat project/plugins.sbt
// It doesn't exist and it's only for demo purposes
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.1.0", "0.12.2", "2.5")
Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420