简体   繁体   中英

Why does SBT 0.12.2 resolve plugins with Scala 2.9.2 and ignore scalaVersion in build.sbt?

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

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.

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) , eg

$ 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")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM