Getting the current sbt plugin cross version

282 Views Asked by At

I'm trying to cross-build an sbt plugin between 0.13 and 1.1. To accomplish this I need to use different libraryDependencies for the different builds, but I can't find a way to access the current build's target sbt version.

Back when the cross compilation was in a plugin there was CrossBuilding.pluginSbtVersion but I can't find anything similar anymore.

  • sbtVersion.value always gives me 0.13.16
  • (sbtVersion in sbtPlugin) likewise
  • crossVersion always gives me Binary
  • scalaBinaryVersion always gives me 2.10

How can I do this?

2

There are 2 best solutions below

0
On BEST ANSWER

It turns out the solution was present in sbt's output all along:

[info] Setting `sbtVersion in pluginCrossBuild` to 1.1.2

I just had to use (sbtBinaryVersion in pluginCrossBuild).value

3
On

you can use the following code:

libraryDependencies ++= {
  sbtBinaryVersion.value match {
    case "0.13" => Seq(...)
    case "1.0" => Seq(...)
  }
}

make sure to run your sbt commands with ^, to run command on all sbt versions, ie:

sbt "^compile"