Fix addSbtPlugin to use the correct version of sbt

Fixes #3393
This commit is contained in:
Dale Wijnand 2017-08-02 14:38:10 +01:00
parent 6c58e2da2d
commit a5afc21bf0
No known key found for this signature in database
GPG Key ID: 4F256E3D151DF5EF
3 changed files with 19 additions and 1 deletions

View File

@ -2956,7 +2956,7 @@ trait BuildExtra extends BuildCommon with DefExtra {
*/
def addSbtPlugin(dependency: ModuleID): Setting[Seq[ModuleID]] =
libraryDependencies += {
val sbtV = (sbtBinaryVersion in update).value
val sbtV = (sbtBinaryVersion in pluginCrossBuild).value
val scalaV = (scalaBinaryVersion in update).value
sbtPluginExtra(dependency, sbtV, scalaV)
}

View File

@ -0,0 +1,7 @@
### Bug fixes
- Fixes `addSbtPlugin` to use the correct version of sbt. [#3393][]/[#3397][] by [@dwijnand][]
[#3393]: https://github.com/sbt/sbt/issues/3393
[#3397]: https://github.com/sbt/sbt/pull/3397
[@dwijnand]: http://github.com/dwijnand

View File

@ -4,6 +4,8 @@ val buildCrossList = List("2.10.6", "2.11.11", "2.12.2")
scalaVersion in ThisBuild := "2.12.2"
crossScalaVersions in ThisBuild := buildCrossList
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.7.0")
lazy val root = (project in file("."))
.settings(
sbtPlugin := true,
@ -16,12 +18,21 @@ lazy val app = (project in file("app"))
def mkCheck(scalaBinV: String, sbtBinVer: String) = Def task {
val crossV = (sbtVersion in pluginCrossBuild).value
val crossBinV = (sbtBinaryVersion in pluginCrossBuild).value
val sv = projectID.value.extraAttributes("e:scalaVersion")
assert(sbtVersion.value startsWith baseSbt, s"Wrong sbt version: ${sbtVersion.value}")
assert(sv == scalaBinV, s"Wrong e:scalaVersion: $sv")
assert(scalaBinaryVersion.value == scalaBinV, s"Wrong Scala binary version: ${scalaBinaryVersion.value}")
assert(crossV startsWith sbtBinVer, s"Wrong `sbtVersion in pluginCrossBuild`: $crossV")
val ur = update.value
val cr = ur.configuration(Compile).get
val mr = cr.modules.find(mr => mr.module.organization == "com.eed3si9n" && mr.module.name == "sbt-buildinfo").get
val plugSv = mr.module.extraAttributes("scalaVersion")
val plugSbtV = mr.module.extraAttributes("sbtVersion")
assert(plugSv == scalaBinV, s"Wrong plugin scalaVersion: $plugSv")
assert(plugSbtV == sbtBinVer, s"Wrong plugin scalaVersion: $sbtBinVer")
// crossScalaVersions in app should not be affected, per se or after ^^
val appCrossScalaVersions = (crossScalaVersions in app).value.toList
val appScalaVersion = (scalaVersion in app).value