mirror of https://github.com/sbt/sbt.git
Fix += interference with sbt-buildinfo
The macro pattern match was too general. This makes it tighter. Fixes #3132
This commit is contained in:
parent
239280f137
commit
bfc2d85d54
|
|
@ -211,7 +211,9 @@ object TaskMacro {
|
|||
val typeArgs = ttpe.typeArgs
|
||||
v.tree.tpe match {
|
||||
// To allow Initialize[Task[A]] in the position of += RHS, we're going to call "taskValue" automatically.
|
||||
case tpe if typeArgs.nonEmpty && (tpe weak_<:< c.weakTypeOf[Initialize[_]]) =>
|
||||
case tpe
|
||||
if typeArgs.nonEmpty && (typeArgs.head weak_<:< c.weakTypeOf[Task[_]])
|
||||
&& (tpe weak_<:< c.weakTypeOf[Initialize[_]]) =>
|
||||
c.macroApplication match {
|
||||
case Apply(Apply(TypeApply(Select(preT, nmeT), targs), _), _) =>
|
||||
val tree = Apply(
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
// https://github.com/sbt/sbt/issues/3132
|
||||
lazy val root = (project in file(".")).
|
||||
enablePlugins(XBuildInfoPlugin).
|
||||
settings(
|
||||
buildInfoKeys += name
|
||||
)
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
|
||||
object XBuildInfoPlugin extends sbt.AutoPlugin {
|
||||
override def requires = plugins.JvmPlugin
|
||||
|
||||
object autoImport {
|
||||
lazy val buildInfoKeys = settingKey[Seq[BuildInfoKey.Entry[_]]]("Entries for build info.")
|
||||
}
|
||||
import autoImport._
|
||||
|
||||
override def projectSettings: Seq[Def.Setting[_]] = Seq(
|
||||
buildInfoKeys := Seq(name, version, scalaVersion, sbtVersion),
|
||||
)
|
||||
}
|
||||
|
||||
object BuildInfoKey {
|
||||
implicit def setting[A](key: SettingKey[A]): Entry[A] = Setting(key)
|
||||
implicit def task[A](key: TaskKey[A]): Entry[A] = Task(key)
|
||||
def apply[A](key: SettingKey[A]): Entry[A] = Setting(key)
|
||||
def apply[A](key: TaskKey[A]): Entry[A] = Task(key)
|
||||
|
||||
case class Setting[A](scoped: SettingKey[A]) extends Entry[A] {
|
||||
def manifest = scoped.key.manifest
|
||||
}
|
||||
case class Task[A](scoped: TaskKey[A]) extends Entry[A] {
|
||||
def manifest = scoped.key.manifest.typeArguments.head.asInstanceOf[Manifest[A]]
|
||||
}
|
||||
sealed trait Entry[A] {
|
||||
def manifest: Manifest[A]
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
> compile
|
||||
Loading…
Reference in New Issue