From 16a6906826819eeee9c781bef4317a6420db718e Mon Sep 17 00:00:00 2001 From: eugene yokota Date: Mon, 29 Aug 2016 15:15:13 -0400 Subject: [PATCH] Deprecate the old operators `<<=`, `<+=`, and `<++=` (#2716) * Backport style changes in tests and Defaults.scala This backports the scripted tests and Defaults.scala style changes to use `build.sbt` and `:=`. * Fix backport * Deprecate the old operators `<<=`, `<+=`, and `<++=` The no-longer-documented operators `<<=`, `<+=`, and `<++=` are deprecated in anticipation of the removal in sbt 1.0. Ref #2711 For `<<=`, the suggested migration would be to use either `:=` or `~=` operators. The RHS of `<<=` takes an `Initialize[_]` expression, which can be converted to `:=` style by wrapping the expression in parenthesis, and calling `.value` at the end. --- .../src/main/scala/sbt/Structure.scala | 12 +++++++++++ notes/0.13.13/ops_deprecation.md | 21 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 notes/0.13.13/ops_deprecation.md diff --git a/main/settings/src/main/scala/sbt/Structure.scala b/main/settings/src/main/scala/sbt/Structure.scala index 56e08e2d2..9483dc37b 100644 --- a/main/settings/src/main/scala/sbt/Structure.scala +++ b/main/settings/src/main/scala/sbt/Structure.scala @@ -40,7 +40,9 @@ sealed abstract class SettingKey[T] extends ScopedTaskable[T] with KeyedInitiali final def :=(v: T): Setting[T] = macro std.TaskMacro.settingAssignMacroImpl[T] final def +=[U](v: U)(implicit a: Append.Value[T, U]): Setting[T] = macro std.TaskMacro.settingAppend1Impl[T, U] final def ++=[U](vs: U)(implicit a: Append.Values[T, U]): Setting[T] = macro std.TaskMacro.settingAppendNImpl[T, U] + @deprecated("Use `lhs += { x.value }`", "0.13.13") final def <+=[V](v: Initialize[V])(implicit a: Append.Value[T, V]): Setting[T] = macro std.TaskMacro.settingAppend1Position[T, V] + @deprecated("Use `lhs ++= { x.value }`", "0.13.13") final def <++=[V](vs: Initialize[V])(implicit a: Append.Values[T, V]): Setting[T] = macro std.TaskMacro.settingAppendNPosition[T, V] final def -=[U](v: U)(implicit r: Remove.Value[T, U]): Setting[T] = macro std.TaskMacro.settingRemove1Impl[T, U] final def --=[U](vs: U)(implicit r: Remove.Values[T, U]): Setting[T] = macro std.TaskMacro.settingRemoveNImpl[T, U] @@ -71,7 +73,9 @@ sealed abstract class TaskKey[T] extends ScopedTaskable[T] with KeyedInitialize[ def +=[U](v: U)(implicit a: Append.Value[T, U]): Setting[Task[T]] = macro std.TaskMacro.taskAppend1Impl[T, U] def ++=[U](vs: U)(implicit a: Append.Values[T, U]): Setting[Task[T]] = macro std.TaskMacro.taskAppendNImpl[T, U] + @deprecated("Use `lhs += { x.value }`", "0.13.13") def <+=[V](v: Initialize[Task[V]])(implicit a: Append.Value[T, V]): Setting[Task[T]] = macro std.TaskMacro.taskAppend1Position[T, V] + @deprecated("Use `lhs ++= { x.value }`", "0.13.13") def <++=[V](vs: Initialize[Task[V]])(implicit a: Append.Values[T, V]): Setting[Task[T]] = macro std.TaskMacro.taskAppendNPosition[T, V] final def -=[U](v: U)(implicit r: Remove.Value[T, U]): Setting[Task[T]] = macro std.TaskMacro.taskRemove1Impl[T, U] final def --=[U](vs: U)(implicit r: Remove.Values[T, U]): Setting[Task[T]] = macro std.TaskMacro.taskRemoveNImpl[T, U] @@ -153,6 +157,10 @@ object Scoped { * @param app value to bind to this key * @return setting binding this key to the given value. */ + @deprecated("""Use `key := { x.value }` or `key ~= (old => { newValue })`. + |The RHS of `<<=` takes an `Initialize[_]` expression, which can be converted to `:=` style + |by wrapping the expression in parenthesis, and calling `.value` at the end. + |For example, `key := (key.dependsOn(compile in Test)).value`.""".stripMargin, "0.13.13") final def <<=(app: Initialize[S]): Setting[S] = macro std.TaskMacro.settingAssignPosition[S] /** Internally used function for setting a value along with the `.sbt` file location where it is defined. */ @@ -199,6 +207,10 @@ object Scoped { def :=(v: S): Setting[Task[S]] = macro std.TaskMacro.taskAssignMacroImpl[S] def ~=(f: S => S): Setting[Task[S]] = macro std.TaskMacro.taskTransformPosition[S] + @deprecated("""Use `key := { x.value }` or `key ~= (old => { newValue })`. + |The RHS of `<<=` takes an `Initialize[_]` expression, which can be converted to `:=` style + |by wrapping the expression in parenthesis, and calling `.value` at the end. + |For example, `key := (key.dependsOn(compile in Test)).value`.""".stripMargin, "0.13.13") def <<=(app: Initialize[Task[S]]): Setting[Task[S]] = macro std.TaskMacro.itaskAssignPosition[S] def set(app: Initialize[Task[S]], source: SourcePosition): Setting[Task[S]] = Def.setting(scopedKey, app, source) def transform(f: S => S, source: SourcePosition): Setting[Task[S]] = set(scopedKey(_ map f), source) diff --git a/notes/0.13.13/ops_deprecation.md b/notes/0.13.13/ops_deprecation.md new file mode 100644 index 000000000..b58f005f0 --- /dev/null +++ b/notes/0.13.13/ops_deprecation.md @@ -0,0 +1,21 @@ + +### Fixes with compatibility implications + +- Deprecate old operators. + +### Deprecate old operators + +The no-longer-documented operators `<<=`, `<+=`, and `<++=` are deprecated, +and will be removed in sbt 1.0. + +For `<<=`, the suggested migration would be to use either `:=` or `~=` operators. +The RHS of `<<=` takes an `Initialize[_]` expression, which can be converted to `:=` style +by wrapping the expression in parenthesis, and calling `.value` at the end. +For example: + + key := (key.dependsOn(compile in Test)).value + +For `<+=` and `<++=`, use `+= { x.value }` and `++= { x.value }`. + + [@eed3si9n]: https://github.com/eed3si9n +