Created
August 12, 2011 06:30
-
-
Save kornysietsma/1141574 to your computer and use it in GitHub Desktop.
sbt sample 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed trait Aggregation | |
final object Aggregation | |
{ | |
def apply(dependencies: Seq[ProjectReference], transitive: Boolean = true): Aggregation | |
= new Explicit(dependencies, transitive) | |
implicit def fromBoolean(b: Boolean): Aggregation = if(b) Enabled else Disabled | |
val Enabled = new Implicit(true) | |
val Disabled = new Implicit(false) | |
final case class Implicit(enabled: Boolean) extends Aggregation | |
final class Explicit(val dependencies: Seq[ProjectReference], val transitive: Boolean) | |
extends Aggregation | |
final case class KeyValue[+T](key: ScopedKey[_], value: T) | |
def getTasks[T](key: ScopedKey[T], structure: BuildStructure, transitive: Boolean): | |
Seq[KeyValue[T]] = | |
getTasks0(key, structure, transitive, new mutable.HashMap[(ScopedKey[_], Boolean), | |
Seq[KeyValue[T]]]) | |
private type Memo[T] = mutable.Map[(ScopedKey[_], Boolean), | |
Seq[KeyValue[T]]] | |
private[this] def getTasks0[T](key: ScopedKey[T], structure: BuildStructure, | |
transitive: Boolean, memo: Memo[T]): Seq[KeyValue[T]] = | |
memo.getOrElseUpdate( (key, transitive), { | |
val task = structure.data.get(key.scope, key.key).toList.map(t => KeyValue(key,t)) | |
if(transitive) aggregateDeps(key, structure, memo) ++ task else task | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment