mirror of https://github.com/sbt/sbt.git
disable printing of success for 'export' command
This commit is contained in:
parent
a263b7e91f
commit
9d82718897
|
|
@ -14,10 +14,11 @@ package sbt
|
||||||
sealed trait Aggregation
|
sealed trait Aggregation
|
||||||
final object Aggregation
|
final object Aggregation
|
||||||
{
|
{
|
||||||
final case class ShowConfig(settingValues: Boolean, taskValues: Boolean, print: String => Unit)
|
final case class ShowConfig(settingValues: Boolean, taskValues: Boolean, print: String => Unit, success: Boolean)
|
||||||
|
final case class Complete[T](start: Long, stop: Long, results: Result[Seq[KeyValue[T]]], state: State)
|
||||||
final case class KeyValue[+T](key: ScopedKey[_], value: T)
|
final case class KeyValue[+T](key: ScopedKey[_], value: T)
|
||||||
|
|
||||||
def defaultShow(state: State, showTasks: Boolean): ShowConfig = ShowConfig(settingValues = true, taskValues = showTasks, s => state.log.info(s))
|
def defaultShow(state: State, showTasks: Boolean): ShowConfig = ShowConfig(settingValues = true, taskValues = showTasks, s => state.log.info(s), success = true)
|
||||||
def printSettings[T](xs: Seq[KeyValue[T]], print: String => Unit)(implicit display: Show[ScopedKey[_]]) =
|
def printSettings[T](xs: Seq[KeyValue[T]], print: String => Unit)(implicit display: Show[ScopedKey[_]]) =
|
||||||
xs match
|
xs match
|
||||||
{
|
{
|
||||||
|
|
@ -32,12 +33,30 @@ final object Aggregation
|
||||||
Command.applyEffect(seqParser(ps)) { ts =>
|
Command.applyEffect(seqParser(ps)) { ts =>
|
||||||
runTasks(s, structure, ts, DummyTaskMap(Nil), show)
|
runTasks(s, structure, ts, DummyTaskMap(Nil), show)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@deprecated("Use `timedRun` and `showRun` directly or use `runTasks`.", "0.13.0")
|
||||||
def runTasksWithResult[T](s: State, structure: BuildStructure, ts: Values[Task[T]], extra: DummyTaskMap, show: ShowConfig)(implicit display: Show[ScopedKey[_]]): (State, Result[Seq[KeyValue[T]]]) =
|
def runTasksWithResult[T](s: State, structure: BuildStructure, ts: Values[Task[T]], extra: DummyTaskMap, show: ShowConfig)(implicit display: Show[ScopedKey[_]]): (State, Result[Seq[KeyValue[T]]]) =
|
||||||
|
{
|
||||||
|
val complete = timedRun[T](s, ts, extra)
|
||||||
|
showRun(complete, show)
|
||||||
|
(complete.state, complete.results)
|
||||||
|
}
|
||||||
|
def showRun[T](complete: Complete[T], show: ShowConfig)(implicit display: Show[ScopedKey[_]])
|
||||||
|
{
|
||||||
|
import complete._
|
||||||
|
val log = state.log
|
||||||
|
val extracted = Project extract state
|
||||||
|
val success = results match { case Value(_) => true; case Inc(_) => false }
|
||||||
|
try { EvaluateTask.onResult(results, log) { results => if(show.taskValues) printSettings(results, show.print) } }
|
||||||
|
finally { if(show.success) printSuccess(start, stop, extracted, success, log) }
|
||||||
|
}
|
||||||
|
def timedRun[T](s: State, ts: Values[Task[T]], extra: DummyTaskMap): Complete[T] =
|
||||||
{
|
{
|
||||||
import EvaluateTask._
|
import EvaluateTask._
|
||||||
import std.TaskExtra._
|
import std.TaskExtra._
|
||||||
|
|
||||||
val extracted = Project extract s
|
val extracted = Project extract s
|
||||||
|
import extracted.structure
|
||||||
val toRun = ts map { case KeyValue(k,t) => t.map(v => KeyValue(k,v)) } join;
|
val toRun = ts map { case KeyValue(k,t) => t.map(v => KeyValue(k,v)) } join;
|
||||||
val roots = ts map { case KeyValue(k,_) => k }
|
val roots = ts map { case KeyValue(k,_) => k }
|
||||||
val config = extractedConfig(extracted, structure)
|
val config = extractedConfig(extracted, structure)
|
||||||
|
|
@ -48,20 +67,15 @@ final object Aggregation
|
||||||
runTask(toRun, s,str, structure.index.triggers, config)(transform)
|
runTask(toRun, s,str, structure.index.triggers, config)(transform)
|
||||||
}
|
}
|
||||||
val stop = System.currentTimeMillis
|
val stop = System.currentTimeMillis
|
||||||
val log = newS.log
|
Complete(start, stop, result, newS)
|
||||||
|
|
||||||
val success = result match { case Value(_) => true; case Inc(_) => false }
|
|
||||||
try { onResult(result, log) { results => if(show.taskValues) printSettings(results, show.print) } }
|
|
||||||
finally { printSuccess(start, stop, extracted, success, log) }
|
|
||||||
|
|
||||||
(newS, result)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def runTasks[HL <: HList, T](s: State, structure: BuildStructure, ts: Values[Task[T]], extra: DummyTaskMap, show: ShowConfig)(implicit display: Show[ScopedKey[_]]): State = {
|
def runTasks[HL <: HList, T](s: State, structure: BuildStructure, ts: Values[Task[T]], extra: DummyTaskMap, show: ShowConfig)(implicit display: Show[ScopedKey[_]]): State = {
|
||||||
runTasksWithResult(s, structure, ts, extra, show)._1
|
val complete = timedRun[T](s, ts, extra)
|
||||||
|
showRun(complete, show)
|
||||||
|
complete.state
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def printSuccess(start: Long, stop: Long, extracted: Extracted, success: Boolean, log: Logger)
|
def printSuccess(start: Long, stop: Long, extracted: Extracted, success: Boolean, log: Logger)
|
||||||
{
|
{
|
||||||
import extracted._
|
import extracted._
|
||||||
|
|
|
||||||
|
|
@ -303,7 +303,7 @@ object BuiltinCommands
|
||||||
val extracted = Project extract s
|
val extracted = Project extract s
|
||||||
import extracted.{showKey, structure}
|
import extracted.{showKey, structure}
|
||||||
val keysParser = token(flag("--last" <~ Space)) ~ Act.aggregatedKeyParser(extracted)
|
val keysParser = token(flag("--last" <~ Space)) ~ Act.aggregatedKeyParser(extracted)
|
||||||
val show = Aggregation.ShowConfig(settingValues = true, taskValues = false, print = println _)
|
val show = Aggregation.ShowConfig(settingValues = true, taskValues = false, print = println _, success = false)
|
||||||
for {
|
for {
|
||||||
lastOnly_keys <- keysParser
|
lastOnly_keys <- keysParser
|
||||||
kvs = Act.keyValues(structure)(lastOnly_keys._2)
|
kvs = Act.keyValues(structure)(lastOnly_keys._2)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue