Robin Green
Robin Green

Reputation: 33083

Removing orr workaround for sbt 0.11

I am maintaining some code that has something similar to this double-layered workaround in it:

import AssemblyKeys._   
lazy val assemblySettings: Seq[sbt.Project.Setting[_]] = baseAssemblySettings

implicit def wrapTaskKey[T](key: TaskKey[T]): WrappedTaskKey[T] = WrappedTaskKey(key) 
case class WrappedTaskKey[A](key: TaskKey[A]) {
  def orr[T >: A](rhs: Initialize[Task[T]]): Initialize[Task[T]] =
    (key.? zipWith rhs)( (x,y) => (x :^: y :^: KNil) map Scoped.hf2( _ getOrElse _ ))
}

lazy val baseAssemblySettings: Seq[sbt.Project.Setting[_]] = Seq(
  test <<= test orr (test in Test).identity,
  test in assembly <<= (test in Test).identity,
)

(from here).

How should I completely remove both "layers" of this workaround, since they apparently aren't needed any more in sbt >= 0.12?

Upvotes: 2

Views: 51

Answers (2)

Eugene Yokota
Eugene Yokota

Reputation: 95674

I'm not sure even the or is still necessary though.

It's no longer necessary.

or

or was a workaround for #202 (Task-scoped keys) that worked in sbt 0.10. This but was fixed in sbt 0.12 according to the comment. Let's test this in sbt 0.13:

helloworld> set test in Compile in compile := {}
[info] Defining helloworld/compile:compile::test
helloworld> inspect test
[info] Task: Unit
[info] Description:
[info]  Executes all tests.
[info] Provided by:
[info]  {file:/Users/eed3si9n/work/helloworld/}helloworld/test:test
....

So we are in the clear with #202. In fact I took the or rewiring out of sbt-assembly last week (9/28/2013) for 0.10.0, and now it looks like this:

// test
test in assembly := (test in Test).value,

orr

The orr was a workaround for #204 ("Reference to undefined setting" while using an optional key), which broke or in sbt 0.11.0 and was fixed in 0.11.1 according to the tag. Since we no longer need or, this is sort of a moot, but we don't need orr after sbt 0.11.1.

To avoid further confusion, I removed the section from the unofficial guide and linked to the github for historical interest.

Upvotes: 2

Robin Green
Robin Green

Reputation: 33083

Looking through the logs of sbt-assembly, what is done there is simply removing wrapTaskKey and WrappedTaskKey and replacing orr with or.

I'm not sure even the or is still necessary though. But I don't understand this code at all.

Upvotes: 0

Related Questions