Upgrade scalariform version

This commit is contained in:
Dale Wijnand 2016-11-24 14:12:23 +00:00
parent 6a46c62524
commit 43821667bf
No known key found for this signature in database
GPG Key ID: 4F256E3D151DF5EF
56 changed files with 469 additions and 371 deletions

View File

@ -74,7 +74,8 @@ object CacheIvy {
implicit def moduleReportFormat(implicit cf: Format[Seq[Caller]], ff: Format[File]): Format[ModuleReport] = {
wrap[ModuleReport, (ModuleID, Seq[(Artifact, File)], Seq[Artifact], Option[String], Option[Long], Option[String], Option[String], Boolean, Option[String], Option[String], Option[String], Option[String], Map[String, String], Option[Boolean], Option[String], Seq[String], Seq[(String, Option[String])], Seq[Caller])](
m => (m.module, m.artifacts, m.missingArtifacts, m.status, m.publicationDate map { _.getTime }, m.resolver, m.artifactResolver, m.evicted, m.evictedData, m.evictedReason, m.problem, m.homepage, m.extraAttributes, m.isDefault, m.branch, m.configurations, m.licenses, m.callers),
{ case (m, as, ms, s, pd, r, a, e, ed, er, p, h, ea, d, b, cs, ls, ks) => new ModuleReport(m, as, ms, s, pd map { new ju.Date(_) }, r, a, e, ed, er, p, h, ea, d, b, cs, ls, ks) })
{ case (m, as, ms, s, pd, r, a, e, ed, er, p, h, ea, d, b, cs, ls, ks) => new ModuleReport(m, as, ms, s, pd map { new ju.Date(_) }, r, a, e, ed, er, p, h, ea, d, b, cs, ls, ks) }
)
}
implicit def artifactFormat(implicit sf: Format[String], uf: Format[Option[URL]]): Format[Artifact] = {
wrap[Artifact, (String, String, String, Option[String], Seq[Configuration], Option[URL], Map[String, String])](
@ -85,8 +86,10 @@ object CacheIvy {
implicit def organizationArtifactReportFormat(implicit sf: Format[String], bf: Format[Boolean], df: Format[Seq[ModuleReport]]): Format[OrganizationArtifactReport] =
wrap[OrganizationArtifactReport, (String, String, Seq[ModuleReport])](m => (m.organization, m.name, m.modules), { case (o, n, r) => OrganizationArtifactReport(o, n, r) })
implicit def callerFormat: Format[Caller] =
wrap[Caller, (ModuleID, Seq[String], Map[String, String], Boolean, Boolean, Boolean, Boolean)](c => (c.caller, c.callerConfigurations, c.callerExtraAttributes, c.isForceDependency, c.isChangingDependency, c.isTransitiveDependency, c.isDirectlyForceDependency),
{ case (c, cc, ea, fd, cd, td, df) => new Caller(c, cc, ea, fd, cd, td, df) })
wrap[Caller, (ModuleID, Seq[String], Map[String, String], Boolean, Boolean, Boolean, Boolean)](
c => (c.caller, c.callerConfigurations, c.callerExtraAttributes, c.isForceDependency, c.isChangingDependency, c.isTransitiveDependency, c.isDirectlyForceDependency),
{ case (c, cc, ea, fd, cd, td, df) => new Caller(c, cc, ea, fd, cd, td, df) }
)
implicit def exclusionRuleFormat(implicit sf: Format[String]): Format[InclExclRule] =
wrap[InclExclRule, (String, String, String, Seq[String])](e => (e.organization, e.name, e.artifact, e.configurations), { case (o, n, a, cs) => InclExclRule(o, n, a, cs) })
implicit def crossVersionFormat: Format[CrossVersion] = wrap(crossToInt, crossFromInt)

View File

@ -24,11 +24,13 @@ object Doc {
def javadoc(label: String, cache: File, doc: JavaTools, log: Logger, reporter: Reporter): Gen =
javadoc(label, cache, doc, log, reporter, Seq())
def javadoc(label: String, cache: File, doc: JavaTools, log: Logger, reporter: Reporter, fileInputOptions: Seq[String]): Gen =
cached(cache, fileInputOptions, prepare(label + " Java API documentation", filterSources(javaSourcesOnly,
cached(cache, fileInputOptions, prepare(label + " Java API documentation", filterSources(
javaSourcesOnly,
(sources: Seq[File], classpath: Seq[File], outputDirectory: File, options: Seq[String], maxErrors: Int, log: Logger) => {
// doc.doc
???
})))
}
)))
val javaSourcesOnly: File => Boolean = _.getName.endsWith(".java")

View File

@ -77,7 +77,8 @@ object TestResultLogger {
printSummary: TestResultLogger = Defaults.printSummary,
printStandard: TestResultLogger = Defaults.printStandard,
printFailures: TestResultLogger = Defaults.printFailures,
printNoTests: TestResultLogger = Defaults.printNoTests) extends TestResultLogger {
printNoTests: TestResultLogger = Defaults.printNoTests
) extends TestResultLogger {
override def run(log: Logger, results: Output, taskName: String): Unit = {
def run(r: TestResultLogger): Unit = r.run(log, results, taskName)
@ -154,7 +155,6 @@ object TestResultLogger {
})
val printNoTests = TestResultLogger((log, results, taskName) =>
log.info("No tests to run for " + taskName)
)
log.info("No tests to run for " + taskName))
}
}

View File

@ -120,7 +120,8 @@ object Tests {
val tests: Seq[TestDefinition],
val setup: Seq[ClassLoader => Unit],
val cleanup: Seq[ClassLoader => Unit],
val testListeners: Seq[TestReportListener])
val testListeners: Seq[TestReportListener]
)
private[sbt] def processOptions(config: Execution, discovered: Seq[TestDefinition], log: Logger): ProcessedOptions =
{
import collection.mutable.{ HashSet, ListBuffer }

View File

@ -55,7 +55,8 @@ class CacheIvyTest extends Properties("CacheIvy") {
} yield ModuleID(
organization = o, name = n, revision = r, configurations = cs, isChanging = isChanging, isTransitive = isTransitive,
isForce = isForce, explicitArtifacts = explicitArtifacts, inclusions = inclusions, exclusions = exclusions,
extraAttributes = extraAttributes, crossVersion = crossVersion, branchName = branch)
extraAttributes = extraAttributes, crossVersion = crossVersion, branchName = branch
)
}
property("moduleIDFormat") = forAll { (m: ModuleID) =>

View File

@ -32,7 +32,8 @@ final case class State(
history: State.History,
attributes: AttributeMap,
globalLogging: GlobalLogging,
next: State.Next) extends Identity {
next: State.Next
) extends Identity {
lazy val combinedParser = Command.combine(definedCommands)(this)
}

View File

@ -38,7 +38,6 @@ private[sbt] final class NetworkChannel extends CommandChannel {
server.publish(
if (cmdStatus.canEnter) StatusEvent(Ready)
else StatusEvent(Processing("TODO current command", cmdStatus.state.remainingCommands))
)
)
))
}
}

View File

