diff --git a/main/src/main/scala/sbt/EvaluateTask.scala b/main/src/main/scala/sbt/EvaluateTask.scala index 8d45104cb..d1c5010d0 100644 --- a/main/src/main/scala/sbt/EvaluateTask.scala +++ b/main/src/main/scala/sbt/EvaluateTask.scala @@ -39,7 +39,7 @@ import scala.util.control.NonFatal */ trait RunningTaskEngine { - /** Attempts to kill and shutdown the running task engine.*/ + /** Attempts to kill and shutdown the running task engine. */ def cancelAndShutdown(): Unit } @@ -180,16 +180,15 @@ object EvaluateTask { // which is a little hard to control. def addShutdownHandler[A](thunk: () => A): Unit = { capturedThunk - .set( - () => - try { - thunk() - () - } catch { - case NonFatal(e) => - System.err.println(s"Caught exception running shutdown hook: $e") - e.printStackTrace(System.err) - } + .set(() => + try { + thunk() + () + } catch { + case NonFatal(e) => + System.err.println(s"Caught exception running shutdown hook: $e") + e.printStackTrace(System.err) + } ) } @@ -249,9 +248,14 @@ object EvaluateTask { structure: BuildStructure, state: State ): TaskCancellationStrategy = - getSetting(Keys.taskCancelStrategy, { (_: State) => - TaskCancellationStrategy.Null - }, extracted, structure)(state) + getSetting( + Keys.taskCancelStrategy, + { (_: State) => + TaskCancellationStrategy.Null + }, + extracted, + structure + )(state) private[sbt] def executeProgress( extracted: Extracted, @@ -511,7 +515,8 @@ object EvaluateTask { val results = x.runKeep(root)(service) storeValuesForPrevious(results, state, streams) applyResults(results, state, root) - } catch { case inc: Incomplete => (state, Inc(inc)) } finally shutdown() + } catch { case inc: Incomplete => (state, Inc(inc)) } + finally shutdown() val replaced = transformInc(result) logIncResult(replaced, state, streams) (newState, replaced) @@ -556,8 +561,8 @@ object EvaluateTask { Function.chain( results.toTypedSeq flatMap { case results.TPair(_, Value(KeyValue(_, st: StateTransform))) => Some(st.transform) - case results.TPair(Task(info, _), Value(v)) => info.post(v) get transformState - case _ => Nil + case results.TPair(Task(info, _), Value(v)) => info.post(v) get transformState + case _ => Nil } ) @@ -595,7 +600,9 @@ object EvaluateTask { def liftAnonymous: Incomplete => Incomplete = { case i @ Incomplete(_, _, None, causes, None) => - causes.find(inc => inc.node.isEmpty && (inc.message.isDefined || inc.directCause.isDefined)) match { + causes.find(inc => + inc.node.isEmpty && (inc.message.isDefined || inc.directCause.isDefined) + ) match { case Some(lift) => i.copy(directCause = lift.directCause, message = lift.message) case None => i } diff --git a/main/src/main/scala/sbt/Extracted.scala b/main/src/main/scala/sbt/Extracted.scala index cec5beb4c..88bb3b9e7 100644 --- a/main/src/main/scala/sbt/Extracted.scala +++ b/main/src/main/scala/sbt/Extracted.scala @@ -116,13 +116,13 @@ final case class Extracted( private[this] def resolve[K <: Scoped.ScopingSetting[K] with Scoped](key: K): K = key in Scope.resolveScope(GlobalScope, currentRef.build, rootProject)(key.scope) - private def getOrError[T](scope: Scope, key: AttributeKey[_], value: Option[T])( - implicit display: Show[ScopedKey[_]] + private def getOrError[T](scope: Scope, key: AttributeKey[_], value: Option[T])(implicit + display: Show[ScopedKey[_]] ): T = value getOrElse sys.error(display.show(ScopedKey(scope, key)) + " is undefined.") - private def getOrError[T](scope: Scope, key: AttributeKey[T])( - implicit display: Show[ScopedKey[_]] + private def getOrError[T](scope: Scope, key: AttributeKey[T])(implicit + display: Show[ScopedKey[_]] ): T = getOrError(scope, key, structure.data.get(scope, key))(display) diff --git a/main/src/main/scala/sbt/MainLoop.scala b/main/src/main/scala/sbt/MainLoop.scala index 0a051ffbd..6ea426dad 100644 --- a/main/src/main/scala/sbt/MainLoop.scala +++ b/main/src/main/scala/sbt/MainLoop.scala @@ -26,7 +26,7 @@ import scala.util.control.NonFatal object MainLoop { - /** Entry point to run the remaining commands in State with managed global logging.*/ + /** Entry point to run the remaining commands in State with managed global logging. */ def runLogged(state: State): xsbti.MainResult = { // We've disabled jline shutdown hooks to prevent classloader leaks, and have been careful to always restore @@ -42,7 +42,7 @@ object MainLoop { } } - /** Run loop that evaluates remaining commands and manages changes to global logging configuration.*/ + /** Run loop that evaluates remaining commands and manages changes to global logging configuration. */ @tailrec def runLoggedLoop(state: State, logBacking: GlobalLogBacking): xsbti.MainResult = runAndClearLast(state, logBacking) match { case ret: Return => // delete current and last log files when exiting normally @@ -235,25 +235,28 @@ object MainLoop { * Dropping (FastTrackCommands.evaluate ... getOrElse) should be functionally identical * but slower. */ - val newState = try { - FastTrackCommands - .evaluate(termState, exec.commandLine) - .getOrElse(Command.process(exec.commandLine, termState)) - } catch { - case _: RejectedExecutionException => - // No stack trace since this is just to notify the user which command they cancelled - object Cancelled extends Throwable(exec.commandLine, null, true, false) { - override def toString: String = s"Cancelled: ${exec.commandLine}" - } - throw Cancelled - } finally { - // Flush the terminal output after command evaluation to ensure that all output - // is displayed in the thin client before we report the command status. Also - // set the prompt to whatever it was before we started evaluating the task. - restoreTerminal() - } - if (exec.execId.fold(true)(!_.startsWith(networkExecPrefix)) && - !exec.commandLine.startsWith(networkExecPrefix)) { + val newState = + try { + FastTrackCommands + .evaluate(termState, exec.commandLine) + .getOrElse(Command.process(exec.commandLine, termState)) + } catch { + case _: RejectedExecutionException => + // No stack trace since this is just to notify the user which command they cancelled + object Cancelled extends Throwable(exec.commandLine, null, true, false) { + override def toString: String = s"Cancelled: ${exec.commandLine}" + } + throw Cancelled + } finally { + // Flush the terminal output after command evaluation to ensure that all output + // is displayed in the thin client before we report the command status. Also + // set the prompt to whatever it was before we started evaluating the task. + restoreTerminal() + } + if ( + exec.execId.fold(true)(!_.startsWith(networkExecPrefix)) && + !exec.commandLine.startsWith(networkExecPrefix) + ) { val doneEvent = ExecStatusEvent( "Done", channelName, @@ -331,8 +334,10 @@ object MainLoop { // it's handled by executing the shell again, instead of the state failing // so we also use that to indicate that the execution failed private[this] def exitCodeFromStateOnFailure(state: State, prevState: State): ExitCode = - if (prevState.onFailure.isDefined && state.onFailure.isEmpty && - state.currentCommand.fold(true)(_.commandLine != StashOnFailure)) { + if ( + prevState.onFailure.isDefined && state.onFailure.isEmpty && + state.currentCommand.fold(true)(_.commandLine != StashOnFailure) + ) { ExitCode(ErrorCodes.UnknownError) } else ExitCode.Success } diff --git a/main/src/main/scala/sbt/PluginCross.scala b/main/src/main/scala/sbt/PluginCross.scala index dbadb542a..5c9009bad 100644 --- a/main/src/main/scala/sbt/PluginCross.scala +++ b/main/src/main/scala/sbt/PluginCross.scala @@ -73,17 +73,16 @@ private[sbt] object PluginCross { import x._ ((currentRef / crossSbtVersions) get structure.data getOrElse Nil).toList } - Command.arb(requireSession(crossParser), pluginCrossHelp) { - case (state, command) => - val x = Project.extract(state) - import x._ - val versions = crossVersions(state) - val current = (pluginCrossBuild / sbtVersion) - .get(structure.data) - .map(PluginSwitchCommand + " " + _) - .toList - if (versions.isEmpty) command :: state - else versions.map(PluginSwitchCommand + " " + _ + " " + command) ::: current ::: state + Command.arb(requireSession(crossParser), pluginCrossHelp) { case (state, command) => + val x = Project.extract(state) + import x._ + val versions = crossVersions(state) + val current = (pluginCrossBuild / sbtVersion) + .get(structure.data) + .map(PluginSwitchCommand + " " + _) + .toList + if (versions.isEmpty) command :: state + else versions.map(PluginSwitchCommand + " " + _ + " " + command) ::: current ::: state } } diff --git a/main/src/main/scala/sbt/Plugins.scala b/main/src/main/scala/sbt/Plugins.scala index 502d72111..b2c77b9aa 100644 --- a/main/src/main/scala/sbt/Plugins.scala +++ b/main/src/main/scala/sbt/Plugins.scala @@ -89,7 +89,7 @@ abstract class AutoPlugin extends Plugins.Basic with PluginsFunctions { override def toString: String = label - /** The `Configuration`s to add to each project that activates this AutoPlugin.*/ + /** The `Configuration`s to add to each project that activates this AutoPlugin. */ def projectConfigurations: Seq[Configuration] = Nil /** The `Setting`s to add in the scope of each project that activates this AutoPlugin. */ @@ -167,7 +167,7 @@ object Plugins extends PluginsFunctions { * The [[AutoPlugin]]s are topologically sorted so that a required [[AutoPlugin]] comes before its requiring [[AutoPlugin]]. */ def deducer(defined0: List[AutoPlugin]): (Plugins, Logger) => Seq[AutoPlugin] = - if (defined0.isEmpty)(_, _) => Nil + if (defined0.isEmpty) (_, _) => Nil else { // TODO: defined should return all the plugins val allReqs = (defined0 flatMap { asRequirements }).toSet @@ -225,9 +225,13 @@ object Plugins extends PluginsFunctions { (selectedPlugins flatMap { Plugins.asExclusions }).toSet val c = selectedPlugins.toSet & forbidden if (c.nonEmpty) { - exclusionConflictError(requestedPlugins, selectedPlugins, c.toSeq sortBy { - _.label - }) + exclusionConflictError( + requestedPlugins, + selectedPlugins, + c.toSeq sortBy { + _.label + } + ) } val retval = topologicalSort(selectedPlugins) // log.debug(s" :: sorted deduced result: ${retval.toString}") @@ -270,9 +274,8 @@ object Plugins extends PluginsFunctions { lits map { case Atom(l) => l; case Negated(Atom(l)) => l } mkString (", ") private[this] def duplicateProvidesError(byAtom: Seq[(Atom, AutoPlugin)]): Unit = { - val dupsByAtom = Map(byAtom.groupBy(_._1).toSeq.map { - case (k, v) => - k -> v.map(_._2) + val dupsByAtom = Map(byAtom.groupBy(_._1).toSeq.map { case (k, v) => + k -> v.map(_._2) }: _*) val dupStrings = for ((atom, dups) <- dupsByAtom if dups.size > 1) @@ -294,18 +297,18 @@ object Plugins extends PluginsFunctions { (if (c.requires != empty && c.trigger == allRequirements) List(s"enabled by ${c.requires.toString}") else Nil) ++ { - val reqs = selected filter { x => - asRequirements(x) contains c + val reqs = selected filter { x => + asRequirements(x) contains c + } + if (reqs.nonEmpty) List(s"""required by ${reqs.mkString(", ")}""") + else Nil + } ++ { + val exs = selected filter { x => + asExclusions(x) contains c + } + if (exs.nonEmpty) List(s"""excluded by ${exs.mkString(", ")}""") + else Nil } - if (reqs.nonEmpty) List(s"""required by ${reqs.mkString(", ")}""") - else Nil - } ++ { - val exs = selected filter { x => - asExclusions(x) contains c - } - if (exs.nonEmpty) List(s"""excluded by ${exs.mkString(", ")}""") - else Nil - } s""" - conflict: ${c.label} is ${reasons.mkString("; ")}""" }).mkString("\n") throw AutoPluginException(s"""Contradiction in enabled plugins: @@ -357,12 +360,12 @@ ${listConflicts(conflicting)}""") Clause(convert(ap), Set(Atom(x.label))) } private[sbt] def asRequirements(ap: AutoPlugin): List[AutoPlugin] = - flatten(ap.requires).toList collect { - case x: AutoPlugin => x + flatten(ap.requires).toList collect { case x: AutoPlugin => + x } private[sbt] def asExclusions(ap: AutoPlugin): List[AutoPlugin] = - flatten(ap.requires).toList collect { - case Exclude(x) => x + flatten(ap.requires).toList collect { case Exclude(x) => + x } // TODO - This doesn't handle nested AND boolean logic... private[sbt] def hasExclude(n: Plugins, p: AutoPlugin): Boolean = n match { @@ -414,7 +417,8 @@ ${listConflicts(conflicting)}""") private val autoImport = "autoImport" - /** Determines whether a plugin has a stable autoImport member by: + /** + * Determines whether a plugin has a stable autoImport member by: * * 1. Checking whether there exists a public field. * 2. Checking whether there exists a public object. diff --git a/main/src/main/scala/sbt/Project.scala b/main/src/main/scala/sbt/Project.scala index 5fd822f01..4e8f73e84 100755 --- a/main/src/main/scala/sbt/Project.scala +++ b/main/src/main/scala/sbt/Project.scala @@ -67,7 +67,7 @@ sealed trait ProjectDefinition[PR <: ProjectReference] { */ def id: String - /** The base directory for the project.*/ + /** The base directory for the project. */ def base: File /** @@ -120,7 +120,8 @@ sealed trait ProjectDefinition[PR <: ProjectReference] { val dep = ifNonEmpty("dependencies", dependencies) val conf = ifNonEmpty("configurations", configurations) val autos = ifNonEmpty("autoPlugins", autoPlugins.map(_.label)) - val fields = s"id $id" :: s"base: $base" :: agg ::: dep ::: conf ::: (s"plugins: List($plugins)" :: autos) + val fields = + s"id $id" :: s"base: $base" :: agg ::: dep ::: conf ::: (s"plugins: List($plugins)" :: autos) s"Project(${fields.mkString(", ")})" } @@ -235,10 +236,10 @@ sealed trait Project extends ProjectDefinition[ProjectReference] with CompositeP def withId(id: String) = copy(id = id) - /** Sets the base directory for this project.*/ + /** Sets the base directory for this project. */ def in(dir: File): Project = copy(base = dir) - /** Adds configurations to this project. Added configurations replace existing configurations with the same name.*/ + /** Adds configurations to this project. Added configurations replace existing configurations with the same name. */ def overrideConfigs(cs: Configuration*): Project = copy(configurations = Defaults.overrideConfigs(cs: _*)(configurations)) @@ -288,7 +289,7 @@ sealed trait Project extends ProjectDefinition[ProjectReference] with CompositeP sealed trait ResolvedProject extends ProjectDefinition[ProjectRef] { - /** The [[AutoPlugin]]s enabled for this project as computed from [[plugins]].*/ + /** The [[AutoPlugin]]s enabled for this project as computed from [[plugins]]. */ def autoPlugins: Seq[AutoPlugin] } @@ -367,14 +368,14 @@ object Project extends ProjectExtra { with GeneratedRootProject } - /** Returns None if `id` is a valid Project ID or Some containing the parser error message if it is not.*/ + /** Returns None if `id` is a valid Project ID or Some containing the parser error message if it is not. */ def validProjectID(id: String): Option[String] = DefaultParsers.parse(id, DefaultParsers.ID).left.toOption private[this] def validProjectIDStart(id: String): Boolean = DefaultParsers.parse(id, DefaultParsers.IDStart).isRight - /** Constructs a valid Project ID based on `id` and returns it in Right or returns the error message in Left if one cannot be constructed.*/ + /** Constructs a valid Project ID based on `id` and returns it in Right or returns the error message in Left if one cannot be constructed. */ def normalizeProjectID(id: String): Either[String, String] = { val attempt = normalizeBase(id) val refined = @@ -498,7 +499,9 @@ object Project extends ProjectExtra { val newState = unloaded.copy(attributes = newAttrs) // TODO: Fix this onLoad( - preOnLoad(updateCurrent(newState)) /*LogManager.setGlobalLogLevels(updateCurrent(newState), structure.data)*/ + preOnLoad( + updateCurrent(newState) + ) /*LogManager.setGlobalLogLevels(updateCurrent(newState), structure.data)*/ ) } @@ -521,7 +524,9 @@ object Project extends ProjectExtra { def get[T](k: SettingKey[T]): Option[T] = (ref / k) get structure.data def commandsIn(axis: ResolvedReference) = (axis / commands) get structure.data toList - val allCommands = commandsIn(ref) ++ commandsIn(BuildRef(ref.build)) ++ ((Global / commands) get structure.data toList) + val allCommands = commandsIn(ref) ++ commandsIn( + BuildRef(ref.build) + ) ++ ((Global / commands) get structure.data toList) val history = get(historyPath) flatMap idFun val prompt = get(shellPrompt) val newPrompt = get(colorShellPrompt) @@ -571,12 +576,10 @@ object Project extends ProjectExtra { private[sbt] def checkTargets(data: Settings[Scope]): Option[String] = { val dups = overlappingTargets(allTargets(data)) - if (dups.isEmpty) - None + if (dups.isEmpty) None else { - val dupStrs = dups map { - case (dir, scopes) => - s"${dir.getAbsolutePath}:\n\t${scopes.mkString("\n\t")}" + val dupStrs = dups map { case (dir, scopes) => + s"${dir.getAbsolutePath}:\n\t${scopes.mkString("\n\t")}" } Some(s"Overlapping output directories:${dupStrs.mkString}") } @@ -702,12 +705,12 @@ object Project extends ProjectExtra { printScopes("Delegates", delegates(structure, scope, key)) + printScopes("Related", related, 10) } - def settingGraph(structure: BuildStructure, basedir: File, scoped: ScopedKey[_])( - implicit display: Show[ScopedKey[_]] + def settingGraph(structure: BuildStructure, basedir: File, scoped: ScopedKey[_])(implicit + display: Show[ScopedKey[_]] ): SettingGraph = SettingGraph(structure, basedir, scoped, 0) - def graphSettings(structure: BuildStructure, basedir: File)( - implicit display: Show[ScopedKey[_]] + def graphSettings(structure: BuildStructure, basedir: File)(implicit + display: Show[ScopedKey[_]] ): Unit = { def graph(actual: Boolean, name: String) = graphSettings(structure, actual, name, new File(basedir, name + ".dot")) @@ -721,13 +724,13 @@ object Project extends ProjectExtra { val keyToString = display.show _ DotGraph.generateGraph(file, graphName, rel, keyToString, keyToString) } - def relation(structure: BuildStructure, actual: Boolean)( - implicit display: Show[ScopedKey[_]] + def relation(structure: BuildStructure, actual: Boolean)(implicit + display: Show[ScopedKey[_]] ): Relation[ScopedKey[_], ScopedKey[_]] = relation(structure.settings, actual)(structure.delegates, structure.scopeLocal, display) - private[sbt] def relation(settings: Seq[Def.Setting[_]], actual: Boolean)( - implicit delegates: Scope => Seq[Scope], + private[sbt] def relation(settings: Seq[Def.Setting[_]], actual: Boolean)(implicit + delegates: Scope => Seq[Scope], scopeLocal: Def.ScopeLocal, display: Show[ScopedKey[_]] ): Relation[ScopedKey[_], ScopedKey[_]] = { @@ -736,8 +739,8 @@ object Project extends ProjectExtra { cMap.foldLeft(emptyRelation) { case (r, (key, value)) => r + (key, value.dependencies) } } - def showDefinitions(key: AttributeKey[_], defs: Seq[Scope])( - implicit display: Show[ScopedKey[_]] + def showDefinitions(key: AttributeKey[_], defs: Seq[Scope])(implicit + display: Show[ScopedKey[_]] ): String = showKeys(defs.map(scope => ScopedKey(scope, key))) @@ -747,17 +750,17 @@ object Project extends ProjectExtra { private[this] def showKeys(s: Seq[ScopedKey[_]])(implicit display: Show[ScopedKey[_]]): String = s.map(display.show).sorted.mkString("\n\t", "\n\t", "\n\n") - def definitions(structure: BuildStructure, actual: Boolean, key: AttributeKey[_])( - implicit display: Show[ScopedKey[_]] + def definitions(structure: BuildStructure, actual: Boolean, key: AttributeKey[_])(implicit + display: Show[ScopedKey[_]] ): Seq[Scope] = relation(structure, actual)(display)._1s.toSeq flatMap { sk => if (sk.key == key) sk.scope :: Nil else Nil } - def usedBy(structure: BuildStructure, actual: Boolean, key: AttributeKey[_])( - implicit display: Show[ScopedKey[_]] + def usedBy(structure: BuildStructure, actual: Boolean, key: AttributeKey[_])(implicit + display: Show[ScopedKey[_]] ): Seq[ScopedKey[_]] = - relation(structure, actual)(display).all.toSeq flatMap { - case (a, b) => if (b.key == key) List[ScopedKey[_]](a) else Nil + relation(structure, actual)(display).all.toSeq flatMap { case (a, b) => + if (b.key == key) List[ScopedKey[_]](a) else Nil } def reverseDependencies( cMap: Map[ScopedKey[_], Flattened], @@ -792,8 +795,7 @@ object Project extends ProjectExtra { if (acc.exists(map.contains)) { val (kept, rem) = map.partition { case (k, _) => acc(k) } helper(rem, acc ++ kept.valuesIterator.flatten) - } else - acc + } else acc helper(map - id, map.getOrElse(id, Nil).toSet) } val allProjectsDeps: Map[ProjectRef, Seq[ProjectRef]] = @@ -891,7 +893,8 @@ object Project extends ProjectExtra { } } - /** implicitly injected to tasks that return PromiseWrap. + /** + * implicitly injected to tasks that return PromiseWrap. */ final class RichTaskPromise[A](i: Def.Initialize[Task[PromiseWrap[A]]]) { import scala.concurrent.Await diff --git a/main/src/main/scala/sbt/Resolvers.scala b/main/src/main/scala/sbt/Resolvers.scala index d28d8a026..d7470aec9 100644 --- a/main/src/main/scala/sbt/Resolvers.scala +++ b/main/src/main/scala/sbt/Resolvers.scala @@ -32,7 +32,8 @@ object Resolvers { if (from.isDirectory) Some { () => if (from.canWrite) from else creates(to) { IO.copyDirectory(from, to) } - } else None + } + else None } val remote: Resolver = (info: ResolveInfo) => { diff --git a/main/src/main/scala/sbt/ScopeFilter.scala b/main/src/main/scala/sbt/ScopeFilter.scala index f279afb9a..c262f318f 100644 --- a/main/src/main/scala/sbt/ScopeFilter.scala +++ b/main/src/main/scala/sbt/ScopeFilter.scala @@ -89,7 +89,7 @@ object ScopeFilter { private[sbt] val Make = new Make {} trait Make { - /** Selects the Scopes used in `.all()`.*/ + /** Selects the Scopes used in `.all()`. */ type ScopeFilter = Base[Scope] /** Selects Scopes with a Zero task axis. */ @@ -154,17 +154,17 @@ object ScopeFilter { classpath = true ) - /** Selects Scopes that have a project axis with one of the provided values.*/ + /** Selects Scopes that have a project axis with one of the provided values. */ def inProjects(projects: ProjectReference*): ProjectFilter = ScopeFilter.inProjects(projects: _*) - /** Selects Scopes that have a task axis with one of the provided values.*/ + /** Selects Scopes that have a task axis with one of the provided values. */ def inTasks(tasks: Scoped*): TaskFilter = { val ts = tasks.map(_.key).toSet selectAxis[AttributeKey[_]](const(ts)) } - /** Selects Scopes that have a task axis with one of the provided values.*/ + /** Selects Scopes that have a task axis with one of the provided values. */ def inConfigurations(configs: Configuration*): ConfigurationFilter = { val cs = configs.map(_.name).toSet selectAxis[ConfigKey](const(c => cs(c.name))) @@ -194,7 +194,7 @@ object ScopeFilter { val allScopes: Set[Scope] ) - /** Constructs a Data instance from the list of static scopes and the project relationships.*/ + /** Constructs a Data instance from the list of static scopes and the project relationships. */ private[this] val getData: Initialize[Data] = Def.setting { val build = Keys.loadedBuild.value @@ -265,16 +265,16 @@ object ScopeFilter { } } - /** Base functionality for filters on values of type `In` that need access to build data.*/ + /** Base functionality for filters on values of type `In` that need access to build data. */ sealed abstract class Base[In] { self => /** Implements this filter. */ private[ScopeFilter] def apply(data: Data): In => Boolean - /** Constructs a filter that selects values that match this filter but not `other`.*/ + /** Constructs a filter that selects values that match this filter but not `other`. */ def --(other: Base[In]): Base[In] = this && -other - /** Constructs a filter that selects values that match this filter and `other`.*/ + /** Constructs a filter that selects values that match this filter and `other`. */ def &&(other: Base[In]): Base[In] = new Base[In] { private[sbt] def apply(data: Data): In => Boolean = { val a = self(data) @@ -283,7 +283,7 @@ object ScopeFilter { } } - /** Constructs a filter that selects values that match this filter or `other`.*/ + /** Constructs a filter that selects values that match this filter or `other`. */ def ||(other: Base[In]): Base[In] = new Base[In] { private[sbt] def apply(data: Data): In => Boolean = { val a = self(data) @@ -292,7 +292,7 @@ object ScopeFilter { } } - /** Constructs a filter that selects values that do not match this filter.*/ + /** Constructs a filter that selects values that do not match this filter. */ def unary_- : Base[In] = new Base[In] { private[sbt] def apply(data: Data): In => Boolean = { val a = self(data) diff --git a/main/src/main/scala/sbt/ScriptedPlugin.scala b/main/src/main/scala/sbt/ScriptedPlugin.scala index 35deb1104..7a564d166 100644 --- a/main/src/main/scala/sbt/ScriptedPlugin.scala +++ b/main/src/main/scala/sbt/ScriptedPlugin.scala @@ -122,8 +122,8 @@ object ScriptedPlugin extends AutoPlugin { private[sbt] def scriptedParser(scriptedBase: File): Parser[Seq[String]] = { import DefaultParsers._ - val scriptedFiles - : NameFilter = ("test": NameFilter) | "test.script" | "pending" | "pending.script" + val scriptedFiles: NameFilter = + ("test": NameFilter) | "test.script" | "pending" | "pending.script" val pairs = (scriptedBase * AllPassFilter * AllPassFilter * scriptedFiles).get map { (f: File) => val p = f.getParentFile @@ -164,13 +164,13 @@ object ScriptedPlugin extends AutoPlugin { page <- pageP files = pagedFilenames(group, page) // TODO - Fail the parser if we don't have enough files for the given page size - //if !files.isEmpty + // if !files.isEmpty } yield files map (f => s"$group/$f") val testID = (for (group <- groupP; name <- nameP(group)) yield (group, name)) val testIdAsGroup = matched(testID) map (test => Seq(test)) - //(token(Space) ~> matched(testID)).* + // (token(Space) ~> matched(testID)).* (token(Space) ~> (PagedIds | testIdAsGroup)).* map (_.flatten) } diff --git a/main/src/main/scala/sbt/SessionVar.scala b/main/src/main/scala/sbt/SessionVar.scala index a9a04607a..bb27532a3 100644 --- a/main/src/main/scala/sbt/SessionVar.scala +++ b/main/src/main/scala/sbt/SessionVar.scala @@ -27,8 +27,8 @@ object SessionVar { } def emptyMap = Map(IMap.empty) - def persistAndSet[T](key: ScopedKey[Task[T]], state: State, value: T)( - implicit f: JsonFormat[T] + def persistAndSet[T](key: ScopedKey[Task[T]], state: State, value: T)(implicit + f: JsonFormat[T] ): State = { persist(key, state, value)(f) set(key, state, value) @@ -72,8 +72,8 @@ object SessionVar { def load[T](key: ScopedKey[Task[T]], state: State)(implicit f: JsonFormat[T]): Option[T] = get(key, state) orElse read(key, state)(f) - def loadAndSet[T](key: ScopedKey[Task[T]], state: State, setIfUnset: Boolean = true)( - implicit f: JsonFormat[T] + def loadAndSet[T](key: ScopedKey[Task[T]], state: State, setIfUnset: Boolean = true)(implicit + f: JsonFormat[T] ): (State, Option[T]) = get(key, state) match { case s: Some[T] => (state, s) diff --git a/main/src/main/scala/sbt/Tags.scala b/main/src/main/scala/sbt/Tags.scala index ec37b8807..8f22d39ea 100644 --- a/main/src/main/scala/sbt/Tags.scala +++ b/main/src/main/scala/sbt/Tags.scala @@ -89,15 +89,15 @@ object Tags { /** Returns a Rule that limits the maximum number of concurrently executing tasks to `max`, regardless of tags. */ def limitAll(max: Int): Rule = limit(All, max) - /** Returns a Rule that limits the maximum number of concurrently executing tasks without a tag to `max`. */ + /** Returns a Rule that limits the maximum number of concurrently executing tasks without a tag to `max`. */ def limitUntagged(max: Int): Rule = limit(Untagged, max) - /** Returns a Rule that limits the maximum number of concurrent executing tasks tagged with `tag` to `max`.*/ + /** Returns a Rule that limits the maximum number of concurrent executing tasks tagged with `tag` to `max`. */ def limit(tag: Tag, max: Int): Rule = new Single(tag, max) def limitSum(max: Int, tags: Tag*): Rule = new Sum(tags, max) - /** Ensure that a task with the given tag always executes in isolation.*/ + /** Ensure that a task with the given tag always executes in isolation. */ def exclusive(exclusiveTag: Tag): Rule = customLimit { (tags: Map[Tag, Int]) => // if there are no exclusive tasks in this group, this rule adds no restrictions tags.getOrElse(exclusiveTag, 0) == 0 || @@ -105,7 +105,7 @@ object Tags { tags.getOrElse(Tags.All, 0) == 1 } - /** Ensure that a task with the given tag only executes with tasks also tagged with the given tag.*/ + /** Ensure that a task with the given tag only executes with tasks also tagged with the given tag. */ def exclusiveGroup(exclusiveTag: Tag): Rule = customLimit { (tags: Map[Tag, Int]) => val exclusiveCount = tags.getOrElse(exclusiveTag, 0) val allCount = tags.getOrElse(Tags.All, 0) @@ -117,7 +117,7 @@ object Tags { allCount == 1 } - /** A task tagged with one of `exclusiveTags` will not execute with another task with any of the other tags in `exclusiveTags`.*/ + /** A task tagged with one of `exclusiveTags` will not execute with another task with any of the other tags in `exclusiveTags`. */ def exclusiveGroups(exclusiveTags: Tag*): Rule = customLimit { (tags: Map[Tag, Int]) => val groups = exclusiveTags.count(tag => tags.getOrElse(tag, 0) > 0) groups <= 1 diff --git a/main/src/main/scala/sbt/Terminal.scala b/main/src/main/scala/sbt/Terminal.scala index 8d84cd167..6b0f8698b 100644 --- a/main/src/main/scala/sbt/Terminal.scala +++ b/main/src/main/scala/sbt/Terminal.scala @@ -15,7 +15,6 @@ import sbt.internal.util.{ JLine3, Terminal => ITerminal } * for an sbt server or it may control a remote client connected through sbtn. The * Terminal is particularly useful whenever an sbt task needs to receive input from * the user. - * */ trait Terminal { diff --git a/main/src/main/scala/sbt/coursierint/CoursierInputsTasks.scala b/main/src/main/scala/sbt/coursierint/CoursierInputsTasks.scala index 9059f36ef..a9f20b566 100644 --- a/main/src/main/scala/sbt/coursierint/CoursierInputsTasks.scala +++ b/main/src/main/scala/sbt/coursierint/CoursierInputsTasks.scala @@ -95,8 +95,8 @@ object CoursierInputsTasks { CModule( COrganization(id.getOrganisation), CModuleName(id.getName), - id.getExtraAttributes.asScala.map { - case (k0, v0) => k0.asInstanceOf[String] -> v0.asInstanceOf[String] + id.getExtraAttributes.asScala.map { case (k0, v0) => + k0.asInstanceOf[String] -> v0.asInstanceOf[String] }.toMap ) @@ -141,9 +141,8 @@ object CoursierInputsTasks { c => m.getOrElse(c, CPublication("", CType(""), CExtension(""), CClassifier(""))) } - configurations.map { - case (from, to) => - from -> dependency(to, publications(to)) + configurations.map { case (from, to) => + from -> dependency(to, publications(to)) } } @@ -164,31 +163,28 @@ object CoursierInputsTasks { // this includes org.scala-sbt:global-plugins referenced from meta-builds in particular sbt.Keys.projectDescriptors.value - .map { - case (k, v) => - moduleFromIvy(k) -> v + .map { case (k, v) => + moduleFromIvy(k) -> v } - .filter { - case (module, _) => - !projectModules(module) + .filter { case (module, _) => + !projectModules(module) } .toVector - .map { - case (module, v) => - val configurations = v.getConfigurations.map { c => - CConfiguration(c.getName) -> c.getExtends.map(CConfiguration(_)).toSeq - }.toMap - val deps = v.getDependencies.flatMap(dependencyFromIvy) - CProject( - module, - v.getModuleRevisionId.getRevision, - deps, - configurations, - Nil, - None, - Nil, - CInfo("", "", Nil, Nil, None) - ) + .map { case (module, v) => + val configurations = v.getConfigurations.map { c => + CConfiguration(c.getName) -> c.getExtends.map(CConfiguration(_)).toSeq + }.toMap + val deps = v.getDependencies.flatMap(dependencyFromIvy) + CProject( + module, + v.getModuleRevisionId.getRevision, + deps, + configurations, + Nil, + None, + Nil, + CInfo("", "", Nil, Nil, None) + ) } } } diff --git a/main/src/main/scala/sbt/coursierint/CoursierRepositoriesTasks.scala b/main/src/main/scala/sbt/coursierint/CoursierRepositoriesTasks.scala index e05916408..0d263f270 100644 --- a/main/src/main/scala/sbt/coursierint/CoursierRepositoriesTasks.scala +++ b/main/src/main/scala/sbt/coursierint/CoursierRepositoriesTasks.scala @@ -48,8 +48,7 @@ object CoursierRepositoriesTasks { if (resolvers.exists(fastRepo) && resolvers.exists(slowRepo)) { val (slow, other) = resolvers.partition(slowRepo) other ++ slow - } else - resolvers + } else resolvers } // local-preloaded-ivy contains dangling ivy.xml without JAR files @@ -92,7 +91,8 @@ object CoursierRepositoriesTasks { } } - private val pluginIvySnapshotsBase = Resolver.SbtRepositoryRoot.stripSuffix("/") + "/ivy-snapshots" + private val pluginIvySnapshotsBase = + Resolver.SbtRepositoryRoot.stripSuffix("/") + "/ivy-snapshots" def coursierSbtResolversTask: Def.Initialize[sbt.Task[Seq[Resolver]]] = Def.task { val resolvers = diff --git a/main/src/main/scala/sbt/coursierint/LMCoursier.scala b/main/src/main/scala/sbt/coursierint/LMCoursier.scala index ebdf02d78..dbd6513d4 100644 --- a/main/src/main/scala/sbt/coursierint/LMCoursier.scala +++ b/main/src/main/scala/sbt/coursierint/LMCoursier.scala @@ -153,9 +153,8 @@ object LMCoursier { log ) .toVector - .map { - case (o, n) => - (o.value, n.value) + .map { case (o, n) => + (o.value, n.value) } .sorted val autoScala = autoScalaLib && scalaModInfo.forall( diff --git a/main/src/main/scala/sbt/internal/AddSettings.scala b/main/src/main/scala/sbt/internal/AddSettings.scala index 14acc5c05..361162cdf 100644 --- a/main/src/main/scala/sbt/internal/AddSettings.scala +++ b/main/src/main/scala/sbt/internal/AddSettings.scala @@ -30,8 +30,8 @@ object AddSettings { private[sbt] final object BuildScalaFiles extends AddSettings /** Adds all settings from autoplugins. */ - val autoPlugins - : AddSettings = new AutoPlugins(const(true)) // Note: We do not expose fine-grained autoplugins because + val autoPlugins: AddSettings = + new AutoPlugins(const(true)) // Note: We do not expose fine-grained autoplugins because // it's dangerous to control at that level right now. // Leaving the hook in place in case we need to expose // it, but most likely it will remain locked out @@ -53,7 +53,7 @@ object AddSettings { /** Includes the settings from the .sbt files given by `files`. */ def sbtFiles(files: File*): AddSettings = new SbtFiles(files) - /** Includes settings automatically*/ + /** Includes settings automatically */ def seq(autos: AddSettings*): AddSettings = new Sequence(autos) /** The default inclusion of settings. */ diff --git a/main/src/main/scala/sbt/internal/Aggregation.scala b/main/src/main/scala/sbt/internal/Aggregation.scala index b17413652..190bf60e4 100644 --- a/main/src/main/scala/sbt/internal/Aggregation.scala +++ b/main/src/main/scala/sbt/internal/Aggregation.scala @@ -46,8 +46,8 @@ object Aggregation { success = true ) - def printSettings(xs: Seq[KeyValue[_]], print: String => Unit)( - implicit display: Show[ScopedKey[_]] + def printSettings(xs: Seq[KeyValue[_]], print: String => Unit)(implicit + display: Show[ScopedKey[_]] ): Unit = xs match { case KeyValue(_, x: Seq[_]) :: Nil => print(x.mkString("* ", "\n* ", "")) @@ -69,8 +69,8 @@ object Aggregation { )(implicit display: Show[ScopedKey[_]]): Parser[() => State] = Command.applyEffect(seqParser(ps))(ts => runTasks(s, ts, DummyTaskMap(Nil), show)) - private def showRun[T](complete: Complete[T], show: ShowConfig)( - implicit display: Show[ScopedKey[_]] + private def showRun[T](complete: Complete[T], show: ShowConfig)(implicit + display: Show[ScopedKey[_]] ): Unit = { import complete._ val log = state.log @@ -163,8 +163,7 @@ object Aggregation { val mins = f"${total % 3600 / 60}%02d" val secs = f"${total % 60}%02d" s" ($maybeHours$mins:$secs)" - }) - s"Total time: $totalString, completed $nowString" + }) s"Total time: $totalString, completed $nowString" } def defaultFormat: DateFormat = { @@ -185,8 +184,8 @@ object Aggregation { } } - def evaluatingParser(s: State, show: ShowConfig)(keys: Seq[KeyValue[_]])( - implicit display: Show[ScopedKey[_]] + def evaluatingParser(s: State, show: ShowConfig)(keys: Seq[KeyValue[_]])(implicit + display: Show[ScopedKey[_]] ): Parser[() => State] = { // to make the call sites clearer @@ -196,8 +195,7 @@ object Aggregation { Util.separate(in)(f) val kvs = keys.toList - if (kvs.isEmpty) - failure("No such setting/task") + if (kvs.isEmpty) failure("No such setting/task") else { val (inputTasks, other) = separate[InputTask[_]](kvs) { case KeyValue(k, v: InputTask[_]) => Left(KeyValue(k, v)) @@ -219,8 +217,7 @@ object Aggregation { val inputStrings = inputTasks.map(_.key).mkString("Input task(s):\n\t", "\n\t", "\n") val otherStrings = other.map(_.key).mkString("Task(s)/setting(s):\n\t", "\n\t", "\n") failure(s"Cannot mix input tasks with plain tasks/settings. $inputStrings $otherStrings") - } else - applyDynamicTasks(s, maps(inputTasks)(castToAny), show) + } else applyDynamicTasks(s, maps(inputTasks)(castToAny), show) } else { val base = if (tasks.isEmpty) success(() => s) @@ -246,8 +243,8 @@ object Aggregation { reverse: Boolean ): Seq[ProjectRef] = { val resRef = proj.map(p => extra.projectRefFor(extra.resolveRef(p))) - resRef.toList.flatMap( - ref => if (reverse) extra.aggregates.reverse(ref) else extra.aggregates.forward(ref) + resRef.toList.flatMap(ref => + if (reverse) extra.aggregates.reverse(ref) else extra.aggregates.forward(ref) ) } diff --git a/main/src/main/scala/sbt/internal/ClasspathImpl.scala b/main/src/main/scala/sbt/internal/ClasspathImpl.scala index 43f35dbd8..c49e34a73 100644 --- a/main/src/main/scala/sbt/internal/ClasspathImpl.scala +++ b/main/src/main/scala/sbt/internal/ClasspathImpl.scala @@ -293,9 +293,8 @@ private[sbt] object ClasspathImpl { trackIfMissing: TaskKey[Seq[A]], trackAlways: TaskKey[Seq[A]] ): Task[Seq[A]] = { - val interDepConfigs = interSort(projectRef, conf, data, deps) filter { - case (dep, c) => - includeSelf || (dep != projectRef) || (conf.name != c && self.name != c) + val interDepConfigs = interSort(projectRef, conf, data, deps) filter { case (dep, c) => + includeSelf || (dep != projectRef) || (conf.name != c && self.name != c) } val tasks = (new LinkedHashSet[Task[Seq[A]]]).asScala for { diff --git a/main/src/main/scala/sbt/internal/Clean.scala b/main/src/main/scala/sbt/internal/Clean.scala index c55a0f90a..a9ad3bd75 100644 --- a/main/src/main/scala/sbt/internal/Clean.scala +++ b/main/src/main/scala/sbt/internal/Clean.scala @@ -108,7 +108,9 @@ private[sbt] object Clean { } val streamsGlobs = (streamsKey.toSeq ++ stampsKey).map(k => manager(k).cacheDirectory.toGlob / **) - ((scope / fileOutputs).value.filter(g => targetDir.fold(true)(g.base.startsWith)) ++ streamsGlobs) + ((scope / fileOutputs).value.filter(g => + targetDir.fold(true)(g.base.startsWith) + ) ++ streamsGlobs) .foreach { g => val filter: Path => Boolean = { path => !g.matches(path) || excludeFilter(path) diff --git a/main/src/main/scala/sbt/internal/ConsoleProject.scala b/main/src/main/scala/sbt/internal/ConsoleProject.scala index b2776b754..4e9015b1b 100644 --- a/main/src/main/scala/sbt/internal/ConsoleProject.scala +++ b/main/src/main/scala/sbt/internal/ConsoleProject.scala @@ -21,7 +21,8 @@ object ConsoleProject { ): Unit = { val extracted = Project extract state val cpImports = new Imports(extracted, state) - val bindings = ("currentState" -> state) :: ("extracted" -> extracted) :: ("cpHelpers" -> cpImports) :: Nil + val bindings = + ("currentState" -> state) :: ("extracted" -> extracted) :: ("cpHelpers" -> cpImports) :: Nil val unit = extracted.currentUnit val (state1, dependencyResolution) = extracted.runTask(Keys.dependencyResolution, state) @@ -51,7 +52,8 @@ object ConsoleProject { componentProvider = app.provider.components, secondaryCacheDir = Option(zincDir), dependencyResolution = dependencyResolution, - compilerBridgeSource = extracted.get(Keys.consoleProject / Keys.scalaCompilerBridgeSource), + compilerBridgeSource = + extracted.get(Keys.consoleProject / Keys.scalaCompilerBridgeSource), scalaJarsTarget = zincDir, classLoaderCache = state1.get(BasicKeys.classLoaderCache), log = log diff --git a/main/src/main/scala/sbt/internal/CrossJava.scala b/main/src/main/scala/sbt/internal/CrossJava.scala index a16aca956..6e352d0d9 100644 --- a/main/src/main/scala/sbt/internal/CrossJava.scala +++ b/main/src/main/scala/sbt/internal/CrossJava.scala @@ -34,8 +34,8 @@ private[sbt] object CrossJava { def splitDot(s: String): Vector[Long] = Option(s) match { case Some(x) => - x.split('.').toVector collect { - case Num(n) => n.toLong + x.split('.').toVector collect { case Num(n) => + n.toLong } case _ => Vector() } @@ -113,8 +113,8 @@ private[sbt] object CrossJava { // when looking for "10" it should match "openjdk@10" case None if jv.vendor.isEmpty => - val noVendors: Map[JavaVersion, File] = mappings map { - case (k, v) => k.withVendor(None) -> v + val noVendors: Map[JavaVersion, File] = mappings map { case (k, v) => + k.withVendor(None) -> v } noVendors.get(jv).getOrElse(javaHomeNotFound(jv, mappings)) case _ => javaHomeNotFound(jv, mappings) @@ -155,9 +155,8 @@ private[sbt] object CrossJava { else version & spacedFirst(JavaSwitchCommand) val verbose = Parser.opt(token(Space ~> "-v")) val optionalCommand = Parser.opt(token(Space ~> matched(state.combinedParser))) - (spacedVersion ~ verbose ~ optionalCommand).map { - case v ~ verbose ~ command => - SwitchJavaHome(v, verbose.isDefined, command) + (spacedVersion ~ verbose ~ optionalCommand).map { case v ~ verbose ~ command => + SwitchJavaHome(v, verbose.isDefined, command) } } token(JavaSwitchCommand ~> OptSpace) flatMap { sp => @@ -216,28 +215,26 @@ private[sbt] object CrossJava { switch.target.version match { case None => projectJavaVersions case Some(v) => - projectJavaVersions flatMap { - case (proj, versions) => - if (versions.isEmpty || versions.contains[String](v.toString)) - Vector(proj -> versions) - else Vector() + projectJavaVersions flatMap { case (proj, versions) => + if (versions.isEmpty || versions.contains[String](v.toString)) + Vector(proj -> versions) + else Vector() } } } def setJavaHomeForProjects: State = { - val newSettings = projects.flatMap { - case (proj, javaVersions) => - val fjh = getJavaHomesTyped(extracted, proj) - val home = switch.target match { - case SwitchTarget(Some(v), _, _) => lookupJavaHome(v, fjh) - case SwitchTarget(_, Some(h), _) => h - case _ => sys.error(s"unexpected ${switch.target}") - } - val scope = Scope(Select(proj), Zero, Zero, Zero) - Seq( - (scope / javaHome) := Some(home) - ) + val newSettings = projects.flatMap { case (proj, javaVersions) => + val fjh = getJavaHomesTyped(extracted, proj) + val home = switch.target match { + case SwitchTarget(Some(v), _, _) => lookupJavaHome(v, fjh) + case SwitchTarget(_, Some(h), _) => h + case _ => sys.error(s"unexpected ${switch.target}") + } + val scope = Scope(Select(proj), Zero, Zero, Zero) + Seq( + (scope / javaHome) := Some(home) + ) } val filterKeys: Set[AttributeKey[_]] = Set(javaHome).map(_.key) @@ -287,8 +284,8 @@ private[sbt] object CrossJava { } // if we support javaHome, projVersions should be cached somewhere since // running ++2.11.1 is at the root level is going to mess with the scalaVersion for the aggregated subproj - val projVersions = (projCrossVersions flatMap { - case (proj, versions) => versions map { proj.project -> _ } + val projVersions = (projCrossVersions flatMap { case (proj, versions) => + versions map { proj.project -> _ } }).toList val verbose = "" @@ -314,8 +311,8 @@ private[sbt] object CrossJava { "that are configured." ) state.log.debug("Java versions configuration is:") - projCrossVersions.foreach { - case (project, versions) => state.log.debug(s"$project: $versions") + projCrossVersions.foreach { case (project, versions) => + state.log.debug(s"$project: $versions") } } @@ -403,9 +400,8 @@ private[sbt] object CrossJava { def javaHomes: Vector[(String, File)] = candidates() - .collect { - case dir @ JavaHomeDir(version) => - version -> (base / dir) + .collect { case dir @ JavaHomeDir(version) => + version -> (base / dir) } } @@ -414,9 +410,8 @@ private[sbt] object CrossJava { def javaHomes: Vector[(String, File)] = wrapNull(base.list()) - .collect { - case dir @ JavaHomeDir(version) => - version -> (base / dir / "Contents" / "Home") + .collect { case dir @ JavaHomeDir(version) => + version -> (base / dir / "Contents" / "Home") } } @@ -426,11 +421,10 @@ private[sbt] object CrossJava { def javaHomes: Vector[(String, File)] = wrapNull(base.list()) - .collect { - case dir @ JabbaJavaHomeDir(vendor, m, n) => - val v = JavaVersion(nullBlank(m) + n).withVendor(vendor).toString - if ((base / dir / "Contents" / "Home").exists) v -> (base / dir / "Contents" / "Home") - else v -> (base / dir) + .collect { case dir @ JabbaJavaHomeDir(vendor, m, n) => + val v = JavaVersion(nullBlank(m) + n).withVendor(vendor).toString + if ((base / dir / "Contents" / "Home").exists) v -> (base / dir / "Contents" / "Home") + else v -> (base / dir) } } @@ -454,8 +448,8 @@ private[sbt] object CrossJava { def javaHomes: Vector[(String, File)] = candidates() - .collect { - case dir @ JavaHomeDir(version) => version -> base / dir + .collect { case dir @ JavaHomeDir(version) => + version -> base / dir } .flatMap { case x if vendors.isEmpty => Vector(x) @@ -513,30 +507,28 @@ private[sbt] object CrossJava { else s def expandJavaHomes(hs: Map[String, File]): Map[String, File] = { - val parsed = hs map { - case (k, v) => JavaVersion(k) -> v + val parsed = hs map { case (k, v) => + JavaVersion(k) -> v } // first ignore vnd - val withAndWithoutVnd = parsed flatMap { - case (k, v) => - if (k.vendor.isDefined) Vector(k -> v, k.withVendor(None) -> v) - else Vector(k -> v) + val withAndWithoutVnd = parsed flatMap { case (k, v) => + if (k.vendor.isDefined) Vector(k -> v, k.withVendor(None) -> v) + else Vector(k -> v) } - val normalizeNumbers = withAndWithoutVnd flatMap { - case (k, v) => - k.numbers match { - case Vector(1L, minor, _*) => - Vector(k -> v, k.withNumbers(Vector(minor)) -> v) - case Vector(major) if major > 1 => - Vector(k -> v, k.withNumbers(Vector(1L, major)) -> v) - case Vector(major, minor, _*) if major > 1 => - Vector(k -> v, k.withNumbers(Vector(major)) -> v, k.withNumbers(Vector(1L, major)) -> v) - case _ => - Vector(k -> v) - } + val normalizeNumbers = withAndWithoutVnd flatMap { case (k, v) => + k.numbers match { + case Vector(1L, minor, _*) => + Vector(k -> v, k.withNumbers(Vector(minor)) -> v) + case Vector(major) if major > 1 => + Vector(k -> v, k.withNumbers(Vector(1L, major)) -> v) + case Vector(major, minor, _*) if major > 1 => + Vector(k -> v, k.withNumbers(Vector(major)) -> v, k.withNumbers(Vector(1L, major)) -> v) + case _ => + Vector(k -> v) + } } - val result: Map[String, File] = normalizeNumbers map { - case (k, v) => (k.toString -> v) + val result: Map[String, File] = normalizeNumbers map { case (k, v) => + (k.toString -> v) } result } diff --git a/main/src/main/scala/sbt/internal/DefaultBackgroundJobService.scala b/main/src/main/scala/sbt/internal/DefaultBackgroundJobService.scala index 3a69b416b..1cb9416cb 100644 --- a/main/src/main/scala/sbt/internal/DefaultBackgroundJobService.scala +++ b/main/src/main/scala/sbt/internal/DefaultBackgroundJobService.scala @@ -152,14 +152,15 @@ private[sbt] abstract class AbstractBackgroundJobService extends BackgroundJobSe LogManager.constructBackgroundLog(extracted.structure.data, state, context)(spawningTask) val workingDir = serviceTempDir / s"job-$id" IO.createDirectory(workingDir) - val job = try { - new ThreadJobHandle(id, spawningTask, logger, workingDir, start(logger, workingDir)) - } catch { - case e: Throwable => - // TODO: Fix this - // logger.close() - throw e - } + val job = + try { + new ThreadJobHandle(id, spawningTask, logger, workingDir, start(logger, workingDir)) + } catch { + case e: Throwable => + // TODO: Fix this + // logger.close() + throw e + } job } @@ -211,7 +212,6 @@ private[sbt] abstract class AbstractBackgroundJobService extends BackgroundJobSe override def toString(): String = s"BackgroundJobService(jobs=${jobs.map(_.id).mkString})" /** - * * Copies products to the working directory, and the rest to the serviceTempDir of this service, * both wrapped in a stamp of the file contents. * This is intended to minimize the file copying and accumulation of the unused JAR file. @@ -463,9 +463,12 @@ private[sbt] class BackgroundThreadPool extends java.io.Closeable { work: (Logger, File) => Unit ): JobHandle = { def start(logger: Logger, workingDir: File): BackgroundJob = { - val runnable = new BackgroundRunnable(spawningTask.key.label, { () => - work(logger, workingDir) - }) + val runnable = new BackgroundRunnable( + spawningTask.key.label, + { () => + work(logger, workingDir) + } + ) executor.execute(runnable) runnable } diff --git a/main/src/main/scala/sbt/internal/DeprecatedContinuous.scala b/main/src/main/scala/sbt/internal/DeprecatedContinuous.scala index 7d344aab9..6ca0ba138 100644 --- a/main/src/main/scala/sbt/internal/DeprecatedContinuous.scala +++ b/main/src/main/scala/sbt/internal/DeprecatedContinuous.scala @@ -47,10 +47,13 @@ private[internal] trait DeprecatedContinuous { } ) .put(legacyWatchState, legacyState) - .put(Watched.Configuration, new Watched { - override def watchSources(s: State): Seq[Source] = - s.get(legacyWatchState).map(_.get.sources).getOrElse(Nil) - }) + .put( + Watched.Configuration, + new Watched { + override def watchSources(s: State): Seq[Source] = + s.get(legacyWatchState).map(_.get.sources).getOrElse(Nil) + } + ) } def updateLegacyWatchState(state: State, globs: Seq[Glob], count: Int): Unit = { state.get(legacyWatchState).foreach { ref => diff --git a/main/src/main/scala/sbt/internal/EvaluateConfigurations.scala b/main/src/main/scala/sbt/internal/EvaluateConfigurations.scala index 9986629e5..acc6d0ab5 100644 --- a/main/src/main/scala/sbt/internal/EvaluateConfigurations.scala +++ b/main/src/main/scala/sbt/internal/EvaluateConfigurations.scala @@ -154,17 +154,16 @@ private[sbt] object EvaluateConfigurations { (imp, DefinedSbtValues(definitions)) } val allImports = importDefs.map(s => (s, -1)) ++ parsed.imports - val dslEntries = parsed.settings map { - case (dslExpression, range) => - evaluateDslEntry(eval, name, allImports, dslExpression, range) + val dslEntries = parsed.settings map { case (dslExpression, range) => + evaluateDslEntry(eval, name, allImports, dslExpression, range) } eval.unlinkDeferred() // Tracks all the files we generated from evaluating the sbt file. val allGeneratedFiles = (definitions.generated ++ dslEntries.flatMap(_.generated)) loader => { val projects = { - val compositeProjects = definitions.values(loader).collect { - case p: CompositeProject => p + val compositeProjects = definitions.values(loader).collect { case p: CompositeProject => + p } CompositeProject.expand(compositeProjects).map(resolveBase(file.getParentFile, _)) } @@ -177,8 +176,8 @@ private[sbt] object EvaluateConfigurations { case DslEntry.ProjectSettings(settings) => settings case _ => Nil } - val manipulations = manipulationsRaw map { - case DslEntry.ProjectManipulation(f) => f + val manipulations = manipulationsRaw map { case DslEntry.ProjectManipulation(f) => + f } // TODO -get project manipulations. new LoadedSbtFile( @@ -205,7 +204,8 @@ private[sbt] object EvaluateConfigurations { * The name of the class we cast DSL "setting" (vs. definition) lines to. */ val SettingsDefinitionName = { - val _ = classOf[DslEntry] // this line exists to try to provide a compile-time error when the following line needs to be changed + val _ = + classOf[DslEntry] // this line exists to try to provide a compile-time error when the following line needs to be changed "sbt.internal.DslEntry" } @@ -230,17 +230,18 @@ private[sbt] object EvaluateConfigurations { ): TrackedEvalResult[DslEntry] = { // TODO - Should we try to namespace these between.sbt files? IF they hash to the same value, they may actually be // exactly the same setting, so perhaps we don't care? - val result = try { - eval.eval( - expression, - imports = new EvalImports(imports, name), - srcName = name, - tpeName = Some(SettingsDefinitionName), - line = range.start - ) - } catch { - case e: sbt.compiler.EvalException => throw new MessageOnlyException(e.getMessage) - } + val result = + try { + eval.eval( + expression, + imports = new EvalImports(imports, name), + srcName = name, + tpeName = Some(SettingsDefinitionName), + line = range.start + ) + } catch { + case e: sbt.compiler.EvalException => throw new MessageOnlyException(e.getMessage) + } // TODO - keep track of configuration classes defined. TrackedEvalResult( result.generated, @@ -331,13 +332,11 @@ private[sbt] object EvaluateConfigurations { object Index { def taskToKeyMap(data: Settings[Scope]): Map[Task[_], ScopedKey[Task[_]]] = { - val pairs = data.scopes flatMap ( - scope => - data.data(scope).entries collect { - case AttributeEntry(key, value: Task[_]) => - (value, ScopedKey(scope, key.asInstanceOf[AttributeKey[Task[_]]])) - } - ) + val pairs = data.scopes flatMap (scope => + data.data(scope).entries collect { case AttributeEntry(key, value: Task[_]) => + (value, ScopedKey(scope, key.asInstanceOf[AttributeKey[Task[_]]])) + } + ) pairs.toMap[Task[_], ScopedKey[Task[_]]] } @@ -372,7 +371,9 @@ object Index { multiMap.collect { case (k, v) if validID(k) => (k, v.head) } toMap else sys.error( - duplicates map { case (k, tps) => "'" + k + "' (" + tps.mkString(", ") + ")" } mkString ("Some keys were defined with the same name but different types: ", ", ", "") + duplicates map { case (k, tps) => + "'" + k + "' (" + tps.mkString(", ") + ")" + } mkString ("Some keys were defined with the same name but different types: ", ", ", "") ) } diff --git a/main/src/main/scala/sbt/internal/FileChangesMacro.scala b/main/src/main/scala/sbt/internal/FileChangesMacro.scala index 0b60b53cc..181b40add 100644 --- a/main/src/main/scala/sbt/internal/FileChangesMacro.scala +++ b/main/src/main/scala/sbt/internal/FileChangesMacro.scala @@ -21,7 +21,6 @@ import scala.reflect.macros.blackbox * Provides extension methods to `TaskKey[T]` that can be use to fetch the input and output file * dependency changes for a task. Nothing in this object is intended to be called directly but, * because there are macro definitions, some of the definitions must be public. - * */ object FileChangesMacro { private[sbt] sealed abstract class TaskOps[T](val taskKey: TaskKey[T]) { diff --git a/main/src/main/scala/sbt/internal/Inspect.scala b/main/src/main/scala/sbt/internal/Inspect.scala index ecc84b5b3..199c04910 100644 --- a/main/src/main/scala/sbt/internal/Inspect.scala +++ b/main/src/main/scala/sbt/internal/Inspect.scala @@ -58,28 +58,27 @@ object Inspect { } def commandHandler(s: State, mode: Mode): Parser[() => String] = { - Space ~> commandParser(s).flatMap { - case (name, cmd) => - cmd.tags.get(BasicCommands.CommandAliasKey) match { - case Some((_, aliasFor)) => - def header = s"Alias for: $aliasFor" - Parser - .parse(" " ++ aliasFor, keyHandler(s)(mode)) - .fold( - // If we can't find a task key for the alias target - // we don't display anymore information - _ => success(() => header), - success - ) - case None => - success(() => s"Command: $name") - } + Space ~> commandParser(s).flatMap { case (name, cmd) => + cmd.tags.get(BasicCommands.CommandAliasKey) match { + case Some((_, aliasFor)) => + def header = s"Alias for: $aliasFor" + Parser + .parse(" " ++ aliasFor, keyHandler(s)(mode)) + .fold( + // If we can't find a task key for the alias target + // we don't display anymore information + _ => success(() => header), + success + ) + case None => + success(() => s"Command: $name") + } } } def commandParser: State => Parser[(String, Command)] = { s => - oneOf(s.definedCommands.map(cmd => cmd -> cmd.nameOption) collect { - case (cmd, Some(name)) => DefaultParsers.literal(name).map(_ -> cmd) + oneOf(s.definedCommands.map(cmd => cmd -> cmd.nameOption) collect { case (cmd, Some(name)) => + DefaultParsers.literal(name).map(_ -> cmd) }) } diff --git a/main/src/main/scala/sbt/internal/KeyIndex.scala b/main/src/main/scala/sbt/internal/KeyIndex.scala index dd803de33..44cef2108 100644 --- a/main/src/main/scala/sbt/internal/KeyIndex.scala +++ b/main/src/main/scala/sbt/internal/KeyIndex.scala @@ -282,8 +282,7 @@ private[sbt] final class KeyIndex0(val data: BuildIndex) extends ExtendableKeyIn if (validID(scoped.key.label)) { val aggregateProjects = Aggregation.aggregate(scoped, ScopeMask(), extra, reverse = true) aggregateProjects.foldLeft(this: ExtendableKeyIndex)(_ add _) - } else - this + } else this def add(scoped: ScopedKey[_]): ExtendableKeyIndex = if (validID(scoped.key.label)) add0(scoped) else this diff --git a/main/src/main/scala/sbt/internal/LibraryManagement.scala b/main/src/main/scala/sbt/internal/LibraryManagement.scala index e6aafbbba..2a9b431d5 100644 --- a/main/src/main/scala/sbt/internal/LibraryManagement.scala +++ b/main/src/main/scala/sbt/internal/LibraryManagement.scala @@ -80,11 +80,15 @@ private[sbt] object LibraryManagement { "this can be overridden using libraryDependencySchemes or evictionErrorLevel" ) val errorLines: Seq[String] = - (if (evictionError.incompatibleEvictions.isEmpty - || evictionLevel != Level.Error) Nil + (if ( + evictionError.incompatibleEvictions.isEmpty + || evictionLevel != Level.Error + ) Nil else evictionError.lines) ++ - (if (evictionError.assumedIncompatibleEvictions.isEmpty - || assumedEvictionErrorLevel != Level.Error) Nil + (if ( + evictionError.assumedIncompatibleEvictions.isEmpty + || assumedEvictionErrorLevel != Level.Error + ) Nil else evictionError.toAssumedLines) if (errorLines.nonEmpty) sys.error((errorLines ++ extraLines).mkString(EOL)) else { @@ -269,8 +273,8 @@ private[sbt] object LibraryManagement { val maybeUpdateLevel = (update / logLevel).?.value val conf1 = maybeUpdateLevel.orElse(state0.get(logLevel.key)) match { case Some(Level.Debug) if conf.logging == Default => conf.withLogging(logging = Full) - case Some(_) if conf.logging == Default => conf.withLogging(logging = DownloadOnly) - case _ => conf + case Some(_) if conf.logging == Default => conf.withLogging(logging = DownloadOnly) + case _ => conf } // logical clock is folded into UpdateConfiguration conf1.withLogicalClock(LogicalClock(state0.hashCode)) diff --git a/main/src/main/scala/sbt/internal/Load.scala b/main/src/main/scala/sbt/internal/Load.scala index 834257634..a6849a8cc 100755 --- a/main/src/main/scala/sbt/internal/Load.scala +++ b/main/src/main/scala/sbt/internal/Load.scala @@ -182,8 +182,7 @@ private[sbt] object Load { if (base != global && global.exists) { val gp = GlobalPlugin.load(global, state, config) config.copy(globalPlugin = Some(gp)) - } else - config + } else config def defaultDelegates: LoadedBuild => Scope => Seq[Scope] = (lb: LoadedBuild) => { val rootProject = getRootProject(lb.units) @@ -286,11 +285,10 @@ private[sbt] object Load { // 3. resolvedScoped is replaced with the defining key as a value // Note: this must be idempotent. def finalTransforms(ss: Seq[Setting[_]]): Seq[Setting[_]] = { - def mapSpecial(to: ScopedKey[_]) = λ[ScopedKey ~> ScopedKey]( - (key: ScopedKey[_]) => - if (key.key == streams.key) { - ScopedKey(Scope.fillTaskAxis(Scope.replaceThis(to.scope)(key.scope), to.key), key.key) - } else key + def mapSpecial(to: ScopedKey[_]) = λ[ScopedKey ~> ScopedKey]((key: ScopedKey[_]) => + if (key.key == streams.key) { + ScopedKey(Scope.fillTaskAxis(Scope.replaceThis(to.scope)(key.scope), to.key), key.key) + } else key ) def setDefining[T] = (key: ScopedKey[T], value: T) => @@ -299,15 +297,14 @@ private[sbt] object Load { case ik: InputTask[t] => ik.mapTask(tk => setDefinitionKey(tk, key)).asInstanceOf[T] case _ => value } - def setResolved(defining: ScopedKey[_]) = λ[ScopedKey ~> Option]( - (key: ScopedKey[_]) => - key.key match { - case resolvedScoped.key => Some(defining.asInstanceOf[A1$]) - case _ => None - } + def setResolved(defining: ScopedKey[_]) = λ[ScopedKey ~> Option]((key: ScopedKey[_]) => + key.key match { + case resolvedScoped.key => Some(defining.asInstanceOf[A1$]) + case _ => None + } ) - ss.map( - s => s mapConstant setResolved(s.key) mapReferenced mapSpecial(s.key) mapInit setDefining + ss.map(s => + s mapConstant setResolved(s.key) mapReferenced mapSpecial(s.key) mapInit setDefining ) } @@ -338,8 +335,8 @@ private[sbt] object Load { } // Reevaluates settings after modifying them. Does not recompile or reload any build components. - def reapply(newSettings: Seq[Setting[_]], structure: BuildStructure)( - implicit display: Show[ScopedKey[_]] + def reapply(newSettings: Seq[Setting[_]], structure: BuildStructure)(implicit + display: Show[ScopedKey[_]] ): BuildStructure = { val transformed = finalTransforms(newSettings) val (cMap, newData) = @@ -377,26 +374,24 @@ private[sbt] object Load { (((GlobalScope / loadedBuild) :== loaded) +: transformProjectOnly(loaded.root, rootProject, injectSettings.global)) ++ inScope(GlobalScope)(loaded.autos.globalSettings) ++ - loaded.units.toSeq.flatMap { - case (uri, build) => - val pluginBuildSettings = loaded.autos.buildSettings(uri) - val projectSettings = build.defined flatMap { - case (id, project) => - val ref = ProjectRef(uri, id) - val defineConfig: Seq[Setting[_]] = - for (c <- project.configurations) - yield ((ref / ConfigKey(c.name) / configuration) :== c) - val builtin: Seq[Setting[_]] = - (thisProject :== project) +: (thisProjectRef :== ref) +: defineConfig - val settings = builtin ++ project.settings ++ injectSettings.project - // map This to thisScope, Select(p) to mapRef(uri, rootProject, p) - transformSettings(projectScope(ref), uri, rootProject, settings) - } - val buildScope = Scope(Select(BuildRef(uri)), Zero, Zero, Zero) - val buildBase = baseDirectory :== build.localBase - val settings3 = pluginBuildSettings ++ (buildBase +: build.buildSettings) - val buildSettings = transformSettings(buildScope, uri, rootProject, settings3) - buildSettings ++ projectSettings + loaded.units.toSeq.flatMap { case (uri, build) => + val pluginBuildSettings = loaded.autos.buildSettings(uri) + val projectSettings = build.defined flatMap { case (id, project) => + val ref = ProjectRef(uri, id) + val defineConfig: Seq[Setting[_]] = + for (c <- project.configurations) + yield ((ref / ConfigKey(c.name) / configuration) :== c) + val builtin: Seq[Setting[_]] = + (thisProject :== project) +: (thisProjectRef :== ref) +: defineConfig + val settings = builtin ++ project.settings ++ injectSettings.project + // map This to thisScope, Select(p) to mapRef(uri, rootProject, p) + transformSettings(projectScope(ref), uri, rootProject, settings) + } + val buildScope = Scope(Select(BuildRef(uri)), Zero, Zero, Zero) + val buildBase = baseDirectory :== build.localBase + val settings3 = pluginBuildSettings ++ (buildBase +: build.buildSettings) + val buildSettings = transformSettings(buildScope, uri, rootProject, settings3) + buildSettings ++ projectSettings } } @@ -463,7 +458,8 @@ private[sbt] object Load { } } - /** Loads the unresolved build units and computes its settings. + /** + * Loads the unresolved build units and computes its settings. * * @param root The root directory. * @param s The given state. @@ -479,7 +475,8 @@ private[sbt] object Load { loadURI(IO.directoryURI(root), loader, config.extraBuilds.toList) } - /** Creates a loader for the build. + /** + * Creates a loader for the build. * * @param s The given state. * @param config The configuration of the loaded build. @@ -594,9 +591,8 @@ private[sbt] object Load { def resolveAll(builds: Map[URI, PartBuildUnit]): Map[URI, LoadedBuildUnit] = { val rootProject = getRootProject(builds) - builds map { - case (uri, unit) => - (uri, unit.resolveRefs(ref => Scope.resolveProjectRef(uri, rootProject, ref))) + builds map { case (uri, unit) => + (uri, unit.resolveRefs(ref => Scope.resolveProjectRef(uri, rootProject, ref))) } } @@ -627,10 +623,9 @@ private[sbt] object Load { def resolveProjects(loaded: PartBuild): LoadedBuild = { val rootProject = getRootProject(loaded.units) - val units = loaded.units map { - case (uri, unit) => - IO.assertAbsolute(uri) - (uri, resolveProjects(uri, unit, rootProject)) + val units = loaded.units map { case (uri, unit) => + IO.assertAbsolute(uri) + (uri, resolveProjects(uri, unit, rootProject)) } new LoadedBuild(loaded.root, units) } @@ -716,7 +711,8 @@ private[sbt] object Load { } mkEval(plugs.classpath, defDir, plugs.pluginData.scalacOptions, mkReporter) } - val initialProjects = defsScala.flatMap(b => projectsFromBuild(b, normBase)) ++ buildLevelExtraProjects + val initialProjects = + defsScala.flatMap(b => projectsFromBuild(b, normBase)) ++ buildLevelExtraProjects val hasRootAlreadyDefined = defsScala.exists(_.rootProject.isDefined) @@ -1124,11 +1120,13 @@ private[sbt] object Load { // Loads a given file, or pulls from the cache. def memoLoadSettingsFile(src: File): LoadedSbtFile = - memoSettings.getOrElse(src, { - val lf = loadSettingsFile(src) - memoSettings.put(src, lf.clearProjects) // don't load projects twice - lf - }) + memoSettings.getOrElse( + src, { + val lf = loadSettingsFile(src) + memoSettings.put(src, lf.clearProjects) // don't load projects twice + lf + } + ) // Loads a set of sbt files, sorted by their lexical name (current behavior of sbt). def loadFiles(fs: Seq[File]): LoadedSbtFile = @@ -1137,7 +1135,7 @@ private[sbt] object Load { // Finds all the build files associated with this project import AddSettings.{ DefaultSbtFiles, SbtFiles, Sequence } def associatedFiles(auto: AddSettings): Seq[File] = auto match { - case sf: SbtFiles => sf.files.map(f => IO.resolve(projectBase, f)).filterNot(_.isHidden) + case sf: SbtFiles => sf.files.map(f => IO.resolve(projectBase, f)).filterNot(_.isHidden) case sf: DefaultSbtFiles => sbtFiles.filter(sf.include).filterNot(_.isHidden) case q: Sequence => q.sequence.foldLeft(Seq.empty[File]) { (b, add) => @@ -1252,7 +1250,8 @@ private[sbt] object Load { def buildPlugins(dir: File, s: State, config: LoadBuildConfiguration): LoadedPlugins = loadPluginDefinition(dir, config, buildPluginDefinition(dir, s, config)) - /** Loads the plugins. + /** + * Loads the plugins. * * @param dir The base directory for the build. * @param config The configuration for the build. @@ -1274,7 +1273,8 @@ private[sbt] object Load { loadPlugins(dir, newData, pluginLoader) } - /** Constructs the classpath required to load plugins, the so-called + /** + * Constructs the classpath required to load plugins, the so-called * dependency classpath, from the provided classpath and the current config. * * @param config The configuration that declares classpath entries. @@ -1289,7 +1289,8 @@ private[sbt] object Load { else (depcp ++ config.classpath).distinct } - /** Creates a classloader with a hierarchical structure, where the parent + /** + * Creates a classloader with a hierarchical structure, where the parent * classloads the dependency classpath and the return classloader classloads * the definition classpath. * @@ -1331,8 +1332,8 @@ private[sbt] object Load { def initialSession(structure: BuildStructure, rootEval: () => Eval, s: State): SessionSettings = { val session = s get Keys.sessionSettings val currentProject = session map (_.currentProject) getOrElse Map.empty - val currentBuild = session map (_.currentBuild) filter ( - uri => structure.units.keys exists (uri ==) + val currentBuild = session map (_.currentBuild) filter (uri => + structure.units.keys exists (uri ==) ) getOrElse structure.root new SessionSettings( currentBuild, diff --git a/main/src/main/scala/sbt/internal/LoadedSbtFile.scala b/main/src/main/scala/sbt/internal/LoadedSbtFile.scala index d39a8e69a..7719c75c0 100644 --- a/main/src/main/scala/sbt/internal/LoadedSbtFile.scala +++ b/main/src/main/scala/sbt/internal/LoadedSbtFile.scala @@ -91,6 +91,6 @@ private[sbt] object DefinedSbtValues { private[sbt] object LoadedSbtFile { - /** Represents an empty .sbt file: no Projects, imports, or settings.*/ + /** Represents an empty .sbt file: no Projects, imports, or settings. */ def empty = new LoadedSbtFile(Nil, Nil, Nil, Nil, DefinedSbtValues.empty, Nil) } diff --git a/main/src/main/scala/sbt/internal/Output.scala b/main/src/main/scala/sbt/internal/Output.scala index 81090e7a4..1e1b8c458 100644 --- a/main/src/main/scala/sbt/internal/Output.scala +++ b/main/src/main/scala/sbt/internal/Output.scala @@ -57,14 +57,13 @@ object Output { def grep(lines: Seq[String], patternString: String): Seq[String] = lines flatMap showMatches(Pattern compile patternString) - def flatLines(outputs: Values[Seq[String]])(f: Seq[String] => Seq[String])( - implicit display: Show[ScopedKey[_]] + def flatLines(outputs: Values[Seq[String]])(f: Seq[String] => Seq[String])(implicit + display: Show[ScopedKey[_]] ): Seq[String] = { val single = outputs.size == 1 - outputs flatMap { - case KeyValue(key, lines) => - val flines = f(lines) - if (!single) bold(display.show(key)) +: flines else flines + outputs flatMap { case KeyValue(key, lines) => + val flines = f(lines) + if (!single) bold(display.show(key)) +: flines else flines } } @@ -96,8 +95,7 @@ object Output { headLines(IO.readLines(file).reverse, tailDelim).reverse @tailrec def headLines(lines: Seq[String], tailDelim: String): Seq[String] = - if (lines.isEmpty) - lines + if (lines.isEmpty) lines else { val (first, tail) = lines.span { line => !(line startsWith tailDelim) diff --git a/main/src/main/scala/sbt/internal/PluginManagement.scala b/main/src/main/scala/sbt/internal/PluginManagement.scala index b000a1061..fea4d34a9 100644 --- a/main/src/main/scala/sbt/internal/PluginManagement.scala +++ b/main/src/main/scala/sbt/internal/PluginManagement.scala @@ -68,7 +68,8 @@ object PluginManagement { ModuleID(m.organization, m.name, m.revision).withCrossVersion(m.crossVersion) final class PluginClassLoader(p: ClassLoader) extends URLClassLoader(Array(), p) { - private[this] val urlSet = new collection.mutable.HashSet[URI] // remember: don't use hashCode/equals on URL + private[this] val urlSet = + new collection.mutable.HashSet[URI] // remember: don't use hashCode/equals on URL def add(urls: Seq[URL]): Unit = synchronized { for (url <- urls) if (urlSet.add(url.toURI)) diff --git a/main/src/main/scala/sbt/internal/PluginsDebug.scala b/main/src/main/scala/sbt/internal/PluginsDebug.scala index d73cfcdc7..b3d3c6850 100644 --- a/main/src/main/scala/sbt/internal/PluginsDebug.scala +++ b/main/src/main/scala/sbt/internal/PluginsDebug.scala @@ -73,8 +73,7 @@ private[sbt] class PluginsDebug( s"\n\nThere are other available plugins that provide $notFoundKey, but they are " + s"impossible to add: $impossiblePlugins" possibleString + imPostfix - } else if (impossible.isEmpty) - s"No available plugin provides key $notFoundKey." + } else if (impossible.isEmpty) s"No available plugin provides key $notFoundKey." else { val explanations = impossible.map(explainPluginEnable) val preamble = s"Plugins are available that could provide $notFoundKey" @@ -189,14 +188,15 @@ private[sbt] object PluginsDebug { val s3 = s"Switch to a project in one of those builds using `project` and rerun this command for more information." s"$s1\n\t$s2\n$s3" - } else if (definesPlugin(currentProject)) - debug.activatedHelp(plugin) + } else if (definesPlugin(currentProject)) debug.activatedHelp(plugin) else { val thisAggregated = BuildUtil.dependencies(structure.units).aggregateTransitive.getOrElse(currentRef, Nil) val definedInAggregated = thisAggregated.filter(ref => definesPlugin(projectForRef(ref))) if (definedInAggregated.nonEmpty) { - val projectNames = definedInAggregated.map(_.project) // TODO: usually in this build, but could technically require the build to be qualified + val projectNames = definedInAggregated.map( + _.project + ) // TODO: usually in this build, but could technically require the build to be qualified val s2 = projectNames.mkString("\n\t") s"Plugin ${plugin.label} is not activated on this project, but this project aggregates projects where it is activated:\n\t$s2" } else { @@ -238,7 +238,7 @@ private[sbt] object PluginsDebug { /** Describes the steps to activate a plugin in some context. */ sealed abstract class PluginEnable - /** Describes a [[plugin]] that is already activated in the [[context]].*/ + /** Describes a [[plugin]] that is already activated in the [[context]]. */ final case class PluginActivated(plugin: AutoPlugin, context: Context) extends PluginEnable sealed abstract class EnableDeactivated extends PluginEnable @@ -404,13 +404,13 @@ private[sbt] object PluginsDebug { def explainPluginEnable(ps: PluginEnable): String = ps match { case PluginRequirements( - plugin, - _, - blockingExcludes, - enablingPlugins, - extraEnabledPlugins, - toBeRemoved, - deactivate + plugin, + _, + blockingExcludes, + enablingPlugins, + extraEnabledPlugins, + toBeRemoved, + deactivate ) => def indent(str: String) = if (str.isEmpty) "" else s"\t$str" def note(str: String) = if (str.isEmpty) "" else s"Note: $str" @@ -423,7 +423,7 @@ private[sbt] object PluginsDebug { Nil parts.filterNot(_.isEmpty).mkString("\n") case PluginImpossible(plugin, _, contradictions) => pluginImpossible(plugin, contradictions) - case PluginActivated(plugin, _) => s"Plugin ${plugin.label} already activated." + case PluginActivated(plugin, _) => s"Plugin ${plugin.label} already activated." } /** diff --git a/main/src/main/scala/sbt/internal/SessionSettings.scala b/main/src/main/scala/sbt/internal/SessionSettings.scala index dce3424d6..bdd441f44 100755 --- a/main/src/main/scala/sbt/internal/SessionSettings.scala +++ b/main/src/main/scala/sbt/internal/SessionSettings.scala @@ -139,8 +139,7 @@ object SessionSettings { if (session.append.isEmpty) { s.log.info("No session settings defined.") s - } else - f(session) + } else f(session) } /** Adds `s` to a strings when needed. Maybe one day we'll care about non-english languages. */ @@ -151,7 +150,10 @@ object SessionSettings { val oldSettings = (oldState get Keys.sessionSettings).toList.flatMap(_.append).flatMap(_._2) if (newSession.append.isEmpty && oldSettings.nonEmpty) oldState.log.warn( - "Discarding " + pluralize(oldSettings.size, " session setting") + ". Use 'session save' to persist session settings." + "Discarding " + pluralize( + oldSettings.size, + " session setting" + ) + ". Use 'session save' to persist session settings." ) } @@ -335,16 +337,16 @@ save, save-all "clear" ^^^ new Clear(false) ) | token("save-all" ^^^ new Save(true)) | token("save" ^^^ new Save(false)) | token( - "clear-all" ^^^ new Clear(true) - ) | + "clear-all" ^^^ new Clear(true) + ) | remove) lazy val remove = token("remove") ~> token(Space) ~> natSelect.map(ranges => new Remove(ranges)) def natSelect = rep1sep(token(range, ""), ',') - def range: Parser[(Int, Int)] = (NatBasic ~ ('-' ~> NatBasic).?).map { - case lo ~ hi => (lo, hi getOrElse lo) + def range: Parser[(Int, Int)] = (NatBasic ~ ('-' ~> NatBasic).?).map { case lo ~ hi => + (lo, hi getOrElse lo) } /** The raw implementation of the session command. */ diff --git a/main/src/main/scala/sbt/internal/SettingCompletions.scala b/main/src/main/scala/sbt/internal/SettingCompletions.scala index e3ff3cce4..c9fba59ad 100644 --- a/main/src/main/scala/sbt/internal/SettingCompletions.scala +++ b/main/src/main/scala/sbt/internal/SettingCompletions.scala @@ -31,7 +31,7 @@ private[sbt] class SetResult( val quietSummary: String ) -/** Defines methods for implementing the `set` command.*/ +/** Defines methods for implementing the `set` command. */ private[sbt] object SettingCompletions { /** @@ -72,7 +72,8 @@ private[sbt] object SettingCompletions { setResult(session, r, redefined) } - /** Implementation of the `set` command that will reload the current project with `settings` + /** + * Implementation of the `set` command that will reload the current project with `settings` * appended to the current settings. */ def setThis(extracted: Extracted, settings: Seq[Def.Setting[_]], arg: String): SetResult = { @@ -115,15 +116,13 @@ private[sbt] object SettingCompletions { quietList(in) def quietList(in: Seq[String]): (String, Boolean) = { val (first, last) = in.splitAt(QuietLimit) - if (last.isEmpty) - (first.mkString(", "), false) + if (last.isEmpty) (first.mkString(", "), false) else { val s = first.take(QuietLimit - 1).mkString("", ", ", " and " + last.size + " others.") (s, true) } } - if (redefined.isEmpty) - "No settings or tasks were redefined." + if (redefined.isEmpty) "No settings or tasks were redefined." else { val (redef, trimR) = lines(strings(redefined)) val (used, trimU) = lines(strings(affected)) @@ -173,7 +172,7 @@ private[sbt] object SettingCompletions { yield ScopedKey(scope, key) } - /** Parser for the `in` method name that slightly augments the naive completion to give a hint of the purpose of `in`.*/ + /** Parser for the `in` method name that slightly augments the naive completion to give a hint of the purpose of `in`. */ val inParser = tokenDisplay(Space ~> InMethod, "%s ".format(InMethod)) /** @@ -204,8 +203,8 @@ private[sbt] object SettingCompletions { ): Parser[Scope] = { val data = settings.data val allScopes = data.keys.toSeq - val definedScopes = data.toSeq flatMap { - case (scope, attrs) => if (attrs contains key) scope :: Nil else Nil + val definedScopes = data.toSeq flatMap { case (scope, attrs) => + if (attrs contains key) scope :: Nil else Nil } scope(allScopes, definedScopes, context) } @@ -257,7 +256,8 @@ private[sbt] object SettingCompletions { val completions = fixedCompletions { (seen, _) => completeAssign(seen, key).toSet } - val identifier = Act.filterStrings(Op, Assign.values.map(_.toString), "assignment method") map Assign.withName + val identifier = + Act.filterStrings(Op, Assign.values.map(_.toString), "assignment method") map Assign.withName token(Space) ~> token(optionallyQuoted(identifier), completions) } @@ -271,8 +271,8 @@ private[sbt] object SettingCompletions { /** Produce a new parser that allows the input accepted by `p` to be quoted in backticks. */ def optionallyQuoted[T](p: Parser[T]): Parser[T] = - (Backtick.? ~ p) flatMap { - case (quote, id) => if (quote.isDefined) Backtick.? ^^^ id else success(id) + (Backtick.? ~ p) flatMap { case (quote, id) => + if (quote.isDefined) Backtick.? ^^^ id else success(id) } /** @@ -297,8 +297,8 @@ private[sbt] object SettingCompletions { prominentCutoff: Int, detailLimit: Int ): Seq[Completion] = - completeSelectDescribed(seen, level, keys, detailLimit)(_.description) { - case (_, v) => v.rank <= prominentCutoff + completeSelectDescribed(seen, level, keys, detailLimit)(_.description) { case (_, v) => + v.rank <= prominentCutoff } def completeScope[T]( @@ -307,8 +307,8 @@ private[sbt] object SettingCompletions { definedChoices: Set[String], allChoices: Map[String, T] )(description: T => Option[String]): Seq[Completion] = - completeSelectDescribed(seen, level, allChoices, 10)(description) { - case (k, _) => definedChoices(k) + completeSelectDescribed(seen, level, allChoices, 10)(description) { case (k, _) => + definedChoices(k) } def completeSelectDescribed[T](seen: String, level: Int, all: Map[String, T], detailLimit: Int)( @@ -317,7 +317,9 @@ private[sbt] object SettingCompletions { val applicable = all.toSeq.filter { case (k, _) => k startsWith seen } val prominentOnly = applicable filter { case (k, v) => prominent(k, v) } - val showAll = (level >= 3) || (level == 2 && prominentOnly.lengthCompare(detailLimit) <= 0) || prominentOnly.isEmpty + val showAll = (level >= 3) || (level == 2 && prominentOnly.lengthCompare( + detailLimit + ) <= 0) || prominentOnly.isEmpty val showKeys = if (showAll) applicable else prominentOnly val showDescriptions = (level >= 2) || showKeys.lengthCompare(detailLimit) <= 0 completeDescribed(seen, showDescriptions, showKeys)(s => description(s).toList.mkString) @@ -326,14 +328,12 @@ private[sbt] object SettingCompletions { description: T => String ): Seq[Completion] = { def appendString(id: String): String = id.stripPrefix(seen) + " " - if (in.isEmpty) - Nil + if (in.isEmpty) Nil else if (showDescriptions) { val withDescriptions = in map { case (id, key) => (id, description(key)) } val padded = CommandUtil.aligned("", " ", withDescriptions) - (padded, in).zipped.map { - case (line, (id, _)) => - Completion.tokenDisplay(append = appendString(id), display = line + "\n") + (padded, in).zipped.map { case (line, (id, _)) => + Completion.tokenDisplay(append = appendString(id), display = line + "\n") } } else in map { case (id, _) => Completion.tokenDisplay(display = id, append = appendString(id)) } @@ -351,7 +351,7 @@ private[sbt] object SettingCompletions { */ def configScalaID(c: String): String = Util.quoteIfKeyword(c.capitalize) - /** Applies a function on the underlying manifest for T for `key` depending if it is for a `Setting[T]`, `Task[T]`, or `InputTask[T]`.*/ + /** Applies a function on the underlying manifest for T for `key` depending if it is for a `Setting[T]`, `Task[T]`, or `InputTask[T]`. */ def keyType[S](key: AttributeKey[_])( onSetting: Manifest[_] => S, onTask: Manifest[_] => S, @@ -388,7 +388,7 @@ private[sbt] object SettingCompletions { /** The simple name of the Global scope, which can be used to reference it in the default setting context. */ final val GlobalID = Scope.Global.getClass.getSimpleName.stripSuffix("$") - /** Character used to quote a Scala identifier that would otherwise be interpreted as a keyword.*/ + /** Character used to quote a Scala identifier that would otherwise be interpreted as a keyword. */ final val Backtick = '`' /** Name of the method that modifies the scope of a key. */ @@ -414,7 +414,7 @@ private[sbt] object SettingCompletions { /** The assignment methods except for the ones that append. */ val assignNoAppend: Set[Assign.Value] = Set(Define, Update) - /** Class values to approximate which types can be appended*/ + /** Class values to approximate which types can be appended */ val appendableClasses = Seq( classOf[Seq[_]], classOf[Map[_, _]], diff --git a/main/src/main/scala/sbt/internal/TaskProgress.scala b/main/src/main/scala/sbt/internal/TaskProgress.scala index 65fea78fc..7bb82858d 100644 --- a/main/src/main/scala/sbt/internal/TaskProgress.scala +++ b/main/src/main/scala/sbt/internal/TaskProgress.scala @@ -70,8 +70,10 @@ private[sbt] class TaskProgress( pending.clear() scheduler.shutdownNow() executor.shutdownNow() - if (!executor.awaitTermination(30, TimeUnit.SECONDS) || - !scheduler.awaitTermination(30, TimeUnit.SECONDS)) { + if ( + !executor.awaitTermination(30, TimeUnit.SECONDS) || + !scheduler.awaitTermination(30, TimeUnit.SECONDS) + ) { scala.Console.err.println("timed out closing the executor of supershell") throw new TimeoutException } @@ -166,10 +168,9 @@ private[sbt] class TaskProgress( if (tasks.nonEmpty) nextReport.set(Deadline.now + sleepDuration) val toWrite = tasks.sortBy(_._2) val distinct = new java.util.LinkedHashMap[String, ProgressItem] - toWrite.foreach { - case (task, elapsed) => - val name = taskName(task) - distinct.put(name, ProgressItem(name, elapsed)) + toWrite.foreach { case (task, elapsed) => + val name = taskName(task) + distinct.put(name, ProgressItem(name, elapsed)) } ProgressEvent( "Info", @@ -200,11 +201,10 @@ private[sbt] class TaskProgress( private[this] def filter( tasks: Vector[(Task[_], Long)] ): (Vector[(Task[_], Long)], Boolean) = { - tasks.foldLeft((Vector.empty[(Task[_], Long)], false)) { - case ((tasks, skip), pair @ (t, _)) => - val shortName = getShortName(t) - val newSkip = skip || skipReportTasks.contains(shortName) - if (hiddenTasks.contains(shortName)) (tasks, newSkip) else (tasks :+ pair, newSkip) + tasks.foldLeft((Vector.empty[(Task[_], Long)], false)) { case ((tasks, skip), pair @ (t, _)) => + val shortName = getShortName(t) + val newSkip = skip || skipReportTasks.contains(shortName) + if (hiddenTasks.contains(shortName)) (tasks, newSkip) else (tasks :+ pair, newSkip) } } } diff --git a/main/src/main/scala/sbt/internal/TaskTimings.scala b/main/src/main/scala/sbt/internal/TaskTimings.scala index fe814ccd5..5b2041e3f 100644 --- a/main/src/main/scala/sbt/internal/TaskTimings.scala +++ b/main/src/main/scala/sbt/internal/TaskTimings.scala @@ -26,12 +26,15 @@ private[sbt] final class TaskTimings(reportOnShutdown: Boolean, logger: Logger) with ExecuteProgress[Task] { @deprecated("Use the constructor that takes an sbt.util.Logger parameter.", "1.3.3") def this(reportOnShutdown: Boolean) = - this(reportOnShutdown, new Logger { - override def trace(t: => Throwable): Unit = {} - override def success(message: => String): Unit = {} - override def log(level: Level.Value, message: => String): Unit = - ConsoleOut.systemOut.println(message) - }) + this( + reportOnShutdown, + new Logger { + override def trace(t: => Throwable): Unit = {} + override def success(message: => String): Unit = {} + override def log(level: Level.Value, message: => String): Unit = + ConsoleOut.systemOut.println(message) + } + ) private[this] var start = 0L private[this] val threshold = SysProp.taskTimingsThreshold private[this] val omitPaths = SysProp.taskTimingsOmitPaths @@ -64,18 +67,16 @@ private[sbt] final class TaskTimings(reportOnShutdown: Boolean, logger: Logger) val times = timingsByName.toSeq .sortBy(_._2.get) .reverse - .map { - case (name, time) => - (if (omitPaths) reFilePath.replaceFirstIn(name, "") else name, divide(time.get)) + .map { case (name, time) => + (if (omitPaths) reFilePath.replaceFirstIn(name, "") else name, divide(time.get)) } .filter { _._2 > threshold } if (times.size > 0) { val maxTaskNameLength = times.map { _._1.length }.max val maxTime = times.map { _._2 }.max.toString.length - times.foreach { - case (taskName, time) => - logger.info(s" ${taskName.padTo(maxTaskNameLength, ' ')}: ${"" - .padTo(maxTime - time.toString.length, ' ')}$time $unit") + times.foreach { case (taskName, time) => + logger.info(s" ${taskName.padTo(maxTaskNameLength, ' ')}: ${"" + .padTo(maxTime - time.toString.length, ' ')}$time $unit") } } } diff --git a/main/src/main/scala/sbt/internal/WatchTransitiveDependencies.scala b/main/src/main/scala/sbt/internal/WatchTransitiveDependencies.scala index 5215f4ea8..17d9868f0 100644 --- a/main/src/main/scala/sbt/internal/WatchTransitiveDependencies.scala +++ b/main/src/main/scala/sbt/internal/WatchTransitiveDependencies.scala @@ -84,7 +84,7 @@ private[sbt] object WatchTransitiveDependencies { case Some(ShowTransitive(key)) => Parser.parse(key.trim, Act.scopedKeyParser(state.value)) match { case Right(scopedKey) => argumentsImpl(scopedKey, extracted, compiledMap) - case _ => argumentsImpl(Keys.resolvedScoped.value, extracted, compiledMap) + case _ => argumentsImpl(Keys.resolvedScoped.value, extracted, compiledMap) } case Some(_) => argumentsImpl(Keys.resolvedScoped.value, extracted, compiledMap) } @@ -139,21 +139,20 @@ private[sbt] object WatchTransitiveDependencies { .toIndexedSeq val projects = projectScopes.flatMap(_.project.toOption).distinct.toSet val scopes: Seq[Either[Scope, Seq[Glob]]] = - data.flatMap { - case (s, am) => - if (s == Scope.Global || s.project.toOption.exists(projects.contains)) - am.get(Keys.watchSources.key) match { - case Some(k) => - k.work match { - // Avoid extracted.runTask if possible. - case Pure(w, _) => Some(Right(w().map(_.toGlob))) - case _ => Some(Left(s)) - } - case _ => None - } - else { - None + data.flatMap { case (s, am) => + if (s == Scope.Global || s.project.toOption.exists(projects.contains)) + am.get(Keys.watchSources.key) match { + case Some(k) => + k.work match { + // Avoid extracted.runTask if possible. + case Pure(w, _) => Some(Right(w().map(_.toGlob))) + case _ => Some(Left(s)) + } + case _ => None } + else { + None + } }.toSeq def toDynamicInput(glob: Glob): DynamicInput = DynamicInput(glob, FileStamper.LastModified, forceTrigger = true) @@ -214,7 +213,7 @@ private[sbt] object WatchTransitiveDependencies { // Append the Keys.triggers key in case there are no other references to Keys.triggers. val transitiveTrigger = compiled.key.scope.task.toOption match { case _: Some[_] => ScopedKey(compiled.key.scope, watchTriggers.key) - case None => ScopedKey(Project.fillTaskAxis(compiled.key).scope, watchTriggers.key) + case None => ScopedKey(Project.fillTaskAxis(compiled.key).scope, watchTriggers.key) } val newRest = rest ++ newDependencies ++ (if (newVisited(transitiveTrigger)) Nil else Some(transitiveTrigger)) diff --git a/main/src/main/scala/sbt/internal/graph/model.scala b/main/src/main/scala/sbt/internal/graph/model.scala index 5bedafcc4..b8e9efd4e 100644 --- a/main/src/main/scala/sbt/internal/graph/model.scala +++ b/main/src/main/scala/sbt/internal/graph/model.scala @@ -22,9 +22,9 @@ private[sbt] object GraphModuleId { implicit val graphModuleIdIso = LList.iso[GraphModuleId, String :*: String :*: String :*: LNil]( { m: GraphModuleId => ("organization", m.organization) :*: ("name", m.name) :*: ("version", m.version) :*: LNil - }, { - case (_, organization) :*: (_, name) :*: (_, version) :*: LNil => - GraphModuleId(organization, name, version) + }, + { case (_, organization) :*: (_, name) :*: (_, version) :*: LNil => + GraphModuleId(organization, name, version) } ) } @@ -50,11 +50,15 @@ private[sbt] object Module { { m: Module => ("id", m.id) :*: ("license", m.license) :*: ("extraInfo", m.extraInfo) :*: ("evictedByVersion", m.evictedByVersion) :*: ( - "jarFile", - m.jarFile - ) :*: ("error", m.error) :*: LNil - }, { - case (_, id) :*: (_, license) :*: (_, extraInfo) :*: (_, evictedByVersion) :*: (_, jarFile) :*: ( + "jarFile", + m.jarFile + ) :*: ("error", m.error) :*: LNil + }, + { + case (_, id) :*: (_, license) :*: (_, extraInfo) :*: (_, evictedByVersion) :*: ( + _, + jarFile + ) :*: ( _, error ) :*: LNil => @@ -97,9 +101,9 @@ private[sbt] object ModuleGraph { implicit val moduleGraphIso = LList.iso[ModuleGraph, Vector[Module] :*: Vector[Edge] :*: LNil]( { g: ModuleGraph => ("nodes", g.nodes.toVector) :*: ("edges", g.edges.toVector) :*: LNil - }, { - case (_, nodes: Vector[Module]) :*: (_, edges: Vector[Edge]) :*: LNil => - ModuleGraph(nodes, edges) + }, + { case (_, nodes: Vector[Module]) :*: (_, edges: Vector[Edge]) :*: LNil => + ModuleGraph(nodes, edges) } ) } diff --git a/main/src/main/scala/sbt/internal/graph/rendering/LicenseInfo.scala b/main/src/main/scala/sbt/internal/graph/rendering/LicenseInfo.scala index d00209735..ba7194cbd 100644 --- a/main/src/main/scala/sbt/internal/graph/rendering/LicenseInfo.scala +++ b/main/src/main/scala/sbt/internal/graph/rendering/LicenseInfo.scala @@ -17,10 +17,9 @@ object LicenseInfo { .groupBy(_.license) .toSeq .sortBy(_._1) - .map { - case (license, modules) => - license.getOrElse("No license specified") + "\n" + - modules.map(m => s"\t ${m.id.idString}").mkString("\n") + .map { case (license, modules) => + license.getOrElse("No license specified") + "\n" + + modules.map(m => s"\t ${m.id.idString}").mkString("\n") } .mkString("\n\n") } diff --git a/main/src/main/scala/sbt/internal/librarymanagement/IvyXml.scala b/main/src/main/scala/sbt/internal/librarymanagement/IvyXml.scala index 74c3af588..ae36a2825 100644 --- a/main/src/main/scala/sbt/internal/librarymanagement/IvyXml.scala +++ b/main/src/main/scala/sbt/internal/librarymanagement/IvyXml.scala @@ -95,13 +95,12 @@ object IvyXml { new PrefixedAttribute("e", k, v, acc) } - val licenseElems = project.info.licenses.map { - case (name, urlOpt) => - val n = + val licenseElems = project.info.licenses.map { case (name, urlOpt) => + val n = - urlOpt.fold(n) { url => - n % .attributes - } + urlOpt.fold(n) { url => + n % .attributes + } } val descriptionElem = { @@ -134,55 +133,56 @@ object IvyXml { } val publications = project.publications - .groupBy { case (_, p) => p } + .groupBy { case (_, p) => p } .mapValues { _.map { case (cfg, _) => cfg } } - val publicationElems = publications.map { - case (pub, configs) => - val n = - + val publicationElems = publications.map { case (pub, configs) => + val n = + - if (pub.classifier.value.nonEmpty) - n % .attributes - else - n + if (pub.classifier.value.nonEmpty) + n % .attributes + else + n } - val dependencyElems = project.dependencies.toVector.map { - case (conf, dep) => - val classifier = { - val pub = dep.publication - if (pub.classifier.value.nonEmpty) - Seq( - - ) - else - Seq.empty - } + val dependencyElems = project.dependencies.toVector.map { case (conf, dep) => + val classifier = { + val pub = dep.publication + if (pub.classifier.value.nonEmpty) + Seq( + + ) + else + Seq.empty + } - val excludes = dep.exclusions.toSeq.map { - case (org, name) => - - } + val excludes = dep.exclusions.toSeq.map { case (org, name) => + + } - val n = - ${dep.configuration.value}"}> + val n = + ${dep.configuration.value}"}> {classifier} {excludes} - val moduleAttrs = dep.module.attributes.foldLeft[xml.MetaData](xml.Null) { - case (acc, (k, v)) => - new PrefixedAttribute("e", k, v, acc) - } + val moduleAttrs = dep.module.attributes.foldLeft[xml.MetaData](xml.Null) { + case (acc, (k, v)) => + new PrefixedAttribute("e", k, v, acc) + } - n % moduleAttrs + n % moduleAttrs } @@ -213,7 +213,8 @@ object IvyXml { sbt.Keys.ivySbt.value, sbt.Keys.streams.value.log ) - } else + } + else Def.task(()) } }.value diff --git a/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala b/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala index 9a6c46b15..a6f607bce 100644 --- a/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala +++ b/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala @@ -97,10 +97,9 @@ object BuildServerProtocol { val workspace = Keys.bspFullWorkspace.value val state = Keys.state.value val allTargets = ScopeFilter.in(workspace.scopes.values.toSeq) - val sbtTargets = workspace.builds.map { - case (buildTargetIdentifier, loadedBuildUnit) => - val buildFor = workspace.buildToScope.getOrElse(buildTargetIdentifier, Nil) - sbtBuildTarget(loadedBuildUnit, buildTargetIdentifier, buildFor).result + val sbtTargets = workspace.builds.map { case (buildTargetIdentifier, loadedBuildUnit) => + val buildFor = workspace.buildToScope.getOrElse(buildTargetIdentifier, Nil) + sbtBuildTarget(loadedBuildUnit, buildTargetIdentifier, buildFor).result }.toList Def.task { val buildTargets = Keys.bspBuildTarget.result.all(allTargets).value @@ -114,23 +113,22 @@ object BuildServerProtocol { // run the worker task concurrently Def.task { val items = bspBuildTargetSourcesItem.result.all(filter).value - val buildItems = workspace.builds.map { - case (id, loadedBuildUnit) => - val base = loadedBuildUnit.localBase - val sbtFiles = configurationSources(base) - val pluginData = loadedBuildUnit.unit.plugins.pluginData - val dirs = pluginData.unmanagedSourceDirectories - val sourceFiles = getStandaloneSourceFiles(pluginData.unmanagedSources, dirs) - val managedDirs = pluginData.managedSourceDirectories - val managedSourceFiles = - getStandaloneSourceFiles(pluginData.managedSources, managedDirs) - val items = - dirs.map(toSourceItem(SourceItemKind.Directory, generated = false)) ++ - sourceFiles.map(toSourceItem(SourceItemKind.File, generated = false)) ++ - managedDirs.map(toSourceItem(SourceItemKind.Directory, generated = true)) ++ - managedSourceFiles.map(toSourceItem(SourceItemKind.File, generated = true)) ++ - sbtFiles.map(toSourceItem(SourceItemKind.File, generated = false)) - Value(SourcesItem(id, items.toVector)) + val buildItems = workspace.builds.map { case (id, loadedBuildUnit) => + val base = loadedBuildUnit.localBase + val sbtFiles = configurationSources(base) + val pluginData = loadedBuildUnit.unit.plugins.pluginData + val dirs = pluginData.unmanagedSourceDirectories + val sourceFiles = getStandaloneSourceFiles(pluginData.unmanagedSources, dirs) + val managedDirs = pluginData.managedSourceDirectories + val managedSourceFiles = + getStandaloneSourceFiles(pluginData.managedSources, managedDirs) + val items = + dirs.map(toSourceItem(SourceItemKind.Directory, generated = false)) ++ + sourceFiles.map(toSourceItem(SourceItemKind.File, generated = false)) ++ + managedDirs.map(toSourceItem(SourceItemKind.Directory, generated = true)) ++ + managedSourceFiles.map(toSourceItem(SourceItemKind.File, generated = true)) ++ + sbtFiles.map(toSourceItem(SourceItemKind.File, generated = false)) + Value(SourcesItem(id, items.toVector)) } val successfulItems = anyOrThrow(items ++ buildItems) val result = SourcesResult(successfulItems.toVector) @@ -205,19 +203,18 @@ object BuildServerProtocol { val items = bspBuildTargetScalacOptionsItem.result.all(filter).value val appProvider = appConfiguration.value.provider() val sbtJars = appProvider.mainClasspath() - val buildItems = builds.map { - build => - val plugins: LoadedPlugins = build._2.unit.plugins - val scalacOptions = plugins.pluginData.scalacOptions - val pluginClassPath = plugins.classpath - val classpath = (pluginClassPath ++ sbtJars).map(_.toURI).toVector - val item = ScalacOptionsItem( - build._1, - scalacOptions.toVector, - classpath, - new File(build._2.localBase, "project/target").toURI - ) - Value(item) + val buildItems = builds.map { build => + val plugins: LoadedPlugins = build._2.unit.plugins + val scalacOptions = plugins.pluginData.scalacOptions + val pluginClassPath = plugins.classpath + val classpath = (pluginClassPath ++ sbtJars).map(_.toURI).toVector + val item = ScalacOptionsItem( + build._1, + scalacOptions.toVector, + classpath, + new File(build._2.localBase, "project/target").toURI + ) + Value(item) } val successfulItems = anyOrThrow(items ++ buildItems) val result = ScalacOptionsResult(successfulItems.toVector) @@ -347,7 +344,9 @@ object BuildServerProtocol { final val ScalaMainClasses = "buildTarget/scalaMainClasses" final val Exit = "build/exit" } - identity(Method) // silence spurious "private object Method in object BuildServerProtocol is never used" warning! + identity( + Method + ) // silence spurious "private object Method in object BuildServerProtocol is never used" warning! def handler( loadedBuild: LoadedBuild, @@ -753,9 +752,8 @@ object BuildServerProtocol { } } - private val jsonParser: Parser[Try[JValue]] = (Parsers.any *) - .map(_.mkString) - .map(JsonParser.parseFromString) + private val jsonParser: Parser[Try[JValue]] = (Parsers.any *).map(_.mkString) + .map(JsonParser.parseFromString) private def bspRunTask: Def.Initialize[InputTask[Unit]] = Def.inputTaskDyn { val runParams = jsonParser @@ -883,19 +881,18 @@ object BuildServerProtocol { private def internalDependencyConfigurationsSetting = Def.settingDyn { val allScopes = bspFullWorkspace.value.scopes.map { case (_, scope) => scope }.toSet val directDependencies = Keys.internalDependencyConfigurations.value - .map { - case (project, rawConfigs) => - val configs = rawConfigs - .flatMap(_.split(",")) - .map(name => ConfigKey(name.trim)) - .filter { config => - val scope = Scope.Global.in(project, config) - allScopes.contains(scope) - } - (project, configs) + .map { case (project, rawConfigs) => + val configs = rawConfigs + .flatMap(_.split(",")) + .map(name => ConfigKey(name.trim)) + .filter { config => + val scope = Scope.Global.in(project, config) + allScopes.contains(scope) + } + (project, configs) } - .filter { - case (_, configs) => configs.nonEmpty + .filter { case (_, configs) => + configs.nonEmpty } val ref = Keys.thisProjectRef.value val thisConfig = Keys.configuration.value @@ -979,14 +976,14 @@ object BuildServerProtocol { private def anyOrThrow[T](results: Seq[Result[T]]): Seq[T] = { val successes = results.collect { case Value(v) => v } - val errors = results.collect { case Inc(cause) => cause } + val errors = results.collect { case Inc(cause) => cause } if (successes.nonEmpty || errors.isEmpty) successes else throw Incomplete(None, causes = errors) } private def allOrThrow[T](results: Seq[Result[T]]): Seq[T] = { val successes = results.collect { case Value(v) => v } - val errors = results.collect { case Inc(cause) => cause } + val errors = results.collect { case Inc(cause) => cause } if (errors.isEmpty) successes else throw Incomplete(None, causes = errors) } diff --git a/main/src/main/scala/sbt/internal/server/Definition.scala b/main/src/main/scala/sbt/internal/server/Definition.scala index 0564c9811..4b0fda4a7 100644 --- a/main/src/main/scala/sbt/internal/server/Definition.scala +++ b/main/src/main/scala/sbt/internal/server/Definition.scala @@ -84,14 +84,13 @@ private[sbt] object Definition { val whiteSpaceReg = "(\\s|\\.)+".r val (zero, end) = fold(Seq.empty)(whiteSpaceReg.findAllIn(line)) - .collect { - case (white, ind) => (ind, ind + white.length) + .collect { case (white, ind) => + (ind, ind + white.length) } - .fold((0, line.length)) { - case ((left, right), (from, to)) => - val zero = if (to > left && to <= point) to else left - val end = if (from < right && from >= point) from else right - (zero, end) + .fold((0, line.length)) { case ((left, right), (from, to)) => + val zero = if (to > left && to <= point) to else left + val end = if (from < right && from >= point) from else right + (zero, end) } val ranges = for { @@ -101,17 +100,16 @@ private[sbt] object Definition { ranges .sortBy { case (from, to) => -(to - from) } - .foldLeft(List.empty[String]) { - case (z, (from, to)) => - val fragment = line.slice(from, to).trim - if (isIdentifier(fragment)) - z match { - case Nil if fragment.nonEmpty => fragment :: z - case h :: _ if h.length < fragment.length => fragment :: Nil - case h :: _ if h.length == fragment.length => fragment :: z - case _ => z - } - else z + .foldLeft(List.empty[String]) { case (z, (from, to)) => + val fragment = line.slice(from, to).trim + if (isIdentifier(fragment)) + z match { + case Nil if fragment.nonEmpty => fragment :: z + case h :: _ if h.length < fragment.length => fragment :: Nil + case h :: _ if h.length == fragment.length => fragment :: z + case _ => z + } + else z } .headOption } @@ -150,9 +148,8 @@ private[sbt] object Definition { .flatMap { reg => fold(Seq.empty)(reg.findAllIn(line)) } - .collect { - case (name, pos) => - (if (name.endsWith("[")) name.init.trim else name.trim) -> pos + .collect { case (name, pos) => + (if (name.endsWith("[")) name.init.trim else name.trim) -> pos } } @@ -163,13 +160,11 @@ private[sbt] object Definition { .iterator .asScala .zipWithIndex - .flatMap { - case (line, lineNumber) => - findInLine(line) - .collect { - case (sym, from) => - (file.toUri, lineNumber.toLong, from.toLong, from.toLong + sym.length) - } + .flatMap { case (line, lineNumber) => + findInLine(line) + .collect { case (sym, from) => + (file.toUri, lineNumber.toLong, from.toLong, from.toLong + sym.length) + } } .toSeq .distinct @@ -249,9 +244,8 @@ private[sbt] object Definition { if (addToCache.nonEmpty) { AnalysesAccess.cache.put(AnalysesKey, validCaches) } - result.success(validCaches.toSeq.collect { - case (_, Some(analysis)) => - analysis + result.success(validCaches.toSeq.collect { case (_, Some(analysis)) => + analysis }) } } catch { case scala.util.control.NonFatal(e) => result.failure(e) } @@ -303,12 +297,11 @@ private[sbt] object Definition { } .flatMap { classFile: VirtualFileRef => val x = converter.toPath(classFile) - textProcessor.markPosition(x, sym).collect { - case (uri, line, from, to) => - Location( - uri.toString, - Range(Position(line, from), Position(line, to)), - ) + textProcessor.markPosition(x, sym).collect { case (uri, line, from, to) => + Location( + uri.toString, + Range(Position(line, from), Position(line, to)), + ) } } }.seq @@ -316,16 +309,15 @@ private[sbt] object Definition { import langserver.codec.JsonProtocol._ send(commandSource, requestId)(locations.toArray) } - .recover { - case t => - log.warn(s"Problem with processing analyses $t for $jsonDefinitionString") - val rsp = JsonRpcResponseError( - ErrorCodes.InternalError, - "Problem with processing analyses.", - None, - ) - import JsonRPCProtocol._ - send(commandSource, requestId)(rsp) + .recover { case t => + log.warn(s"Problem with processing analyses $t for $jsonDefinitionString") + val rsp = JsonRpcResponseError( + ErrorCodes.InternalError, + "Problem with processing analyses.", + None, + ) + import JsonRPCProtocol._ + send(commandSource, requestId)(rsp) } () case None => diff --git a/main/src/main/scala/sbt/internal/server/SettingQuery.scala b/main/src/main/scala/sbt/internal/server/SettingQuery.scala index 98aa89655..50776c484 100644 --- a/main/src/main/scala/sbt/internal/server/SettingQuery.scala +++ b/main/src/main/scala/sbt/internal/server/SettingQuery.scala @@ -113,12 +113,11 @@ object SettingQuery { structure: BuildStructure, key: Def.ScopedKey[A] ): Either[String, JValue] = - getSettingValue(structure, key) flatMap ( - value => - getJsonWriter(key.key) map { implicit jw: JsonWriter[A] => - toJson(value) - } - ) + getSettingValue(structure, key) flatMap (value => + getJsonWriter(key.key) map { implicit jw: JsonWriter[A] => + toJson(value) + } + ) def handleSettingQueryEither( req: SettingQuery, diff --git a/main/src/main/scala/sbt/nio/FileStamp.scala b/main/src/main/scala/sbt/nio/FileStamp.scala index 1a892373e..ca8c4bbff 100644 --- a/main/src/main/scala/sbt/nio/FileStamp.scala +++ b/main/src/main/scala/sbt/nio/FileStamp.scala @@ -25,7 +25,6 @@ sealed trait FileStamper /** * Provides implementations of [[FileStamper]]. - * */ object FileStamper { @@ -195,12 +194,11 @@ object FileStamp { new JsonFormat[Seq[(Path, Hash)]] { override def write[J](obj: Seq[(Path, Hash)], builder: Builder[J]): Unit = { builder.beginArray() - obj.foreach { - case (p, h) => - builder.beginArray() - builder.writeString(p.toString) - builder.writeString(h.hex) - builder.endArray() + obj.foreach { case (p, h) => + builder.beginArray() + builder.writeString(p.toString) + builder.writeString(h.hex) + builder.endArray() } builder.endArray() } @@ -226,12 +224,11 @@ object FileStamp { new JsonFormat[Seq[(Path, LastModified)]] { override def write[J](obj: Seq[(Path, LastModified)], builder: Builder[J]): Unit = { builder.beginArray() - obj.foreach { - case (p, lm) => - builder.beginArray() - builder.writeString(p.toString) - builder.writeLong(lm.time) - builder.endArray() + obj.foreach { case (p, lm) => + builder.beginArray() + builder.writeString(p.toString) + builder.writeLong(lm.time) + builder.endArray() } builder.endArray() } diff --git a/main/src/main/scala/sbt/nio/Keys.scala b/main/src/main/scala/sbt/nio/Keys.scala index 373f23cda..a06179452 100644 --- a/main/src/main/scala/sbt/nio/Keys.scala +++ b/main/src/main/scala/sbt/nio/Keys.scala @@ -133,7 +133,6 @@ object Keys { * watchTriggeredMessage := Watch.clearScreenOnTrigger * }}} * to the build. - * */ val watchTriggeredMessage = settingKey[(Int, Path, Seq[String]) => Option[String]]( "The message to show before triggered execution executes an action after sources change. The parameters are the current watch iteration count, the path that triggered the build and the names of the commands to run." diff --git a/main/src/main/scala/sbt/nio/Watch.scala b/main/src/main/scala/sbt/nio/Watch.scala index 0e235ed13..03108ceda 100644 --- a/main/src/main/scala/sbt/nio/Watch.scala +++ b/main/src/main/scala/sbt/nio/Watch.scala @@ -580,11 +580,17 @@ object Watch { * a build is triggered. */ final val defaultOnTriggerMessage: (Int, Path, Seq[String]) => Option[String] = - ((_: Int, path: Path, commands: Seq[String]) => { - val msg = s"Build triggered by $path. " + - s"Running ${commands.mkString("'", "; ", "'")}." - Some(msg) - }).label("Watched.defaultOnTriggerMessage") + ( + ( + _: Int, + path: Path, + commands: Seq[String] + ) => { + val msg = s"Build triggered by $path. " + + s"Running ${commands.mkString("'", "; ", "'")}." + Some(msg) + } + ).label("Watched.defaultOnTriggerMessage") final val noTriggerMessage: (Int, Path, Seq[String]) => Option[String] = (_, _, _) => None diff --git a/main/src/main/scala/sbt/plugins/DependencyTreeSettings.scala b/main/src/main/scala/sbt/plugins/DependencyTreeSettings.scala index 88ed9d374..533fe6c28 100644 --- a/main/src/main/scala/sbt/plugins/DependencyTreeSettings.scala +++ b/main/src/main/scala/sbt/plugins/DependencyTreeSettings.scala @@ -71,9 +71,8 @@ object DependencyTreeSettings { val sv = scalaVersion.value val g = dependencyTreeIgnoreMissingUpdate.value .configuration(configuration.value) - .map( - report => - SbtUpdateReport.fromConfigurationReport(report, dependencyTreeCrossProjectId.value) + .map(report => + SbtUpdateReport.fromConfigurationReport(report, dependencyTreeCrossProjectId.value) ) .getOrElse(ModuleGraph.empty) if (dependencyTreeIncludeScalaLibrary.value) g @@ -253,24 +252,24 @@ object DependencyTreeSettings { import sbt.internal.util.complete.DefaultParsers._ val artifactPatternParser: Def.Initialize[State => Parser[ArtifactPattern]] = Keys.resolvedScoped { ctx => (state: State) => - val graph = Defaults.loadFromContext(dependencyTreeModuleGraphStore, ctx, state) getOrElse ModuleGraph( - Nil, - Nil - ) + val graph = + Defaults.loadFromContext(dependencyTreeModuleGraphStore, ctx, state) getOrElse ModuleGraph( + Nil, + Nil + ) graph.nodes .map(_.id) .groupBy(m => (m.organization, m.name)) - .map { - case ((org, name), modules) => - val versionParsers: Seq[Parser[Option[String]]] = - modules.map { id => - token(Space ~> id.version).? - } - - (Space ~> token(org) ~ token(Space ~> name) ~ oneOf(versionParsers)).map { - case ((org, name), version) => ArtifactPattern(org, name, version) + .map { case ((org, name), modules) => + val versionParsers: Seq[Parser[Option[String]]] = + modules.map { id => + token(Space ~> id.version).? } + + (Space ~> token(org) ~ token(Space ~> name) ~ oneOf(versionParsers)).map { + case ((org, name), version) => ArtifactPattern(org, name, version) + } } .reduceOption(_ | _) .getOrElse { @@ -278,9 +277,8 @@ object DependencyTreeSettings { ((Space ~> token(StringBasic, "")) ~ (Space ~> token( StringBasic, "" - )) ~ (Space ~> token(StringBasic, "")).?).map { - case ((org, mod), version) => - ArtifactPattern(org, mod, version) + )) ~ (Space ~> token(StringBasic, "")).?).map { case ((org, mod), version) => + ArtifactPattern(org, mod, version) } } } diff --git a/project/Docs.scala b/project/Docs.scala index 0e79269c1..e785e59ff 100644 --- a/project/Docs.scala +++ b/project/Docs.scala @@ -52,5 +52,5 @@ object Docs { IO.copy(toCopy) repo } - */ + */ } diff --git a/project/PublishBinPlugin.scala b/project/PublishBinPlugin.scala index 5e5397c4b..5b7c94e1d 100644 --- a/project/PublishBinPlugin.scala +++ b/project/PublishBinPlugin.scala @@ -45,7 +45,8 @@ object PublishBinPlugin extends AutoPlugin { proj.withPublications(publications) } IvyXml.writeFiles(currentProject, None, ivySbt.value, streams.value.log) - } else + } + else Def.task(()) } ) diff --git a/project/Scripted.scala b/project/Scripted.scala index 7bc7ccb06..fbbcebd0f 100644 --- a/project/Scripted.scala +++ b/project/Scripted.scala @@ -79,13 +79,13 @@ object Scripted { page <- pageP files = pagedFilenames(group, page) // TODO - Fail the parser if we don't have enough files for the given page size - //if !files.isEmpty + // if !files.isEmpty } yield files map (f => s"$group/$f") val testID = (for (group <- groupP; name <- nameP(group)) yield (group, name)) val testIdAsGroup = matched(testID) map (test => Seq(test)) - //(token(Space) ~> matched(testID)).* + // (token(Space) ~> matched(testID)).* (token(Space) ~> (PagedIds | testIdAsGroup)).* map (_.flatten) } diff --git a/project/Transform.scala b/project/Transform.scala index fde66b01c..e6d61676d 100644 --- a/project/Transform.scala +++ b/project/Transform.scala @@ -38,12 +38,11 @@ object Transform { def get(key: String) = props.getOrElse(key, sys.error(s"No value defined for key '$key'")) val Property = """\$\{\{([\w.-]+)\}\}""".r val catcher = scala.util.control.Exception.catching(classOf[java.io.IOException]) - rs.map { - case (in, out) => - val newString = Property.replaceAllIn(IO.read(in), mtch => get(mtch.group(1))) - if (Some(newString) != catcher.opt(IO.read(out))) - IO.write(out, newString) - out + rs.map { case (in, out) => + val newString = Property.replaceAllIn(IO.read(in), mtch => get(mtch.group(1))) + if (Some(newString) != catcher.opt(IO.read(out))) + IO.write(out, newString) + out } }.taskValue, ) diff --git a/project/Util.scala b/project/Util.scala index cf8b75cc8..b32a9ee11 100644 --- a/project/Util.scala +++ b/project/Util.scala @@ -93,7 +93,9 @@ object Util { val f = dir / "xsbt.version.properties" // TODO: replace lastModified() with sbt.io.IO.getModifiedTimeOrZero(), once the build // has been upgraded to a version of sbt that includes that call. - if (!f.exists || f.lastModified < lastCompilationTime(analysis) || !containsVersion(f, version)) { + if ( + !f.exists || f.lastModified < lastCompilationTime(analysis) || !containsVersion(f, version) + ) { s.log.info("Writing version information to " + f + " :\n" + content) IO.write(f, content) }