mirror of https://github.com/sbt/sbt.git
Format Structure
This commit is contained in:
parent
c85fbbf215
commit
c5b21ab9d9
|
|
@ -31,41 +31,58 @@ sealed abstract class SettingKey[T]
|
|||
with KeyedInitialize[T]
|
||||
with Scoped.ScopingSetting[SettingKey[T]]
|
||||
with Scoped.DefinableSetting[T] {
|
||||
|
||||
val key: AttributeKey[T]
|
||||
|
||||
final def toTask: Initialize[Task[T]] = this apply inlineTask
|
||||
|
||||
final def scopedKey: ScopedKey[T] = ScopedKey(scope, key)
|
||||
|
||||
final def in(scope: Scope): SettingKey[T] =
|
||||
Scoped.scopedSetting(Scope.replaceThis(this.scope)(scope), this.key)
|
||||
|
||||
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]
|
||||
|
||||
final def <+=[V](v: Initialize[V])(implicit a: Append.Value[T, V]): Setting[T] =
|
||||
macro std.TaskMacro.fakeSettingAppend1Position[T, V]
|
||||
|
||||
final def <++=[V](vs: Initialize[V])(implicit a: Append.Values[T, V]): Setting[T] =
|
||||
macro std.TaskMacro.fakeSettingAppendNPosition[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]
|
||||
|
||||
final def ~=(f: T => T): Setting[T] = macro std.TaskMacro.settingTransformPosition[T]
|
||||
|
||||
final def append1[V](v: Initialize[V], source: SourcePosition)(
|
||||
implicit a: Append.Value[T, V]): Setting[T] = make(v, source)(a.appendValue)
|
||||
implicit a: Append.Value[T, V]
|
||||
): Setting[T] = make(v, source)(a.appendValue)
|
||||
|
||||
final def appendN[V](vs: Initialize[V], source: SourcePosition)(
|
||||
implicit a: Append.Values[T, V]): Setting[T] = make(vs, source)(a.appendValues)
|
||||
implicit a: Append.Values[T, V]
|
||||
): Setting[T] = make(vs, source)(a.appendValues)
|
||||
|
||||
final def remove1[V](v: Initialize[V], source: SourcePosition)(
|
||||
implicit r: Remove.Value[T, V]): Setting[T] = make(v, source)(r.removeValue)
|
||||
implicit r: Remove.Value[T, V]
|
||||
): Setting[T] = make(v, source)(r.removeValue)
|
||||
final def removeN[V](vs: Initialize[V], source: SourcePosition)(
|
||||
implicit r: Remove.Values[T, V]): Setting[T] = make(vs, source)(r.removeValues)
|
||||
implicit r: Remove.Values[T, V]
|
||||
): Setting[T] = make(vs, source)(r.removeValues)
|
||||
|
||||
final def transform(f: T => T, source: SourcePosition): Setting[T] = set(scopedKey(f), source)
|
||||
|
||||
protected[this] def make[S](other: Initialize[S], source: SourcePosition)(
|
||||
f: (T, S) => T): Setting[T] =
|
||||
f: (T, S) => T
|
||||
): Setting[T] =
|
||||
set((this, other)(f), source)
|
||||
}
|
||||
|
||||
|
|
@ -80,37 +97,53 @@ sealed abstract class TaskKey[T]
|
|||
with KeyedInitialize[Task[T]]
|
||||
with Scoped.ScopingSetting[TaskKey[T]]
|
||||
with Scoped.DefinableTask[T] {
|
||||
|
||||
val key: AttributeKey[Task[T]]
|
||||
|
||||
def toTask: Initialize[Task[T]] = this
|
||||
|
||||
def scopedKey: ScopedKey[Task[T]] = ScopedKey(scope, key)
|
||||
|
||||
def in(scope: Scope): TaskKey[T] =
|
||||
Scoped.scopedTask(Scope.replaceThis(this.scope)(scope), this.key)
|
||||
|
||||
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]
|
||||
|
||||
def <+=[V](v: Initialize[Task[V]])(implicit a: Append.Value[T, V]): Setting[Task[T]] =
|
||||
macro std.TaskMacro.fakeTaskAppend1Position[T, V]
|
||||
|
||||
def <++=[V](vs: Initialize[Task[V]])(implicit a: Append.Values[T, V]): Setting[Task[T]] =
|
||||
macro std.TaskMacro.fakeTaskAppendNPosition[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]
|
||||
|
||||
def append1[V](v: Initialize[Task[V]], source: SourcePosition)(
|
||||
implicit a: Append.Value[T, V]): Setting[Task[T]] = make(v, source)(a.appendValue)
|
||||
implicit a: Append.Value[T, V]
|
||||
): Setting[Task[T]] = make(v, source)(a.appendValue)
|
||||
|
||||
def appendN[V](vs: Initialize[Task[V]], source: SourcePosition)(
|
||||
implicit a: Append.Values[T, V]): Setting[Task[T]] = make(vs, source)(a.appendValues)
|
||||
implicit a: Append.Values[T, V]
|
||||
): Setting[Task[T]] = make(vs, source)(a.appendValues)
|
||||
|
||||
final def remove1[V](v: Initialize[Task[V]], source: SourcePosition)(
|
||||
implicit r: Remove.Value[T, V]): Setting[Task[T]] = make(v, source)(r.removeValue)
|
||||
implicit r: Remove.Value[T, V]
|
||||
): Setting[Task[T]] = make(v, source)(r.removeValue)
|
||||
|
||||
final def removeN[V](vs: Initialize[Task[V]], source: SourcePosition)(
|
||||
implicit r: Remove.Values[T, V]): Setting[Task[T]] = make(vs, source)(r.removeValues)
|
||||
implicit r: Remove.Values[T, V]
|
||||
): Setting[Task[T]] = make(vs, source)(r.removeValues)
|
||||
|
||||
private[this] def make[S](other: Initialize[Task[S]], source: SourcePosition)(
|
||||
f: (T, S) => T): Setting[Task[T]] =
|
||||
f: (T, S) => T
|
||||
): Setting[Task[T]] =
|
||||
set((this, other)((a, b) => (a, b) map f.tupled), source)
|
||||
}
|
||||
|
||||
|
|
@ -126,13 +159,17 @@ sealed trait InputKey[T]
|
|||
with KeyedInitialize[InputTask[T]]
|
||||
with Scoped.ScopingSetting[InputKey[T]]
|
||||
with Scoped.DefinableSetting[InputTask[T]] {
|
||||
|
||||
val key: AttributeKey[InputTask[T]]
|
||||
|
||||
def scopedKey: ScopedKey[InputTask[T]] = ScopedKey(scope, key)
|
||||
|
||||
def in(scope: Scope): InputKey[T] =
|
||||
Scoped.scopedInput(Scope.replaceThis(this.scope)(scope), this.key)
|
||||
|
||||
final def :=(v: T): Setting[InputTask[T]] = macro std.TaskMacro.inputTaskAssignMacroImpl[T]
|
||||
final def ~=(f: T => T): Setting[InputTask[T]] = macro std.TaskMacro.itaskTransformPosition[T]
|
||||
|
||||
final def transform(f: T => T, source: SourcePosition): Setting[InputTask[T]] =
|
||||
set(scopedKey(_ mapTask { _ map f }), source)
|
||||
}
|
||||
|
|
@ -140,6 +177,7 @@ sealed trait InputKey[T]
|
|||
/** Methods and types related to constructing settings, including keys, scopes, and initializations. */
|
||||
object Scoped {
|
||||
implicit def taskScopedToKey[T](s: TaskKey[T]): ScopedKey[Task[T]] = ScopedKey(s.scope, s.key)
|
||||
|
||||
implicit def inputScopedToKey[T](s: InputKey[T]): ScopedKey[InputTask[T]] =
|
||||
ScopedKey(s.scope, s.key)
|
||||
|
||||
|
|
@ -167,22 +205,25 @@ object Scoped {
|
|||
def in(c: ConfigKey, t: Scoped): ResultType = in(This, Select(c), Select(t.key))
|
||||
def in(p: Reference, c: ConfigKey): ResultType = in(Select(p), Select(c), This)
|
||||
def in(p: Reference, t: Scoped): ResultType = in(Select(p), This, Select(t.key))
|
||||
|
||||
def in(p: Reference, c: ConfigKey, t: Scoped): ResultType =
|
||||
in(Select(p), Select(c), Select(t.key))
|
||||
def in(p: ScopeAxis[Reference],
|
||||
c: ScopeAxis[ConfigKey],
|
||||
t: ScopeAxis[AttributeKey[_]]): ResultType = in(Scope(p, c, t, This))
|
||||
|
||||
def in(
|
||||
p: ScopeAxis[Reference],
|
||||
c: ScopeAxis[ConfigKey],
|
||||
t: ScopeAxis[AttributeKey[_]]
|
||||
): ResultType = in(Scope(p, c, t, This))
|
||||
}
|
||||
|
||||
def scopedSetting[T](s: Scope, k: AttributeKey[T]): SettingKey[T] = new SettingKey[T] {
|
||||
val scope = s; val key = k
|
||||
}
|
||||
def scopedInput[T](s: Scope, k: AttributeKey[InputTask[T]]): InputKey[T] = new InputKey[T] {
|
||||
val scope = s; val key = k
|
||||
}
|
||||
def scopedTask[T](s: Scope, k: AttributeKey[Task[T]]): TaskKey[T] = new TaskKey[T] {
|
||||
val scope = s; val key = k
|
||||
}
|
||||
def scopedSetting[T](s: Scope, k: AttributeKey[T]): SettingKey[T] =
|
||||
new SettingKey[T] { val scope = s; val key = k }
|
||||
|
||||
def scopedInput[T](s: Scope, k: AttributeKey[InputTask[T]]): InputKey[T] =
|
||||
new InputKey[T] { val scope = s; val key = k }
|
||||
|
||||
def scopedTask[T](s: Scope, k: AttributeKey[Task[T]]): TaskKey[T] =
|
||||
new TaskKey[T] { val scope = s; val key = k }
|
||||
|
||||
/**
|
||||
* Mixin trait for adding convenience vocabulary associated with applying a setting to a configuration item.
|
||||
|
|
@ -237,27 +278,34 @@ object Scoped {
|
|||
sealed trait DefinableTask[S] { self: TaskKey[S] =>
|
||||
|
||||
private[sbt] def :==(app: S): Setting[Task[S]] = macro std.TaskMacro.taskAssignPositionPure[S]
|
||||
|
||||
private[sbt] def ::=(app: Task[S]): Setting[Task[S]] =
|
||||
macro std.TaskMacro.taskAssignPositionT[S]
|
||||
|
||||
def :=(v: S): Setting[Task[S]] = macro std.TaskMacro.taskAssignMacroImpl[S]
|
||||
def ~=(f: S => S): Setting[Task[S]] = macro std.TaskMacro.taskTransformPosition[S]
|
||||
|
||||
def <<=(app: Initialize[Task[S]]): Setting[Task[S]] =
|
||||
macro std.TaskMacro.fakeItaskAssignPosition[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)
|
||||
|
||||
@deprecated("No longer needed with new task syntax and SettingKey inheriting from Initialize.",
|
||||
"0.13.2")
|
||||
def task: SettingKey[Task[S]] = scopedSetting(scope, key)
|
||||
|
||||
def get(settings: Settings[Scope]): Option[Task[S]] = settings.get(scope, key)
|
||||
|
||||
def ? : Initialize[Task[Option[S]]] = Def.optional(scopedKey) {
|
||||
case None => mktask { None }; case Some(t) => t map some.fn
|
||||
}
|
||||
|
||||
def ??[T >: S](or: => T): Initialize[Task[T]] = Def.optional(scopedKey)(_ getOrElse mktask(or))
|
||||
|
||||
def or[T >: S](i: Initialize[Task[T]]): Initialize[Task[T]] =
|
||||
(this.? zipWith i)((x, y) => (x, y) map { case (a, b) => a getOrElse b })
|
||||
}
|
||||
|
|
@ -273,13 +321,17 @@ object Scoped {
|
|||
|
||||
def xtriggeredBy[T](tasks: Initialize[Task[T]]*): Initialize[Task[S]] =
|
||||
nonLocal(tasks, Def.triggeredBy)
|
||||
|
||||
def triggeredBy[T](tasks: Initialize[Task[T]]*): Initialize[Task[S]] =
|
||||
nonLocal(tasks, Def.triggeredBy)
|
||||
|
||||
def runBefore[T](tasks: Initialize[Task[T]]*): Initialize[Task[S]] =
|
||||
nonLocal(tasks, Def.runBefore)
|
||||
|
||||
private[this] def nonLocal(tasks: Seq[AnyInitTask],
|
||||
key: AttributeKey[Seq[Task[_]]]): Initialize[Task[S]] =
|
||||
private[this] def nonLocal(
|
||||
tasks: Seq[AnyInitTask],
|
||||
key: AttributeKey[Seq[Task[_]]]
|
||||
): Initialize[Task[S]] =
|
||||
(Initialize.joinAny[Task](tasks), i)((ts, i) => i.copy(info = i.info.set(key, ts)))
|
||||
}
|
||||
|
||||
|
|
@ -334,6 +386,7 @@ object Scoped {
|
|||
def join: Initialize[Task[Seq[T]]] = tasks(_.join)
|
||||
def tasks: Initialize[Seq[Task[T]]] = Initialize.join(keys)
|
||||
}
|
||||
|
||||
implicit def richAnyTaskSeq(in: Seq[AnyInitTask]): RichAnyTaskSeq = new RichAnyTaskSeq(in)
|
||||
final class RichAnyTaskSeq(keys: Seq[AnyInitTask]) {
|
||||
def dependOn: Initialize[Task[Unit]] =
|
||||
|
|
@ -357,13 +410,20 @@ object Scoped {
|
|||
// format: on
|
||||
|
||||
sealed abstract class RichTaskables[K[L[x]]](final val keys: K[ScopedTaskable])(
|
||||
implicit a: AList[K]) {
|
||||
implicit a: AList[K]
|
||||
) {
|
||||
|
||||
type App[T] = Initialize[Task[T]]
|
||||
type Fun[M[_], Ret]
|
||||
|
||||
protected def convert[M[_], Ret](f: Fun[M, Ret]): K[M] => Ret
|
||||
private[this] val inputs: K[App] = a.transform(keys, new (ScopedTaskable ~> App) {
|
||||
def apply[T](in: ScopedTaskable[T]): App[T] = in.toTask
|
||||
})
|
||||
|
||||
private[this] val inputs: K[App] =
|
||||
a.transform(
|
||||
keys,
|
||||
new (ScopedTaskable ~> App) { def apply[T](in: ScopedTaskable[T]): App[T] = in.toTask }
|
||||
)
|
||||
|
||||
private[this] def onTasks[T](f: K[Task] => Task[T]): App[T] =
|
||||
Def.app[({ type l[L[x]] = K[(L ∙ Task)#l] })#l, Task[T]](inputs)(f)(AList.asplit[K, Task](a))
|
||||
|
||||
|
|
@ -506,22 +566,27 @@ import Scoped.extendScoped
|
|||
|
||||
/** Constructs InputKeys, which are associated with input tasks to define a setting.*/
|
||||
object InputKey {
|
||||
def apply[T: Manifest](label: String,
|
||||
description: String = "",
|
||||
rank: Int = KeyRanks.DefaultInputRank): InputKey[T] =
|
||||
def apply[T: Manifest](
|
||||
label: String,
|
||||
description: String = "",
|
||||
rank: Int = KeyRanks.DefaultInputRank
|
||||
): InputKey[T] =
|
||||
apply(AttributeKey[InputTask[T]](label, description, rank))
|
||||
|
||||
def apply[T: Manifest](label: String,
|
||||
description: String,
|
||||
extend1: Scoped,
|
||||
extendN: Scoped*): InputKey[T] =
|
||||
apply(label, description, KeyRanks.DefaultInputRank, extend1, extendN: _*)
|
||||
def apply[T: Manifest](
|
||||
label: String,
|
||||
description: String,
|
||||
extend1: Scoped,
|
||||
extendN: Scoped*
|
||||
): InputKey[T] = apply(label, description, KeyRanks.DefaultInputRank, extend1, extendN: _*)
|
||||
|
||||
def apply[T: Manifest](label: String,
|
||||
description: String,
|
||||
rank: Int,
|
||||
extend1: Scoped,
|
||||
extendN: Scoped*): InputKey[T] =
|
||||
def apply[T: Manifest](
|
||||
label: String,
|
||||
description: String,
|
||||
rank: Int,
|
||||
extend1: Scoped,
|
||||
extendN: Scoped*
|
||||
): InputKey[T] =
|
||||
apply(AttributeKey[InputTask[T]](label, description, extendScoped(extend1, extendN), rank))
|
||||
|
||||
def apply[T](akey: AttributeKey[InputTask[T]]): InputKey[T] =
|
||||
|
|
@ -530,22 +595,28 @@ object InputKey {
|
|||
|
||||
/** Constructs TaskKeys, which are associated with tasks to define a setting.*/
|
||||
object TaskKey {
|
||||
def apply[T: Manifest](label: String,
|
||||
description: String = "",
|
||||
rank: Int = KeyRanks.DefaultTaskRank): TaskKey[T] =
|
||||
def apply[T: Manifest](
|
||||
label: String,
|
||||
description: String = "",
|
||||
rank: Int = KeyRanks.DefaultTaskRank
|
||||
): TaskKey[T] =
|
||||
apply(AttributeKey[Task[T]](label, description, rank))
|
||||
|
||||
def apply[T: Manifest](label: String,
|
||||
description: String,
|
||||
extend1: Scoped,
|
||||
extendN: Scoped*): TaskKey[T] =
|
||||
def apply[T: Manifest](
|
||||
label: String,
|
||||
description: String,
|
||||
extend1: Scoped,
|
||||
extendN: Scoped*
|
||||
): TaskKey[T] =
|
||||
apply(AttributeKey[Task[T]](label, description, extendScoped(extend1, extendN)))
|
||||
|
||||
def apply[T: Manifest](label: String,
|
||||
description: String,
|
||||
rank: Int,
|
||||
extend1: Scoped,
|
||||
extendN: Scoped*): TaskKey[T] =
|
||||
def apply[T: Manifest](
|
||||
label: String,
|
||||
description: String,
|
||||
rank: Int,
|
||||
extend1: Scoped,
|
||||
extendN: Scoped*
|
||||
): TaskKey[T] =
|
||||
apply(AttributeKey[Task[T]](label, description, extendScoped(extend1, extendN), rank))
|
||||
|
||||
def apply[T](akey: AttributeKey[Task[T]]): TaskKey[T] =
|
||||
|
|
@ -556,22 +627,28 @@ object TaskKey {
|
|||
|
||||
/** Constructs SettingKeys, which are associated with a value to define a basic setting.*/
|
||||
object SettingKey {
|
||||
def apply[T: Manifest: OptJsonWriter](label: String,
|
||||
description: String = "",
|
||||
rank: Int = KeyRanks.DefaultSettingRank): SettingKey[T] =
|
||||
def apply[T: Manifest: OptJsonWriter](
|
||||
label: String,
|
||||
description: String = "",
|
||||
rank: Int = KeyRanks.DefaultSettingRank
|
||||
): SettingKey[T] =
|
||||
apply(AttributeKey[T](label, description, rank))
|
||||
|
||||
def apply[T: Manifest: OptJsonWriter](label: String,
|
||||
description: String,
|
||||
extend1: Scoped,
|
||||
extendN: Scoped*): SettingKey[T] =
|
||||
def apply[T: Manifest: OptJsonWriter](
|
||||
label: String,
|
||||
description: String,
|
||||
extend1: Scoped,
|
||||
extendN: Scoped*
|
||||
): SettingKey[T] =
|
||||
apply(AttributeKey[T](label, description, extendScoped(extend1, extendN)))
|
||||
|
||||
def apply[T: Manifest: OptJsonWriter](label: String,
|
||||
description: String,
|
||||
rank: Int,
|
||||
extend1: Scoped,
|
||||
extendN: Scoped*): SettingKey[T] =
|
||||
def apply[T: Manifest: OptJsonWriter](
|
||||
label: String,
|
||||
description: String,
|
||||
rank: Int,
|
||||
extend1: Scoped,
|
||||
extendN: Scoped*
|
||||
): SettingKey[T] =
|
||||
apply(AttributeKey[T](label, description, extendScoped(extend1, extendN), rank))
|
||||
|
||||
def apply[T](akey: AttributeKey[T]): SettingKey[T] =
|
||||
|
|
|
|||
Loading…
Reference in New Issue