@ -24,21 +24,29 @@ object Serialization {
def toMessage(event: Event): EventMessage =
event match {
case LogEvent(level, message) =>
EventMessage(`type` = "logEvent",
EventMessage(
`type` = "logEvent",
status = None, commandQueue = Vector(),
level = Some(level), message = Some(message), success = None, commandLine = None)
level = Some(level), message = Some(message), success = None, commandLine = None
)
case StatusEvent(Ready) =>
EventMessage(`type` = "statusEvent",
EventMessage(
`type` = "statusEvent",
status = Some("ready"), commandQueue = Vector(),
level = None, message = None, success = None, commandLine = None)
level = None, message = None, success = None, commandLine = None
)
case StatusEvent(Processing(command, commandQueue)) =>
EventMessage(`type` = "statusEvent",
EventMessage(
`type` = "statusEvent",
status = Some("processing"), commandQueue = commandQueue.toVector,
level = None, message = None, success = None, commandLine = None)
level = None, message = None, success = None, commandLine = None
)
case ExecutionEvent(command, status) =>
EventMessage(`type` = "executionEvent",
EventMessage(
`type` = "executionEvent",
status = None, commandQueue = Vector(),
level = None, message = None, success = Some(status), commandLine = Some(command))
level = None, message = None, success = Some(status), commandLine = Some(command)
)
}
/**

View File

@ -20,8 +20,7 @@ final class InputTask[T] private (val parser: State => Parser[Task[T]]) {
case Left(msg) =>
val indented = msg.lines.map(" " + _).mkString("\n")
Parser.failure(s"Invalid programmatic input:\n$indented")
}
)
})
}
object InputTask {
@ -38,9 +37,7 @@ object InputTask {
case Left(msg) =>
val indented = msg.lines.map(" " + _).mkString("\n")
sys.error(s"Invalid programmatic input:\n$indented")
}
)
)
}))
)
}

View File

@ -142,7 +142,8 @@ object Scope {
projectInherit: ProjectRef => Seq[ProjectRef],
configInherit: (ResolvedReference, ConfigKey) => Seq[ConfigKey],
taskInherit: AttributeKey[_] => Seq[AttributeKey[_]],
extraInherit: (ResolvedReference, AttributeMap) => Seq[AttributeMap]): Scope => Seq[Scope] =
extraInherit: (ResolvedReference, AttributeMap) => Seq[AttributeMap]
): Scope => Seq[Scope] =
{
val index = delegates(refs, configurations, projectInherit, configInherit)
scope => indexedDelegates(resolve, index, rootProject, taskInherit, extraInherit)(scope)
@ -153,7 +154,8 @@ object Scope {
index: DelegateIndex,
rootProject: URI => String,
taskInherit: AttributeKey[_] => Seq[AttributeKey[_]],
extraInherit: (ResolvedReference, AttributeMap) => Seq[AttributeMap])(rawScope: Scope): Seq[Scope] =
extraInherit: (ResolvedReference, AttributeMap) => Seq[AttributeMap]
)(rawScope: Scope): Seq[Scope] =
{
val scope = Scope.replaceThis(GlobalScope)(rawScope)
@ -190,7 +192,8 @@ object Scope {
refs: Seq[(ProjectRef, Proj)],
configurations: Proj => Seq[ConfigKey],
projectInherit: ProjectRef => Seq[ProjectRef],
configInherit: (ResolvedReference, ConfigKey) => Seq[ConfigKey]): DelegateIndex =
configInherit: (ResolvedReference, ConfigKey) => Seq[ConfigKey]
): DelegateIndex =
{
val pDelegates = refs map {
case (ref, project) =>

View File

@ -199,7 +199,7 @@ object ParserInput {
private def wrapInitInputTask[T: c.WeakTypeTag](c: blackbox.Context)(tree: c.Tree, pos: c.Position) = {
val e = c.Expr[Initialize[InputTask[T]]](tree)
wrapInit[Task[T]](c)(c.universe.reify {Def.toIParser(e.splice)}, pos)
wrapInit[Task[T]](c)(c.universe.reify { Def.toIParser(e.splice) }, pos)
}
/** Implements `Parser[T].parsed` by wrapping the Parser with the ParserInput wrapper.*/
@ -216,12 +216,12 @@ object ParserInput {
private def wrapParser[T: c.WeakTypeTag](c: blackbox.Context)(tree: c.Tree, pos: c.Position) = {
val e = c.Expr[Parser[T]](tree)
wrap[T](c)(c.universe.reify {Def.toSParser(e.splice)}, pos)
wrap[T](c)(c.universe.reify { Def.toSParser(e.splice) }, pos)
}
private def wrapInitParser[T: c.WeakTypeTag](c: blackbox.Context)(tree: c.Tree, pos: c.Position) = {
val e = c.Expr[Initialize[Parser[T]]](tree)
val es = c.universe.reify {Def.toISParser(e.splice)}
val es = c.universe.reify { Def.toISParser(e.splice) }
wrapInit[T](c)(es, pos)
}

View File

@ -54,9 +54,7 @@ object FullInstance extends Instance.Composed[Initialize, Task](InitializeInstan
def flattenFun[S, T](in: Initialize[Task[S => Initialize[Task[T]]]]): Initialize[S => Task[T]] =
{
import Scoped._
(in, settingsData, Def.capturedTransformations) apply {
(a: Task[S => Initialize[Task[T]]], data: Task[SS], f) =>
(s: S) =>
(in, settingsData, Def.capturedTransformations) apply { (a: Task[S => Initialize[Task[T]]], data: Task[SS], f) => (s: S) =>
import TaskExtra.multT2Task
(a, data) flatMap { case (af, d) => f(af(s)) evaluate d }
}

View File

@ -265,7 +265,8 @@ object Defaults extends BuildCommon {
def compileBase = inTask(console)(compilersSetting :: Nil) ++ compileBaseGlobal ++ Seq(
incOptions := incOptions.value.withClassfileManagerType(
Maybe.just(new TransactionalManagerType(crossTarget.value / "classes.bak", sbt.util.Logger.Null))),
Maybe.just(new TransactionalManagerType(crossTarget.value / "classes.bak", sbt.util.Logger.Null))
),
scalaInstance := scalaInstanceTask.value,
crossVersion := (if (crossPaths.value) CrossVersion.binary else CrossVersion.Disabled),
crossTarget := makeCrossTarget(target.value, scalaBinaryVersion.value, sbtBinaryVersion.value, sbtPlugin.value, crossPaths.value),
@ -678,7 +679,8 @@ object Defaults extends BuildCommon {
}
)) ++
inTask(packageSrc)(Seq(
packageOptions := Package.addSpecManifestAttributes(name.value, version.value, organizationName.value) +: packageOptions.value)) ++
packageOptions := Package.addSpecManifestAttributes(name.value, version.value, organizationName.value) +: packageOptions.value
)) ++
packageTaskSettings(packageBin, packageBinMappings) ++
packageTaskSettings(packageSrc, packageSrcMappings) ++
packageTaskSettings(packageDoc, packageDocMappings) ++
@ -947,7 +949,8 @@ object Defaults extends BuildCommon {
(compilerReporter in compile).value,
o2m(None),
// TODO - task / setting for extra,
Array.empty)
Array.empty
)
}
def compileInputsSettings: Seq[Setting[_]] = {
Seq(
@ -959,13 +962,15 @@ object Defaults extends BuildCommon {
javacOptions.value.toArray,
maxErrors.value,
f1(Compiler.foldMappers(sourcePositionMappers.value)),
compileOrder.value),
compileOrder.value
),
compilerReporter := new LoggerReporter(maxErrors.value, streams.value.log, Compiler.foldMappers(sourcePositionMappers.value)),
compileInputs := new Inputs(
compilers.value,
compileOptions.value,
compileIncSetup.value,
previousCompile.value)
previousCompile.value
)
)
}
def compileAnalysisSettings: Seq[Setting[_]] = Seq(

View File

@ -11,8 +11,16 @@ import sbt.librarymanagement.{ Resolver, UpdateReport }
import scala.concurrent.duration.Duration
import java.io.File
import Def.{ dummyState, ScopedKey, Setting }
import Keys.{ Streams, TaskStreams, dummyRoots, executionRoots, pluginData, streams,
streamsManager, transformState }
import Keys.{
Streams,
TaskStreams,
dummyRoots,
executionRoots,
pluginData,
streams,
streamsManager,
transformState
}
import Project.richInitializeTask
import Scope.GlobalScope
import scala.Console.RED
@ -97,21 +105,25 @@ sealed trait EvaluateTaskConfig {
}
object EvaluateTaskConfig {
@deprecated("Use the alternative that specifies minForcegcInterval", "0.13.9")
def apply(restrictions: Seq[Tags.Rule],
def apply(
restrictions: Seq[Tags.Rule],
checkCycles: Boolean,
progressReporter: ExecuteProgress[Task],
cancelStrategy: TaskCancellationStrategy,
forceGarbageCollection: Boolean): EvaluateTaskConfig =
forceGarbageCollection: Boolean
): EvaluateTaskConfig =
apply(restrictions, checkCycles, progressReporter, cancelStrategy, forceGarbageCollection,
GCUtil.defaultMinForcegcInterval)
/** Raw constructor for EvaluateTaskConfig. */
def apply(restrictions: Seq[Tags.Rule],
def apply(
restrictions: Seq[Tags.Rule],
checkCycles: Boolean,
progressReporter: ExecuteProgress[Task],
cancelStrategy: TaskCancellationStrategy,
forceGarbageCollection: Boolean,
minForcegcInterval: Duration): EvaluateTaskConfig = {
minForcegcInterval: Duration
): EvaluateTaskConfig = {
val r = restrictions
val check = checkCycles
val cs = cancelStrategy

View File

@ -63,7 +63,8 @@ final case class Extracted(structure: BuildStructure, session: SessionSettings,
import EvaluateTask._
val scopedKey = Scoped.scopedSetting(
Scope.resolveScope(Load.projectScope(currentRef), currentRef.build, structure.rootProject)(key.scope), key.key)
Scope.resolveScope(Load.projectScope(currentRef), currentRef.build, structure.rootProject)(key.scope), key.key
)
val rkey = resolve(scopedKey.scopedKey)
val inputTask = get(Scoped.scopedSetting(rkey.scope, rkey.key))
val task = Parser.parse(input, inputTask.parser(state)) match {

View File

@ -31,9 +31,11 @@ object LogManager {
def withScreenLogger(mk: (ScopedKey[_], State) => AbstractLogger): LogManager = withLoggers(screen = mk)
def withLoggers(screen: (ScopedKey[_], State) => AbstractLogger = (sk, s) => defaultScreen(s.globalLogging.console),
def withLoggers(
screen: (ScopedKey[_], State) => AbstractLogger = (sk, s) => defaultScreen(s.globalLogging.console),
backed: PrintWriter => AbstractLogger = defaultBacked(),
extra: ScopedKey[_] => Seq[AbstractLogger] = _ => Nil): LogManager = new LogManager {
extra: ScopedKey[_] => Seq[AbstractLogger] = _ => Nil
): LogManager = new LogManager {
def apply(data: Settings[Scope], state: State, task: ScopedKey[_], to: PrintWriter): Logger =
defaultLogger(data, state, task, screen(task, state), backed(to), extra(task).toList)
}

View File

@ -49,28 +49,31 @@ final class xMain extends xsbti.AppMain {
import BasicCommandStrings.runEarly
import BuiltinCommands.defaults
import sbt.internal.CommandStrings.{ BootCommand, DefaultsCommand, InitCommand }
runManaged(initialState(configuration,
runManaged(initialState(
configuration,
Seq(defaults, early),
runEarly(DefaultsCommand) :: runEarly(InitCommand) :: BootCommand :: Nil)
)
runEarly(DefaultsCommand) :: runEarly(InitCommand) :: BootCommand :: Nil
))
}
}
final class ScriptMain extends xsbti.AppMain {
def run(configuration: xsbti.AppConfiguration): xsbti.MainResult =
{
import BasicCommandStrings.runEarly
runManaged(initialState(configuration,
runManaged(initialState(
configuration,
BuiltinCommands.ScriptCommands,
runEarly(Level.Error.toString) :: Script.Name :: Nil)
)
runEarly(Level.Error.toString) :: Script.Name :: Nil
))
}
}
final class ConsoleMain extends xsbti.AppMain {
def run(configuration: xsbti.AppConfiguration): xsbti.MainResult =
runManaged(initialState(configuration,
runManaged(initialState(
configuration,
BuiltinCommands.ConsoleCommands,
IvyConsole.Name :: Nil)
)
IvyConsole.Name :: Nil
))
}
object StandardMain {

View File

@ -7,8 +7,8 @@ TODO:
import sbt.librarymanagement.Configuration
import sbt.internal.util.logic.{Atom, Clause, Clauses, Formula, Literal, Logic, Negated}
import Logic.{CyclicNegation, InitialContradictions, InitialOverlap, LogicException}
import sbt.internal.util.logic.{ Atom, Clause, Clauses, Formula, Literal, Logic, Negated }
import Logic.{ CyclicNegation, InitialContradictions, InitialOverlap, LogicException }
import Def.Setting
import Plugins._
import annotation.tailrec
@ -60,16 +60,19 @@ import sbt.util.Logger
* then the `MyPlugin` settings (and anything that activates only when `MyPlugin` is activated) will not be added.
*/
abstract class AutoPlugin extends Plugins.Basic with PluginsFunctions {
/** Determines whether this AutoPlugin will be activated for this project when the `requires` clause is satisfied.
/**
* Determines whether this AutoPlugin will be activated for this project when the `requires` clause is satisfied.
*
* When this method returns `allRequirements`, and `requires` method returns `Web && Javascript`, this plugin
* instance will be added automatically if the `Web` and `Javascript` plugins are enabled.
*
* When this method returns `noTrigger`, and `requires` method returns `Web && Javascript`, this plugin
* instance will be added only if the build user enables it, but it will automatically add both `Web` and `Javascript`. */
* instance will be added only if the build user enables it, but it will automatically add both `Web` and `Javascript`.
*/
def trigger: PluginTrigger = noTrigger
/** This AutoPlugin requires the plugins the [[Plugins]] matcher returned by this method. See [[trigger]].
/**
* This AutoPlugin requires the plugins the [[Plugins]] matcher returned by this method. See [[trigger]].
*/
def requires: Plugins = plugins.JvmPlugin
@ -83,9 +86,11 @@ abstract class AutoPlugin extends Plugins.Basic with PluginsFunctions {
/** The [[Setting]]s to add in the scope of each project that activates this AutoPlugin. */
def projectSettings: Seq[Setting[_]] = Nil
/** The [[Setting]]s to add to the build scope for each project that activates this AutoPlugin.
/**
* The [[Setting]]s to add to the build scope for each project that activates this AutoPlugin.
* The settings returned here are guaranteed to be added to a given build scope only once
* regardless of how many projects for that build activate this AutoPlugin. */
* regardless of how many projects for that build activate this AutoPlugin.
*/
def buildSettings: Seq[Setting[_]] = Nil
/** The [[Setting]]s to add to the global scope exactly once if any project activates this AutoPlugin. */
@ -101,7 +106,6 @@ abstract class AutoPlugin extends Plugins.Basic with PluginsFunctions {
private[sbt] def unary_! : Exclude = Exclude(this)
/** If this plugin does not have any requirements, it means it is actually a root plugin. */
private[sbt] final def isRoot: Boolean =
requires match {
@ -114,9 +118,11 @@ abstract class AutoPlugin extends Plugins.Basic with PluginsFunctions {
isRoot && (trigger == AllRequirements)
}
/** An error that occurs when auto-plugins aren't configured properly.
* It translates the error from the underlying logic system to be targeted at end users. */
final class AutoPluginException private(val message: String, val origin: Option[LogicException]) extends RuntimeException(message) {
/**
* An error that occurs when auto-plugins aren't configured properly.
* It translates the error from the underlying logic system to be targeted at end users.
*/
final class AutoPluginException private (val message: String, val origin: Option[LogicException]) extends RuntimeException(message) {
/** Prepends `p` to the error message derived from `origin`. */
def withPrefix(p: String) = new AutoPluginException(p + message, origin)
}
@ -131,10 +137,9 @@ case object NoTrigger extends PluginTrigger
/** An expression that matches `AutoPlugin`s. */
sealed trait Plugins {
def && (o: Basic): Plugins
def &&(o: Basic): Plugins
}
sealed trait PluginsFunctions {
/** [[Plugins]] instance that doesn't require any [[Plugins]]s. */
def empty: Plugins = Plugins.Empty
@ -146,10 +151,12 @@ sealed trait PluginsFunctions {
}
object Plugins extends PluginsFunctions {
/** Given the available auto plugins `defined`, returns a function that selects [[AutoPlugin]]s for the provided [[AutoPlugin]]s.
* The [[AutoPlugin]]s are topologically sorted so that a required [[AutoPlugin]] comes before its requiring [[AutoPlugin]].*/
/**
* Given the available auto plugins `defined`, returns a function that selects [[AutoPlugin]]s for the provided [[AutoPlugin]]s.
* 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
@ -159,7 +166,7 @@ object Plugins extends PluginsFunctions {
val byAtom = defined map { x => (Atom(x.label), x) }
val byAtomMap = byAtom.toMap
if(byAtom.size != byAtomMap.size) duplicateProvidesError(byAtom)
if (byAtom.size != byAtomMap.size) duplicateProvidesError(byAtom)
// Ignore clauses for plugins that does not require anything else.
// Avoids the requirement for pure Nature strings *and* possible
// circular dependencies in the logic.
@ -186,7 +193,7 @@ object Plugins extends PluginsFunctions {
val forbidden: Set[AutoPlugin] = (selectedPlugins flatMap { Plugins.asExclusions }).toSet
val c = selectedPlugins.toSet & forbidden
if (c.nonEmpty) {
exlusionConflictError(requestedPlugins, selectedPlugins, c.toSeq sortBy {_.label})
exlusionConflictError(requestedPlugins, selectedPlugins, c.toSeq sortBy { _.label })
}
val retval = topologicalSort(selectedPlugins, log)
log.debug(s" :: sorted deduced result: ${retval.toString}")
@ -214,13 +221,12 @@ object Plugins extends PluginsFunctions {
case cn: CyclicNegation => s"Cycles in plugin requirements cannot involve excludes. The problematic cycle is: ${literalsString(cn.cycle)}"
}
private[this] def literalsString(lits: Seq[Literal]): String =
lits map { case Atom(l) => l; case Negated(Atom(l)) => l } mkString(", ")
lits map { case Atom(l) => l; case Negated(Atom(l)) => l } mkString (", ")
private[this] def duplicateProvidesError(byAtom: Seq[(Atom, AutoPlugin)]): Unit = {
val dupsByAtom = byAtom.groupBy(_._1).mapValues(_.map(_._2))
val dupStrings = for( (atom, dups) <- dupsByAtom if dups.size > 1 ) yield
s"${atom.label} by ${dups.mkString(", ")}"
val (ns, nl) = if(dupStrings.size > 1) ("s", "\n\t") else ("", " ")
val dupStrings = for ((atom, dups) <- dupsByAtom if dups.size > 1) yield s"${atom.label} by ${dups.mkString(", ")}"
val (ns, nl) = if (dupStrings.size > 1) ("s", "\n\t") else ("", " ")
val message = s"Plugin$ns provided by multiple AutoPlugins:$nl${dupStrings.mkString(nl)}"
throw AutoPluginException(message)
}
@ -271,22 +277,22 @@ ${listConflicts(conflicting)}""")
case b: Basic => a && b
}
private[sbt] def remove(a: Plugins, del: Set[Basic]): Plugins = a match {
case b: Basic => if(del(b)) Empty else b
case b: Basic => if (del(b)) Empty else b
case Empty => Empty
case And(ns) =>
val removed = ns.filterNot(del)
if(removed.isEmpty) Empty else And(removed)
if (removed.isEmpty) Empty else And(removed)
}
/** Defines enabled-by clauses for `ap`. */
private[sbt] def asEnabledByClauses(ap: AutoPlugin): List[Clause] =
// `ap` is the head and the required plugins for `ap` is the body.
if (ap.trigger == AllRequirements) Clause( convert(ap.requires), Set(Atom(ap.label)) ) :: Nil
if (ap.trigger == AllRequirements) Clause(convert(ap.requires), Set(Atom(ap.label))) :: Nil
else Nil
/** Defines requirements clauses for `ap`. */
private[sbt] def asRequirementsClauses(ap: AutoPlugin): List[Clause] =
// required plugin is the head and `ap` is the body.
asRequirements(ap) map { x => Clause( convert(ap), Set(Atom(x.label)) ) }
asRequirements(ap) map { x => Clause(convert(ap), Set(Atom(x.label))) }
private[sbt] def asRequirements(ap: AutoPlugin): List[AutoPlugin] = flatten(ap.requires).toList collect {
case x: AutoPlugin => x
}
@ -342,7 +348,7 @@ ${listConflicts(conflicting)}""")
}
private[sbt] def hasAutoImportGetter(ap: AutoPlugin, loader: ClassLoader): Boolean = {
import reflect.runtime.{universe => ru}
import reflect.runtime.{ universe => ru }
import scala.util.control.Exception.catching
val m = ru.runtimeMirror(loader)
val im = m.reflect(ap)

View File

@ -94,16 +94,17 @@ sealed trait Project extends ProjectDefinition[ProjectReference] {
private[sbt] def delegatesEval: Eval[Seq[ProjectReference]]
private[sbt] def dependenciesEval: Eval[Seq[ClasspathDep[ProjectReference]]]
// TODO: add parameters for plugins in 0.14.0 (not reasonable to do in a binary compatible way in 0.13)
private[sbt] def copy(id: String = id,
private[sbt] def copy(
id: String = id,
base: File = base,
aggregateEval: Eval[Seq[ProjectReference]] = aggregateEval,
dependenciesEval: Eval[Seq[ClasspathDep[ProjectReference]]] = dependenciesEval,
delegatesEval: Eval[Seq[ProjectReference]] = delegatesEval,
settingsEval: Eval[Seq[Setting[_]]] = settingsEval,
configurations: Seq[Configuration] = configurations,
auto: AddSettings = auto): Project =
auto: AddSettings = auto
): Project =
unresolved(id, base,
aggregateEval = aggregateEval,
dependenciesEval = dependenciesEval,
@ -280,7 +281,8 @@ object Project extends ProjectExtra {
val auto: AddSettings,
val plugins: Plugins,
val autoPlugins: Seq[AutoPlugin],
val projectOrigin: ProjectOrigin) extends ProjectDefinition[PR] {
val projectOrigin: ProjectOrigin
) extends ProjectDefinition[PR] {
def aggregate: Seq[PR] = aggregateEval.get
def dependencies: Seq[ClasspathDep[PR]] = dependenciesEval.get
def delegates: Seq[PR] = delegatesEval.get
@ -665,7 +667,6 @@ trait ProjectExtra extends ProjectExtra0 {
implicit def configDependencyConstructor[T](p: T)(implicit ev: T => ProjectReference): Constructor = new Constructor(p)
implicit def classpathDependency[T](p: T)(implicit ev: T => ProjectReference): ClasspathDep[ProjectReference] = new ClasspathDependency(p, None)
// These used to be in Project so that they didn't need to get imported (due to Initialize being nested in Project).
// Moving Initialize and other settings types to Def and decoupling Project, Def, and Structure means these go here for now
implicit def richInitializeTask[T](init: Initialize[Task[T]]): Scoped.RichInitializeTask[T] = new Scoped.RichInitializeTask(init)

View File

@ -28,8 +28,7 @@ object SessionVar {
def persist[T](key: ScopedKey[Task[T]], state: State, value: T)(implicit f: sbinary.Format[T]): Unit =
Project.structure(state).streams(state).use(key)(s =>
Operations.write(s.binary(DefaultDataID), value)(f)
)
Operations.write(s.binary(DefaultDataID), value)(f))
def clear(s: State): State = s.put(sessionVars, SessionVar.emptyMap)

View File

@ -253,8 +253,7 @@ object Act {
def evaluate(kvs: Seq[ScopedKey[_]]): Parser[() => State] = {
val preparedPairs = anyKeyValues(structure, kvs)
val showConfig = Aggregation.defaultShow(state, showTasks = action == ShowAction)
evaluatingParser(state, structure, showConfig)(preparedPairs) map { evaluate =>
() => {
evaluatingParser(state, structure, showConfig)(preparedPairs) map { evaluate => () => {
val keyStrings = preparedPairs.map(pp => showKey(pp.key)).mkString(", ")
state.log.debug("Evaluating tasks: " + keyStrings)
evaluate()

View File

@ -150,8 +150,7 @@ object Aggregation {
} else {
val base = if (tasks.isEmpty) success(() => s) else
applyTasks(s, structure, maps(tasks)(x => success(castToAny(x))), show)
base.map { res =>
() =>
base.map { res => () =>
val newState = res()
if (show.settingValues && settings.nonEmpty) printSettings(settings, show.print)
newState
@ -169,8 +168,7 @@ object Aggregation {
{
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)
)
if (reverse) extra.aggregates.reverse(ref) else extra.aggregates.forward(ref))
}
def aggregate[T, Proj](key: ScopedKey[T], rawMask: ScopeMask, extra: BuildUtil[Proj], reverse: Boolean = false): Seq[ScopedKey[T]] =

View File

@ -105,23 +105,22 @@ final class BuildLoader(
val builders: MultiHandler[BuildInfo, () => BuildUnit],
val transformer: Transformer,
val full: MultiHandler[LoadInfo, () => BuildUnit],
val transformAll: TransformAll) {
val transformAll: TransformAll
) {
def addNonRoot(uri: URI, loaders: Components): BuildLoader =
new BuildLoader(fail, state, config,
resolvers.addNonRoot(uri, loaders.resolver),
builders.addNonRoot(uri, loaders.builder),
seq(transformer, loaders.transformer),
full.addNonRoot(uri, loaders.full),
transformAll andThen loaders.transformAll
)
transformAll andThen loaders.transformAll)
def setRoot(loaders: Components): BuildLoader =
new BuildLoader(fail, state, config,
resolvers.setRoot(loaders.resolver),
builders.setRoot(loaders.builder),
seq(loaders.transformer, transformer),
full.setRoot(loaders.full),
loaders.transformAll andThen transformAll
)
loaders.transformAll andThen transformAll)
def resetPluginDepth: BuildLoader = copyWithNewPM(config.pluginManagement.resetDepth)
def updatePluginManagement(overrides: Set[ModuleID]): BuildLoader =

View File

@ -30,7 +30,8 @@ final class StructureIndex(
val taskToKey: Map[Task[_], ScopedKey[Task[_]]],
val triggers: Triggers[Task],
val keyIndex: KeyIndex,
val aggregateKeyIndex: KeyIndex)
val aggregateKeyIndex: KeyIndex
)
/**
* A resolved build unit. (`ResolvedBuildUnit` would be a better name to distinguish it from the loaded, but unresolved `BuildUnit`.)
@ -92,13 +93,16 @@ final class LoadedDefinitions(
val builds: Seq[BuildDef],
val projects: Seq[Project],
val buildNames: Seq[String],
val dslDefinitions: DefinedSbtValues) {
def this(base: File,
val dslDefinitions: DefinedSbtValues
) {
def this(
base: File,
target: Seq[File],
loader: ClassLoader,
builds: Seq[BuildDef],
projects: Seq[Project],
buildNames: Seq[String]) = this(base, target, loader, builds, projects, buildNames, DefinedSbtValues.empty)
buildNames: Seq[String]
) = this(base, target, loader, builds, projects, buildNames, DefinedSbtValues.empty)
}
/** Auto-detected top-level modules (as in `object X`) of type `T` paired with their source names. */

View File

@ -12,7 +12,8 @@ final class BuildUtil[Proj](
val rootProjectID: URI => String,
val project: (URI, String) => Proj,
val configurations: Proj => Seq[ConfigKey],
val aggregates: Relation[ProjectRef, ProjectRef]) {
val aggregates: Relation[ProjectRef, ProjectRef]
) {
def rootProject(uri: URI): Proj =
project(uri, rootProjectID(uri))

View File

@ -181,11 +181,13 @@ private[sbt] object EvaluateConfigurations {
case e: sbt.compiler.EvalException => throw new MessageOnlyException(e.getMessage)
}
// TODO - keep track of configuration classes defined.
TrackedEvalResult(result.generated,
TrackedEvalResult(
result.generated,
loader => {
val pos = RangePosition(name, range shift 1)
result.getValue(loader).asInstanceOf[DslEntry].withPos(pos)
})
}
)
}
/**

View File

@ -16,9 +16,24 @@ import sbt.internal.inc.{ Analysis, ClasspathOptionsUtil, ModuleUtilities }
import sbt.internal.inc.classpath.ClasspathUtilities
import Project.inScope
import Def.{ isDummy, ScopedKey, ScopeLocal, Setting }
import Keys.{ appConfiguration, baseDirectory, configuration, exportedProducts, fullClasspath, fullResolvers,
loadedBuild, onLoadMessage, pluginData, resolvedScoped, sbtPlugin, scalacOptions, streams,
thisProject, thisProjectRef, update }
import Keys.{
appConfiguration,
baseDirectory,
configuration,
exportedProducts,
fullClasspath,
fullResolvers,
loadedBuild,
onLoadMessage,
pluginData,
resolvedScoped,
sbtPlugin,
scalacOptions,
streams,
thisProject,
thisProjectRef,
update
}
import tools.nsc.reporters.ConsoleReporter
import sbt.internal.util.{ Attributed, Eval => Ev, Settings, Show, ~> }
import sbt.internal.util.Attributed.data
@ -437,7 +452,7 @@ private[sbt] object Load {
val plugs = plugins(defDir, s, config.copy(pluginManagement = config.pluginManagement.forPlugin))
val defsScala = plugs.detected.builds.values
val buildLevelExtraProjects = plugs.detected.autoPlugins flatMap { d =>
d.value.extraProjects map {_.setProjectOrigin(ProjectOrigin.ExtraProject)}
d.value.extraProjects map { _.setProjectOrigin(ProjectOrigin.ExtraProject) }
}
// NOTE - because we create an eval here, we need a clean-eval later for this URI.
@ -547,7 +562,8 @@ private[sbt] object Load {
makeOrDiscoverRoot: Boolean,
buildUri: URI,
context: PluginManagement.Context,
generatedConfigClassFiles: Seq[File]): LoadedProjects =
generatedConfigClassFiles: Seq[File]
): LoadedProjects =
{
// load all relevant configuration files (.sbt, as .scala already exists at this point)
def discover(auto: AddSettings, base: File): DiscoveredProjects =
@ -567,7 +583,7 @@ private[sbt] object Load {
catch { case e: AutoPluginException => throw translateAutoPluginException(e, p) }
val p2 = this.resolveProject(p1, autoPlugins, plugins, injectSettings, memoSettings, log)
val projectLevelExtra =
if (expand) autoPlugins flatMap { _.derivedProjects(p2) map {_.setProjectOrigin(ProjectOrigin.DerivedProject)} }
if (expand) autoPlugins flatMap { _.derivedProjects(p2) map { _.setProjectOrigin(ProjectOrigin.DerivedProject) } }
else Nil
(p2, projectLevelExtra)
}
@ -638,7 +654,8 @@ private[sbt] object Load {
root: Option[Project],
nonRoot: Seq[Project],
sbtFiles: Seq[File],
generatedFiles: Seq[File])
generatedFiles: Seq[File]
)
/**
* This method attempts to resolve/apply all configuration loaded for a project. It is responsible for the following:
@ -660,7 +677,8 @@ private[sbt] object Load {
loadedPlugins: LoadedPlugins,
globalUserSettings: InjectSettings,
memoSettings: mutable.Map[File, LoadedSbtFile],
log: Logger): Project = {
log: Logger
): Project = {
import AddSettings._
val autoConfigs = projectPlugins.flatMap(_.projectConfigurations)
@ -707,7 +725,8 @@ private[sbt] object Load {
projectBase: File,
loadedPlugins: LoadedPlugins,
eval: () => Eval,
memoSettings: mutable.Map[File, LoadedSbtFile]): DiscoveredProjects = {
memoSettings: mutable.Map[File, LoadedSbtFile]
): DiscoveredProjects = {
// Default sbt files to read, if needed
lazy val defaultSbtFiles = configurationSources(projectBase)
@ -915,7 +934,8 @@ final case class LoadBuildConfiguration(
injectSettings: Load.InjectSettings,
globalPlugin: Option[GlobalPlugin],
extraBuilds: Seq[URI],
log: Logger) {
log: Logger
) {
lazy val (globalPluginClasspath, _) = Load.pluginDefinitionLoader(this, Load.globalPluginClasspath(globalPlugin))
private[sbt] lazy val globalPluginDefs = {

View File

@ -16,7 +16,8 @@ private[sbt] final class LoadedSbtFile(
// TODO - we may want to expose a simpler interface on top of here for the set command,
// rather than what we have now...
val definitions: DefinedSbtValues,
val generatedFiles: Seq[File]) {
val generatedFiles: Seq[File]
) {
// We still use merge for now. We track originating sbt file in an alternative manner.
def merge(o: LoadedSbtFile): LoadedSbtFile =
new LoadedSbtFile(
@ -25,7 +26,8 @@ private[sbt] final class LoadedSbtFile(
importedDefs ++ o.importedDefs,
manipulations,
definitions zip o.definitions,
generatedFiles ++ o.generatedFiles)
generatedFiles ++ o.generatedFiles
)
def clearProjects = new LoadedSbtFile(settings, Nil, importedDefs, manipulations, definitions, generatedFiles)
}

View File

@ -4,14 +4,16 @@ package internal
import sbt.internal.util.{ AttributeKey, Dag, Relation, Util }
import sbt.util.Logger
import Def.Setting
import Plugins._
import PluginsDebug._
import java.net.URI
import Def.Setting
import Plugins._
import PluginsDebug._
import java.net.URI
private[sbt] class PluginsDebug(val available: List[AutoPlugin], val nameToKey: Map[String, AttributeKey[_]], val provided: Relation[AutoPlugin, AttributeKey[_]]) {
/** The set of [[AutoPlugin]]s that might define a key named `keyName`.
* Because plugins can define keys in different scopes, this should only be used as a guideline. */
/**
* The set of [[AutoPlugin]]s that might define a key named `keyName`.
* Because plugins can define keys in different scopes, this should only be used as a guideline.
*/
def providers(keyName: String): Set[AutoPlugin] = nameToKey.get(keyName) match {
case None => Set.empty
case Some(key) => provided.reverse(key)
@ -27,7 +29,7 @@ private[sbt] class PluginsDebug(val available: List[AutoPlugin], val nameToKey:
case pa: PluginActivated => Left(pa)
case pd: EnableDeactivated => Right(pd)
}
val activePrefix = if(activated.nonEmpty) s"Some already activated plugins define $notFoundKey: ${activated.mkString(", ")}\n" else ""
val activePrefix = if (activated.nonEmpty) s"Some already activated plugins define $notFoundKey: ${activated.mkString(", ")}\n" else ""
activePrefix + debugDeactivated(notFoundKey, deactivated)
}
private[this] def debugDeactivated(notFoundKey: String, deactivated: Seq[EnableDeactivated]): String =
@ -36,16 +38,15 @@ private[sbt] class PluginsDebug(val available: List[AutoPlugin], val nameToKey:
case pi: PluginImpossible => Left(pi)
case pr: PluginRequirements => Right(pr)
}
if(possible.nonEmpty) {
if (possible.nonEmpty) {
val explained = possible.map(explainPluginEnable)
val possibleString =
if(explained.size > 1) explained.zipWithIndex.map{case (s,i) => s"$i. $s"}.mkString(s"Multiple plugins are available that can provide $notFoundKey:\n", "\n", "")
if (explained.size > 1) explained.zipWithIndex.map { case (s, i) => s"$i. $s" }.mkString(s"Multiple plugins are available that can provide $notFoundKey:\n", "\n", "")
else s"$notFoundKey is provided by an available (but not activated) plugin:\n${explained.mkString}"
def impossiblePlugins = impossible.map(_.plugin.label).mkString(", ")
val imPostfix = if(impossible.isEmpty) "" else s"\n\nThere are other available plugins that provide $notFoundKey, but they are impossible to add: $impossiblePlugins"
val imPostfix = if (impossible.isEmpty) "" else s"\n\nThere are other available plugins that provide $notFoundKey, but they are impossible to add: $impossiblePlugins"
possibleString + imPostfix
}
else if(impossible.isEmpty)
} else if (impossible.isEmpty)
s"No available plugin provides key $notFoundKey."
else {
val explanations = impossible.map(explainPluginEnable)
@ -61,44 +62,42 @@ private[sbt] class PluginsDebug(val available: List[AutoPlugin], val nameToKey:
{
val prefix = s"${plugin.label} is activated."
val keys = provided.forward(plugin)
val keysString = if(keys.isEmpty) "" else s"\nIt may affect these keys: ${multi(keys.toList.map(_.label))}"
val keysString = if (keys.isEmpty) "" else s"\nIt may affect these keys: ${multi(keys.toList.map(_.label))}"
val configs = plugin.projectConfigurations
val confsString = if(configs.isEmpty) "" else s"\nIt defines these configurations: ${multi(configs.map(_.name))}"
val confsString = if (configs.isEmpty) "" else s"\nIt defines these configurations: ${multi(configs.map(_.name))}"
prefix + keysString + confsString
}
private def deactivatedHelp(plugin: AutoPlugin, context: Context): String =
{
val prefix = s"${plugin.label} is NOT activated."
val keys = provided.forward(plugin)
val keysString = if(keys.isEmpty) "" else s"\nActivating it may affect these keys: ${multi(keys.toList.map(_.label))}"
val keysString = if (keys.isEmpty) "" else s"\nActivating it may affect these keys: ${multi(keys.toList.map(_.label))}"
val configs = plugin.projectConfigurations
val confsString = if(configs.isEmpty) "" else s"\nActivating it will define these configurations: ${multi(configs.map(_.name))}"
val confsString = if (configs.isEmpty) "" else s"\nActivating it will define these configurations: ${multi(configs.map(_.name))}"
val toActivate = explainPluginEnable(pluginEnable(context, plugin))
s"$prefix$keysString$confsString\n$toActivate"
}
private[this] def multi(strs: Seq[String]): String = strs.mkString(if(strs.size > 4) "\n\t" else ", ")
private[this] def multi(strs: Seq[String]): String = strs.mkString(if (strs.size > 4) "\n\t" else ", ")
}
private[sbt] object PluginsDebug {
def helpAll(s: State): String =
if(Project.isProjectLoaded(s))
{
if (Project.isProjectLoaded(s)) {
val extracted = Project.extract(s)
import extracted._
def helpBuild(uri: URI, build: LoadedBuildUnit): String =
{
val pluginStrings = for(plugin <- availableAutoPlugins(build)) yield {
val pluginStrings = for (plugin <- availableAutoPlugins(build)) yield {
val activatedIn = build.defined.values.toList.filter(_.autoPlugins.contains(plugin)).map(_.id)
val actString = if(activatedIn.nonEmpty) activatedIn.mkString(": enabled in ", ", ", "") else "" // TODO: deal with large builds
val actString = if (activatedIn.nonEmpty) activatedIn.mkString(": enabled in ", ", ", "") else "" // TODO: deal with large builds
s"\n\t${plugin.label}$actString"
}
s"In $uri${pluginStrings.mkString}"
}
val buildStrings = for((uri, build) <- structure.units) yield helpBuild(uri, build)
val buildStrings = for ((uri, build) <- structure.units) yield helpBuild(uri, build)
buildStrings.mkString("\n")
}
else "No project is currently loaded."
} else "No project is currently loaded."
def autoPluginMap(s: State): Map[String, AutoPlugin] =
{
@ -107,7 +106,7 @@ private[sbt] object PluginsDebug {
structure.units.values.toList.flatMap(availableAutoPlugins).map(plugin => (plugin.label, plugin)).toMap
}
private[this] def availableAutoPlugins(build: LoadedBuildUnit): Seq[AutoPlugin] =
build.unit.plugins.detected.autoPlugins map {_.value}
build.unit.plugins.detected.autoPlugins map { _.value }
def help(plugin: AutoPlugin, s: State): String =
{
@ -119,20 +118,20 @@ private[sbt] object PluginsDebug {
val pluginsThisBuild = perBuild.getOrElse(currentRef.build, Set.empty).toList
lazy val context = Context(currentProject.plugins, currentProject.autoPlugins, Plugins.deducer(pluginsThisBuild), pluginsThisBuild, s.log)
lazy val debug = PluginsDebug(context.available)
if(!pluginsThisBuild.contains(plugin)) {
if (!pluginsThisBuild.contains(plugin)) {
val availableInBuilds: List[URI] = perBuild.toList.filter(_._2(plugin)).map(_._1)
s"Plugin ${plugin.label} is only available in builds:\n\t${availableInBuilds.mkString("\n\t")}\nSwitch to a project in one of those builds using `project` and rerun this command for more information."
} else if(definesPlugin(currentProject))
} 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) {
if (definedInAggregated.nonEmpty) {
val projectNames = definedInAggregated.map(_.project) // TODO: usually in this build, but could technically require the build to be qualified
s"Plugin ${plugin.label} is not activated on this project, but this project aggregates projects where it is activated:\n\t${projectNames.mkString("\n\t")}"
} else {
val base = debug.deactivatedHelp(plugin, context)
val aggNote = if(thisAggregated.nonEmpty) "Note: This project aggregates other projects and this" else "Note: This"
val aggNote = if (thisAggregated.nonEmpty) "Note: This project aggregates other projects and this" else "Note: This"
val common = " information is for this project only."
val helpOther = "To see how to activate this plugin for another project, change to the project using `project <name>` and rerun this command."
s"$base\n$aggNote$common\n$helpOther"
@ -148,11 +147,13 @@ private[sbt] object PluginsDebug {
new PluginsDebug(available, nameToKey, keyR)
}
/** The context for debugging a plugin (de)activation.
/**
* The context for debugging a plugin (de)activation.
* @param initial The initially defined [[AutoPlugin]]s.
* @param enabled The resulting model.
* @param deducePlugin The function used to compute the model.
* @param available All [[AutoPlugin]]s available for consideration. */
* @param available All [[AutoPlugin]]s available for consideration.
*/
final case class Context(initial: Plugins, enabled: Seq[AutoPlugin], deducePlugin: (Plugins, Logger) => Seq[AutoPlugin], available: List[AutoPlugin], log: Logger)
/** Describes the steps to activate a plugin in some context. */
@ -163,24 +164,28 @@ private[sbt] object PluginsDebug {
/** Describes a [[plugin]] that cannot be activated in a [[context]] due to [[contradictions]] in requirements. */
final case class PluginImpossible(plugin: AutoPlugin, context: Context, contradictions: Set[AutoPlugin]) extends EnableDeactivated
/** Describes the requirements for activating [[plugin]] in [[context]].
/**
* Describes the requirements for activating [[plugin]] in [[context]].
* @param context The base plugins, exclusions, and ultimately activated plugins
* @param blockingExcludes Existing exclusions that prevent [[plugin]] from being activated and must be dropped
* @param enablingPlugins [[AutoPlugin]]s that are not currently enabled, but need to be enabled for [[plugin]] to activate
* @param extraEnabledPlugins Plugins that will be enabled as a result of [[plugin]] activating, but are not required for [[plugin]] to activate
* @param willRemove Plugins that will be deactivated as a result of [[plugin]] activating
* @param deactivate Describes plugins that must be deactivated for [[plugin]] to activate. These require an explicit exclusion or dropping a transitive [[AutoPlugin]].*/
* @param deactivate Describes plugins that must be deactivated for [[plugin]] to activate. These require an explicit exclusion or dropping a transitive [[AutoPlugin]].
*/
final case class PluginRequirements(plugin: AutoPlugin, context: Context, blockingExcludes: Set[AutoPlugin], enablingPlugins: Set[AutoPlugin], extraEnabledPlugins: Set[AutoPlugin], willRemove: Set[AutoPlugin], deactivate: List[DeactivatePlugin]) extends EnableDeactivated
/** Describes a [[plugin]] that must be removed in order to activate another plugin in some context.
/**
* Describes a [[plugin]] that must be removed in order to activate another plugin in some context.
* The [[plugin]] can always be directly, explicitly excluded.
* @param removeOneOf If non-empty, removing one of these [[AutoPlugin]]s will deactivate [[plugin]] without affecting the other plugin. If empty, a direct exclusion is required.
* @param newlySelected If false, this plugin was selected in the original context. */
* @param newlySelected If false, this plugin was selected in the original context.
*/
final case class DeactivatePlugin(plugin: AutoPlugin, removeOneOf: Set[AutoPlugin], newlySelected: Boolean)
/** Determines how to enable [[plugin]] in [[context]]. */
def pluginEnable(context: Context, plugin: AutoPlugin): PluginEnable =
if(context.enabled.contains(plugin))
if (context.enabled.contains(plugin))
PluginActivated(plugin, context)
else
enableDeactivated(context, plugin)
@ -248,7 +253,7 @@ private[sbt] object PluginsDebug {
// So, in either of these cases, A doesn't need to be considered further and won't be included in this set.
val minDeactivate = minAbsentPlugins.filter(p => Plugins.satisfied(p.requires, incrementalModel))
val deactivate = for(d <- minDeactivate.toList) yield {
val deactivate = for (d <- minDeactivate.toList) yield {
// removing any one of these plugins will deactivate `d`. TODO: This is not an especially efficient implementation.
val removeToDeactivate = plugins(minimalModel(d)) -- minRequiredPlugins
val newlySelected = !initialModel(d)
@ -281,10 +286,10 @@ private[sbt] object PluginsDebug {
def explainPluginEnable(ps: PluginEnable): String =
ps match {
case PluginRequirements(plugin, context, 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"
def indent(str: String) = if (str.isEmpty) "" else s"\t$str"
def note(str: String) = if (str.isEmpty) "" else s"Note: $str"
val parts =
indent(excludedError(false /* TODO */, blockingExcludes.toList)) ::
indent(excludedError(false /* TODO */ , blockingExcludes.toList)) ::
indent(required(enablingPlugins.toList)) ::
indent(needToDeactivate(deactivate)) ::
note(willAdd(plugin, extraEnabledPlugins.toList)) ::
@ -295,15 +300,17 @@ private[sbt] object PluginsDebug {
case PluginActivated(plugin, context) => s"Plugin ${plugin.label} already activated."
}
/** Provides a [[Relation]] between plugins and the keys they potentially define.
* Because plugins can define keys in different scopes and keys can be overridden, this is not definitive.*/
/**
* Provides a [[Relation]] between plugins and the keys they potentially define.
* Because plugins can define keys in different scopes and keys can be overridden, this is not definitive.
*/
def definedKeys(available: List[AutoPlugin]): Relation[AutoPlugin, AttributeKey[_]] =
{
def extractDefinedKeys(ss: Seq[Setting[_]]): Seq[AttributeKey[_]] =
ss.map(_.key.key)
def allSettings(p: AutoPlugin): Seq[Setting[_]] = p.projectSettings ++ p.buildSettings ++ p.globalSettings
val empty = Relation.empty[AutoPlugin, AttributeKey[_]]
(empty /: available)( (r,p) => r + (p, extractDefinedKeys(allSettings(p))) )
(empty /: available)((r, p) => r + (p, extractDefinedKeys(allSettings(p))))
}
private[this] def excludedError(transitive: Boolean, dependencies: List[AutoPlugin]): String =
@ -314,7 +321,7 @@ private[sbt] object PluginsDebug {
private[this] def excludedPluginsError(transitive: Boolean)(dependencies: List[AutoPlugin]) =
s"Required ${transitiveString(transitive)}dependencies were excluded:\n\t${labels(dependencies).mkString("\n\t")}"
private[this] def transitiveString(transitive: Boolean) =
if(transitive) "(transitive) " else ""
if (transitive) "(transitive) " else ""
private[this] def required(plugins: List[AutoPlugin]): String =
str(plugins)(requiredPlugin, requiredPlugins)

View File

@ -34,12 +34,14 @@ object SettingGraph {
}
}
case class SettingGraph(name: String,
case class SettingGraph(
name: String,
definedIn: Option[String],
data: Option[ScopedKeyData[_]],
description: Option[String],
basedir: File,
depends: Set[SettingGraph]) {
depends: Set[SettingGraph]
) {
def dataString: String =
data map { d =>
d.settingValue map {
@ -48,9 +50,11 @@ case class SettingGraph(name: String,
} getOrElse { d.typeName }
} getOrElse { "" }
def dependsAscii: String = Graph.toAscii(this,
def dependsAscii: String = Graph.toAscii(
this,
(x: SettingGraph) => x.depends.toSeq.sortBy(_.name),
(x: SettingGraph) => "%s = %s" format (x.definedIn getOrElse { "" }, x.dataString))
(x: SettingGraph) => "%s = %s" format (x.definedIn getOrElse { "" }, x.dataString)
)
}
object Graph {

View File

@ -9,8 +9,10 @@ import Def._
trait TaskSequential {
def sequential[B](last: Initialize[Task[B]]): Initialize[Task[B]] =
sequential(Nil, last)
def sequential[A0, B](task0: Initialize[Task[A0]],
last: Initialize[Task[B]]): Initialize[Task[B]] =
def sequential[A0, B](
task0: Initialize[Task[A0]],
last: Initialize[Task[B]]
): Initialize[Task[B]] =
sequential(List(unitTask(task0)), last)
def sequential[A0, A1, B](task0: Initialize[Task[A0]], task1: Initialize[Task[A1]],
last: Initialize[Task[B]]): Initialize[Task[B]] =

View File

@ -4,7 +4,8 @@ package plugins
import Def.Setting
import Keys._
/** An experimental plugin that adds the ability for junit-xml to be generated.
/**
* An experimental plugin that adds the ability for junit-xml to be generated.
*
* To disable this plugin, you need to add:
* {{{

View File

@ -5,7 +5,8 @@ import sbt.librarymanagement.{ Configuration, Configurations }
import Def.Setting
/** A plugin representing the ability to build a JVM project.
/**
* A plugin representing the ability to build a JVM project.
*
* Core tasks/keys:
* - `run`

View File

@ -4,8 +4,7 @@ import org.specs2._
import mutable.Specification
import sbt.util.Logger
object PluginsTest extends Specification
{
object PluginsTest extends Specification {
import AI._
"Auto plugin" should {
@ -17,14 +16,14 @@ object PluginsTest extends Specification
}
"order enable plugins after required plugins" in {
val ns = deducePlugin(A && B, log)
( (ns indexOf Q) must beGreaterThan(ns indexOf A) ) and
( (ns indexOf Q) must beGreaterThan(ns indexOf B) ) and
( (ns indexOf R) must beGreaterThan(ns indexOf A) ) and
( (ns indexOf R) must beGreaterThan(ns indexOf B) ) and
( (ns indexOf R) must beGreaterThan(ns indexOf Q) )
((ns indexOf Q) must beGreaterThan(ns indexOf A)) and
((ns indexOf Q) must beGreaterThan(ns indexOf B)) and
((ns indexOf R) must beGreaterThan(ns indexOf A)) and
((ns indexOf R) must beGreaterThan(ns indexOf B)) and
((ns indexOf R) must beGreaterThan(ns indexOf Q))
}
"not enable plugins with trigger=allRequirements but conflicting requirements" in {
deducePlugin(A && B, log) must not contain(S)
deducePlugin(A && B, log) must not contain (S)
}
"enable plugins that are required by the requested plugins" in {
val ns = deducePlugin(Q, log)
@ -47,8 +46,7 @@ object PluginsTest extends Specification
}
}
object AI
{
object AI {
lazy val allPlugins: List[AutoPlugin] = List(A, B, Q, R, S, T, U)
lazy val deducePlugin = Plugins.deducer(allPlugins)
lazy val log = Logger.Null
@ -56,35 +54,30 @@ object AI
object A extends AutoPlugin { override def requires = empty }
object B extends AutoPlugin { override def requires = empty }
object Q extends AutoPlugin
{
object Q extends AutoPlugin {
override def requires: Plugins = A && B
override def trigger = allRequirements
}
object R extends AutoPlugin
{
object R extends AutoPlugin {
override def requires = Q
override def trigger = allRequirements
}
object S extends AutoPlugin
{
object S extends AutoPlugin {
override def requires = Q && !R
override def trigger = allRequirements
}
// This is an opt-in plugin with a requirement
// Unless explicitly loaded by the build user, this will not be activated.
object T extends AutoPlugin
{
object T extends AutoPlugin {
override def requires = Q && !R
}
// This is an opt-in plugin with a requirement
// Unless explicitly loaded by the build user, this will not be activated.
object U extends AutoPlugin
{
object U extends AutoPlugin {
override def requires = A && !Q
}
}

View File

@ -13,7 +13,8 @@ class CommentedXmlSpec extends CheckIfParsedSpec {
|
|val tra = "</scm>"
|
""".stripMargin, "Xml in string", false, true),
""".stripMargin, "Xml in string", false, true
),
("""
|val scmpom = taskKey[xml.NodeBuffer]("Node buffer")
|

View File

@ -139,7 +139,8 @@ class EmbeddedXmlSpec extends CheckIfParsedSpec {
|
|
|
""".stripMargin, "xml with blank line", false, true)
""".stripMargin, "xml with blank line", false, true
)
)
}

View File

@ -36,7 +36,8 @@ lazy val root = (project in file(".")).enablePlugins­(PlayScala)""")
"""import foo.Bar
import foo.Bar
version := "1.0"
""".stripMargin)
""".stripMargin
)
imports.size === 2
settingsAndDefs.size === 1
}

View File

@ -9,13 +9,18 @@ object Formatting {
val scalariformCheck = taskKey[Unit]("Checks that the existing code is formatted, via git diff")
lazy val settings: Seq[Setting[_]] = Seq() ++ scalariformSettings ++ prefs
lazy val prefs: Seq[Setting[_]] = {
import scalariform.formatter.preferences._
Seq(
scalariformPreferences ~= (_.setPreference(AlignSingleLineCaseStatements, true))
scalariformPreferences ~= (_
.setPreference(AlignSingleLineCaseStatements, true)
.setPreference(AlignSingleLineCaseStatements.MaxArrowIndent, 100)
.setPreference(DanglingCloseParenthesis, Force)
)
)
}
lazy val settings: Seq[Setting[_]] = Seq() ++ scalariformSettings ++ prefs
lazy val sbtFilesSettings: Seq[Setting[_]] = Seq() ++ scalariformSettings ++ prefs ++
inConfig(BuildConfig)(configScalariformSettings) ++
inConfig(BuildSbtConfig)(configScalariformSettings) ++

View File

@ -5,6 +5,6 @@ addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.8")
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.5.4")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.8.5")
addSbtPlugin("com.typesafe.sbt" % "sbt-javaversioncheck" % "0.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.3.0") // 1.6.0 is out but is a hard upgrade
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.6.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "0.8.2")
addSbtPlugin("me.lessis" % "bintray-sbt" % "0.3.0")

View File

@ -178,7 +178,6 @@ trait Import {
val ~> = sbt.internal.util.~>
type ~>[-K[_], +V[_]] = sbt.internal.util.~>[K, V]
// sbt.internal.util.complete
object complete {
val Completion = sbt.internal.util.complete.Completion
@ -302,7 +301,6 @@ trait Import {
type VersionNumber = sbt.librarymanagement.VersionNumber
type VersionNumberCompatibility = sbt.librarymanagement.VersionNumberCompatibility
// sbt.internal.librarymanagement
type IvyPaths = sbt.internal.librarymanagement.IvyPaths
val UpdateLogging = sbt.internal.librarymanagement.UpdateLogging

View File

@ -85,7 +85,8 @@ object ScriptedPlugin extends AutoPlugin {
try {
scriptedRun.value.invoke(
scriptedTests.value, sbtTestDirectory.value, scriptedBufferLog.value: java.lang.Boolean,
args.toArray, sbtLauncher.value, scriptedLaunchOpts.value.toArray)
args.toArray, sbtLauncher.value, scriptedLaunchOpts.value.toArray
)
} catch { case e: java.lang.reflect.InvocationTargetException => throw e.getCause }
}

View File

@ -4,8 +4,20 @@
package sbt
package std
import java.io.{ BufferedInputStream, BufferedOutputStream, BufferedReader, BufferedWriter, Closeable, File,
FileInputStream, FileOutputStream, IOException, InputStreamReader, OutputStreamWriter, PrintWriter }
import java.io.{
BufferedInputStream,
BufferedOutputStream,
BufferedReader,
BufferedWriter,
Closeable,
File,
FileInputStream,
FileOutputStream,
IOException,
InputStreamReader,
OutputStreamWriter,
PrintWriter
}
import sbt.internal.io.DeferredWriter
import sbt.io.IO

View File

@ -33,5 +33,5 @@ object TaskRunnerCircularTest extends Properties("TaskRunner Circular") {
try { tryRun(top, true, workers); false }
catch { case i: Incomplete => cyclic(i) }
}
def cyclic(i: Incomplete) = Incomplete.allExceptions(i).exists(_.isInstanceOf[Execute[({ type A[_] <: AnyRef})#A]#CyclicException[_]])
def cyclic(i: Incomplete) = Incomplete.allExceptions(i).exists(_.isInstanceOf[Execute[({ type A[_] <: AnyRef })#A]#CyclicException[_]])
}

View File

@ -29,8 +29,7 @@ object CompletionService {
() => future.get()
}
def manage[A, T](service: CompletionService[A, T])(setup: A => Unit, cleanup: A => Unit): CompletionService[A, T] =
wrap(service) { (node, work) =>
() =>
wrap(service) { (node, work) => () =>
setup(node)
try { work() }
finally { cleanup(node) }

View File

@ -179,7 +179,9 @@ private[sbt] final class Execute[A[_] <: AnyRef](config: Config, triggers: Trigg
val v = register(node)
val deps = dependencies(v) ++ runBefore(node)
val active = IDSet[A[_]](deps filter notDone)
progressState = progress.registered(progressState, node, deps, active.toList /** active is mutable, so take a snapshot */ )
progressState = progress.registered(progressState, node, deps, active.toList
/** active is mutable, so take a snapshot */
)
if (active.isEmpty)
ready(node)

View File

@ -85,11 +85,11 @@ class JUnitXmlTestsListener(val outputDir: String) extends TestsListener {
""
}
e.status match {
case TStatus.Error if (e.throwable.isDefined) => <error message={ e.throwable.get.getMessage } type={ e.throwable.get.getClass.getName }>{ trace }</error>
case TStatus.Error => <error message={ "No Exception or message provided" }/>
case TStatus.Failure if (e.throwable.isDefined) => <failure message={ e.throwable.get.getMessage } type={ e.throwable.get.getClass.getName }>{ trace }</failure>
case TStatus.Failure => <failure message={ "No Exception or message provided" }/>
case TStatus.Ignored | TStatus.Skipped | TStatus.Pending => <skipped/>
case TStatus.Error if (e.throwable.isDefined)=> <error message={ e.throwable.get.getMessage } type={ e.throwable.get.getClass.getName }>{ trace }</error>
case TStatus.Error=> <error message={ "No Exception or message provided" }/>
case TStatus.Failure if (e.throwable.isDefined)=> <failure message={ e.throwable.get.getMessage } type={ e.throwable.get.getClass.getName }>{ trace }</failure>
case TStatus.Failure=> <failure message={ "No Exception or message provided" }/>
case TStatus.Ignored | TStatus.Skipped | TStatus.Pending=> <skipped/>
case _ => {}
}
}

View File

@ -127,12 +127,14 @@ object TestFramework {
case _ => f.toString
}
def testTasks(frameworks: Map[TestFramework, Framework],
def testTasks(
frameworks: Map[TestFramework, Framework],
runners: Map[TestFramework, Runner],
testLoader: ClassLoader,
tests: Seq[TestDefinition],
log: Logger,
listeners: Seq[TestReportListener]): (() => Unit, Seq[(String, TestFunction)], TestResult.Value => () => Unit) =
listeners: Seq[TestReportListener]
): (() => Unit, Seq[(String, TestFunction)], TestResult.Value => () => Unit) =
{
val mappedTests = testMap(frameworks.values.toSeq, tests)
if (mappedTests.isEmpty)

View File

@ -37,7 +37,8 @@ trait TestsListener extends TestReportListener {
final class SuiteResult(
val result: TestResult.Value,
val passedCount: Int, val failureCount: Int, val errorCount: Int,
val skippedCount: Int, val ignoredCount: Int, val canceledCount: Int, val pendingCount: Int) {
val skippedCount: Int, val ignoredCount: Int, val canceledCount: Int, val pendingCount: Int
) {
def +(other: SuiteResult): SuiteResult = {
val combinedTestResult =
(result, other.result) match {