Make clean task run exclusively

This commit is contained in:
Eugene Yokota 2017-04-12 02:06:31 -04:00
parent 7acb8764f5
commit acf6c1191e
2 changed files with 12 additions and 6 deletions

View File

@ -374,7 +374,7 @@ object Defaults extends BuildCommon {
lazy val projectTasks: Seq[Setting[_]] = Seq(
cleanFiles := cleanFilesTask.value,
cleanKeepFiles := historyPath.value.toVector,
clean := IO.delete(cleanFiles.value),
clean := (Def.task { IO.delete(cleanFiles.value) } tag (Tags.Clean)).value,
consoleProject := consoleProjectTask.value,
watchTransitiveSources := watchTransitiveSourcesTask.value,
watch := watchSetting.value
@ -692,10 +692,15 @@ object Defaults extends BuildCommon {
Def.task {
Tests.discover(loadedTestFrameworks.value.values.toList, compile.value, streams.value.log)._1
}
def defaultRestrictions: Initialize[Seq[Tags.Rule]] = parallelExecution { par =>
val max = EvaluateTask.SystemProcessors
Tags.limitAll(if (par) max else 1) :: Tags.limit(Tags.ForkedTestGroup, 1) :: Nil
}
def defaultRestrictions: Initialize[Seq[Tags.Rule]] =
Def.setting {
val par = parallelExecution.value
val max = EvaluateTask.SystemProcessors
Tags.limitAll(if (par) max else 1) ::
Tags.limit(Tags.ForkedTestGroup, 1) ::
Tags.exclusiveGroup(Tags.Clean) ::
Nil
}
lazy val packageBase: Seq[Setting[_]] = Seq(
artifact := Artifact(moduleName.value)

View File

@ -13,6 +13,7 @@ object Tags {
val Test = Tag("test")
val Update = Tag("update")
val Publish = Tag("publish")
val Clean = Tag("clean")
val CPU = Tag("cpu")
val Network = Tag("network")
@ -24,7 +25,7 @@ object Tags {
* Describes a restriction on concurrently executing tasks.
* A Rule is constructed using one of the Tags.limit* methods.
*/
sealed trait Rule { // TODO: make this an abstract class for 0.14
abstract class Rule {
def apply(m: TagMap): Boolean
def ||(r: Rule): Rule = new Or(this, r)
def &&(r: Rule): Rule = new And(this, r)