mirror of https://github.com/sbt/sbt.git
commit
00f292524f
|
|
@ -1,6 +1,7 @@
|
|||
version = 2.0.0-RC5
|
||||
maxColumn = 100
|
||||
project.git = true
|
||||
project.excludeFilters = [ /sbt-test/, /input_sources/, /contraband-scala/ ]
|
||||
project.excludeFilters = [ "\\Wsbt-test\\W", "\\Winput_sources\\W", "\\Wcontraband-scala\\W" ]
|
||||
|
||||
# http://docs.scala-lang.org/style/scaladoc.html recommends the JavaDoc style.
|
||||
# scala/scala is written that way too https://github.com/scala/scala/blob/v2.12.2/src/library/scala/Predef.scala
|
||||
|
|
@ -16,3 +17,5 @@ align.openParenDefnSite = false
|
|||
|
||||
# For better code clarity
|
||||
danglingParentheses = true
|
||||
|
||||
trailingCommas = preserve
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ env:
|
|||
# WHITESOURCE_PASSWORD=
|
||||
- secure: d3bu2KNwsVHwfhbGgO+gmRfDKBJhfICdCJFGWKf2w3Gv86AJZX9nuTYRxz0KtdvEHO5Xw8WTBZLPb2thSJqhw9OCm4J8TBAVqCP0ruUj4+aqBUFy4bVexQ6WKE6nWHs4JPzPk8c6uC1LG3hMuzlC8RGETXtL/n81Ef1u7NjyXjs=
|
||||
matrix:
|
||||
- SBT_CMD=";mimaReportBinaryIssues ;scalafmtCheck ;headerCheck ;test:headerCheck ;whitesourceOnPush ;test:compile ;mainSettingsProj/test ;safeUnitTests ;otherUnitTests; doc"
|
||||
- SBT_CMD=";mimaReportBinaryIssues ;scalafmtCheckAll ;headerCheck ;test:headerCheck ;whitesourceOnPush ;test:compile ;mainSettingsProj/test ;safeUnitTests ;otherUnitTests; doc"
|
||||
- SBT_CMD="scripted actions/*"
|
||||
- SBT_CMD="scripted apiinfo/* compiler-project/* ivy-deps-management/*"
|
||||
- SBT_CMD="scripted dependency-management/*1of4"
|
||||
|
|
|
|||
|
|
@ -27,7 +27,9 @@ object Dag {
|
|||
def visit(node: T): Unit = {
|
||||
if (!discovered(node)) {
|
||||
discovered(node) = true;
|
||||
try { visitAll(dependencies(node)); } catch { case c: Cyclic => throw node :: c }
|
||||
try {
|
||||
visitAll(dependencies(node));
|
||||
} catch { case c: Cyclic => throw node :: c }
|
||||
finished += node
|
||||
()
|
||||
} else if (!finished(node))
|
||||
|
|
|
|||
|
|
@ -48,7 +48,10 @@ object IDSet {
|
|||
def isEmpty = backing.isEmpty
|
||||
|
||||
def process[S](t: T)(ifSeen: S)(ifNew: => S) =
|
||||
if (contains(t)) ifSeen else { this += t; ifNew }
|
||||
if (contains(t)) ifSeen
|
||||
else {
|
||||
this += t; ifNew
|
||||
}
|
||||
|
||||
override def toString = backing.toString
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,7 +95,9 @@ abstract class EvaluateSettings[ScopeType] {
|
|||
}
|
||||
|
||||
private[this] def run0(work: => Unit): Unit = {
|
||||
try { work } catch { case e: Throwable => complete.put(Some(e)) }
|
||||
try {
|
||||
work
|
||||
} catch { case e: Throwable => complete.put(Some(e)) }
|
||||
workComplete()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -206,7 +206,9 @@ trait Init[ScopeType] {
|
|||
// order the initializations. cyclic references are detected here.
|
||||
val ordered: Seq[Compiled[_]] = sort(cMap)
|
||||
// evaluation: apply the initializations.
|
||||
try { applyInits(ordered) } catch {
|
||||
try {
|
||||
applyInits(ordered)
|
||||
} catch {
|
||||
case rru: RuntimeUndefined =>
|
||||
throw Uninitialized(cMap.keys.toSeq, delegates, rru.undefined, true)
|
||||
}
|
||||
|
|
@ -285,7 +287,9 @@ trait Init[ScopeType] {
|
|||
def executor = x
|
||||
}
|
||||
eval.run
|
||||
} finally { x.shutdown() }
|
||||
} finally {
|
||||
x.shutdown()
|
||||
}
|
||||
}
|
||||
|
||||
def showUndefined(
|
||||
|
|
|
|||
|
|
@ -70,7 +70,9 @@ object Signals {
|
|||
private final class Signals0 {
|
||||
def supported(signal: String): Boolean = {
|
||||
import sun.misc.Signal
|
||||
try { new Signal(signal); true } catch { case _: IllegalArgumentException => false }
|
||||
try {
|
||||
new Signal(signal); true
|
||||
} catch { case _: IllegalArgumentException => false }
|
||||
}
|
||||
|
||||
// returns a LinkageError in `action` as Left(t) in order to avoid it being
|
||||
|
|
@ -85,6 +87,8 @@ private final class Signals0 {
|
|||
val oldHandler = Signal.handle(intSignal, newHandler)
|
||||
|
||||
try Right(action())
|
||||
catch { case e: LinkageError => Left(e) } finally { Signal.handle(intSignal, oldHandler); () }
|
||||
catch { case e: LinkageError => Left(e) } finally {
|
||||
Signal.handle(intSignal, oldHandler); ()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,9 @@ case class SettingsExample() extends Init[Scope] {
|
|||
val delegates: Scope => Seq[Scope] = {
|
||||
case s @ Scope(index, proj) =>
|
||||
s +: (if (index <= 0) Nil
|
||||
else { (if (proj > 0) List(Scope(index)) else Nil) ++: delegates(Scope(index - 1)) })
|
||||
else {
|
||||
(if (proj > 0) List(Scope(index)) else Nil) ++: delegates(Scope(index - 1))
|
||||
})
|
||||
}
|
||||
|
||||
// Not using this feature in this example.
|
||||
|
|
|
|||
|
|
@ -158,7 +158,9 @@ object SettingsTest extends Properties("settings") {
|
|||
// property("Catches circular references") = forAll(chainLengthGen) { checkCircularReferences _ }
|
||||
final def checkCircularReferences(intermediate: Int): Prop = {
|
||||
val ccr = new CCR(intermediate)
|
||||
try { evaluate(setting(chk, ccr.top) :: Nil); false } catch {
|
||||
try {
|
||||
evaluate(setting(chk, ccr.top) :: Nil); false
|
||||
} catch {
|
||||
case _: java.lang.Exception => true
|
||||
}
|
||||
}
|
||||
|
|
@ -195,7 +197,9 @@ object SettingsTest extends Properties("settings") {
|
|||
}
|
||||
|
||||
def evaluate(settings: Seq[Setting[_]]): Settings[Scope] =
|
||||
try { make(settings)(delegates, scopeLocal, showFullKey) } catch {
|
||||
try {
|
||||
make(settings)(delegates, scopeLocal, showFullKey)
|
||||
} catch {
|
||||
case e: Throwable => e.printStackTrace(); throw e
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -166,7 +166,11 @@ private[sbt] object JLine {
|
|||
def withJLine[T](action: => T): T =
|
||||
withTerminal { t =>
|
||||
t.init
|
||||
try { action } finally { t.restore }
|
||||
try {
|
||||
action
|
||||
} finally {
|
||||
t.restore
|
||||
}
|
||||
}
|
||||
|
||||
def simple(
|
||||
|
|
|
|||
|
|
@ -19,7 +19,10 @@ final class History private (val lines: IndexedSeq[String], val path: Option[Fil
|
|||
def !! : Option[String] = !-(1)
|
||||
|
||||
def apply(i: Int): Option[String] =
|
||||
if (0 <= i && i < size) Some(lines(i)) else { sys.error("Invalid history index: " + i) }
|
||||
if (0 <= i && i < size) Some(lines(i))
|
||||
else {
|
||||
sys.error("Invalid history index: " + i)
|
||||
}
|
||||
|
||||
def !(i: Int): Option[String] = apply(i)
|
||||
|
||||
|
|
@ -54,5 +57,7 @@ object History {
|
|||
new History(lines.toIndexedSeq, path)
|
||||
|
||||
def number(s: String): Option[Int] =
|
||||
try { Some(s.toInt) } catch { case _: NumberFormatException => None }
|
||||
try {
|
||||
Some(s.toInt)
|
||||
} catch { case _: NumberFormatException => None }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -641,14 +641,26 @@ private final case class SoftInvalid(fail: Failure) extends ValidParser[Nothing]
|
|||
}
|
||||
|
||||
private final class TrapAndFail[A](a: Parser[A]) extends ValidParser[A] {
|
||||
def result = try { a.result } catch { case _: Exception => None }
|
||||
def resultEmpty = try { a.resultEmpty } catch { case e: Exception => fail(e) }
|
||||
def result =
|
||||
try {
|
||||
a.result
|
||||
} catch { case _: Exception => None }
|
||||
def resultEmpty =
|
||||
try {
|
||||
a.resultEmpty
|
||||
} catch { case e: Exception => fail(e) }
|
||||
|
||||
def derive(c: Char) = try { trapAndFail(a derive c) } catch {
|
||||
def derive(c: Char) =
|
||||
try {
|
||||
trapAndFail(a derive c)
|
||||
} catch {
|
||||
case e: Exception => Invalid(fail(e))
|
||||
}
|
||||
|
||||
def completions(level: Int) = try { a.completions(level) } catch {
|
||||
def completions(level: Int) =
|
||||
try {
|
||||
a.completions(level)
|
||||
} catch {
|
||||
case _: Exception => Completions.nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -264,7 +264,9 @@ trait Parsers {
|
|||
*/
|
||||
def mapOrFail[S, T](p: Parser[S])(f: S => T): Parser[T] =
|
||||
p flatMap { s =>
|
||||
try { success(f(s)) } catch { case e: Exception => failure(e.toString) }
|
||||
try {
|
||||
success(f(s))
|
||||
} catch { case e: Exception => failure(e.toString) }
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -123,7 +123,9 @@ object Sync {
|
|||
def readInfo[F <: FileInfo](
|
||||
store: CacheStore
|
||||
)(implicit infoFormat: JsonFormat[F]): RelationInfo[F] =
|
||||
try { readUncaught[F](store)(infoFormat) } catch {
|
||||
try {
|
||||
readUncaught[F](store)(infoFormat)
|
||||
} catch {
|
||||
case _: IOException => (Relation.empty[File, File], Map.empty[File, F])
|
||||
case _: ZipException => (Relation.empty[File, File], Map.empty[File, F])
|
||||
case e: TranslatedException =>
|
||||
|
|
|
|||
|
|
@ -218,7 +218,11 @@ final class Eval(
|
|||
val extra = ev.read(cacheFile(back, moduleName))
|
||||
(extra, loader)
|
||||
case _ =>
|
||||
try { compileAndLoad(run, unit, imports, backing, moduleName, ev) } finally { unlinkAll() }
|
||||
try {
|
||||
compileAndLoad(run, unit, imports, backing, moduleName, ev)
|
||||
} finally {
|
||||
unlinkAll()
|
||||
}
|
||||
}
|
||||
|
||||
val generatedFiles = getGeneratedFiles(backing, moduleName)
|
||||
|
|
|
|||
|
|
@ -273,8 +273,7 @@ object Scope {
|
|||
taskInherit: AttributeKey[_] => Seq[AttributeKey[_]],
|
||||
): Scope => Seq[Scope] = {
|
||||
val index = delegates(refs, configurations, projectInherit, configInherit)
|
||||
scope =>
|
||||
indexedDelegates(resolve, index, rootProject, taskInherit)(scope)
|
||||
scope => indexedDelegates(resolve, index, rootProject, taskInherit)(scope)
|
||||
}
|
||||
|
||||
@deprecated("Use variant without extraInherit", "1.1.1")
|
||||
|
|
|
|||
|
|
@ -48,8 +48,7 @@ abstract class BackgroundJobService extends Closeable {
|
|||
object BackgroundJobService {
|
||||
private[sbt] def jobIdParser: (State, Seq[JobHandle]) => Parser[Seq[JobHandle]] = {
|
||||
import DefaultParsers._
|
||||
(state, handles) =>
|
||||
{
|
||||
(state, handles) => {
|
||||
val stringIdParser: Parser[Seq[String]] = Space ~> token(
|
||||
NotSpace examples handles.map(_.id.toString).toSet,
|
||||
description = "<job id>"
|
||||
|
|
|
|||
|
|
@ -268,8 +268,7 @@ object Defaults extends BuildCommon {
|
|||
taskTemporaryDirectory := { val dir = IO.createTemporaryDirectory; dir.deleteOnExit(); dir },
|
||||
onComplete := {
|
||||
val tempDirectory = taskTemporaryDirectory.value
|
||||
() =>
|
||||
Clean.deleteContents(tempDirectory, _ => false)
|
||||
() => Clean.deleteContents(tempDirectory, _ => false)
|
||||
},
|
||||
useSuperShell := { if (insideCI.value) false else sbt.internal.TaskProgress.isEnabled },
|
||||
progressReports := { (s: State) =>
|
||||
|
|
@ -295,8 +294,7 @@ object Defaults extends BuildCommon {
|
|||
Continuous.dynamicInputs := Continuous.dynamicInputsImpl.value,
|
||||
externalHooks := {
|
||||
val repository = fileTreeRepository.value
|
||||
compileOptions =>
|
||||
Some(ExternalHooks(compileOptions, repository))
|
||||
compileOptions => Some(ExternalHooks(compileOptions, repository))
|
||||
},
|
||||
logBuffered :== false,
|
||||
commands :== Nil,
|
||||
|
|
@ -1686,7 +1684,8 @@ object Defaults extends BuildCommon {
|
|||
private[sbt] def foldMappers[A](mappers: Seq[A => Option[A]]) =
|
||||
mappers.foldRight({ p: A =>
|
||||
p
|
||||
}) { (mapper, mappers) =>
|
||||
}) {
|
||||
(mapper, mappers) =>
|
||||
{ p: A =>
|
||||
mapper(p).getOrElse(mappers(p))
|
||||
}
|
||||
|
|
@ -3188,8 +3187,7 @@ object Classpaths {
|
|||
case _ => sys.error("Invalid configuration '" + confString + "'") // shouldn't get here
|
||||
}
|
||||
val m = ms.toMap
|
||||
s =>
|
||||
m.getOrElse(s, Nil)
|
||||
s => m.getOrElse(s, Nil)
|
||||
}
|
||||
|
||||
def union[A, B](maps: Seq[A => Seq[B]]): A => Seq[B] =
|
||||
|
|
@ -3365,12 +3363,16 @@ object Classpaths {
|
|||
|
||||
// try/catch for supporting earlier launchers
|
||||
def bootIvyHome(app: xsbti.AppConfiguration): Option[File] =
|
||||
try { Option(app.provider.scalaProvider.launcher.ivyHome) } catch {
|
||||
try {
|
||||
Option(app.provider.scalaProvider.launcher.ivyHome)
|
||||
} catch {
|
||||
case _: NoSuchMethodError => None
|
||||
}
|
||||
|
||||
def bootChecksums(app: xsbti.AppConfiguration): Vector[String] =
|
||||
try { app.provider.scalaProvider.launcher.checksums.toVector } catch {
|
||||
try {
|
||||
app.provider.scalaProvider.launcher.checksums.toVector
|
||||
} catch {
|
||||
case _: NoSuchMethodError => IvySbt.DefaultChecksums
|
||||
}
|
||||
|
||||
|
|
@ -3380,23 +3382,33 @@ object Classpaths {
|
|||
|
||||
/** Loads the `appRepositories` configured for this launcher, if supported. */
|
||||
def appRepositories(app: xsbti.AppConfiguration): Option[Vector[Resolver]] =
|
||||
try { Some(app.provider.scalaProvider.launcher.appRepositories.toVector map bootRepository) } catch {
|
||||
try {
|
||||
Some(app.provider.scalaProvider.launcher.appRepositories.toVector map bootRepository)
|
||||
} catch {
|
||||
case _: NoSuchMethodError => None
|
||||
}
|
||||
|
||||
def bootRepositories(app: xsbti.AppConfiguration): Option[Vector[Resolver]] =
|
||||
try { Some(app.provider.scalaProvider.launcher.ivyRepositories.toVector map bootRepository) } catch {
|
||||
try {
|
||||
Some(app.provider.scalaProvider.launcher.ivyRepositories.toVector map bootRepository)
|
||||
} catch {
|
||||
case _: NoSuchMethodError => None
|
||||
}
|
||||
|
||||
private[this] def mavenCompatible(ivyRepo: xsbti.IvyRepository): Boolean =
|
||||
try { ivyRepo.mavenCompatible } catch { case _: NoSuchMethodError => false }
|
||||
try {
|
||||
ivyRepo.mavenCompatible
|
||||
} catch { case _: NoSuchMethodError => false }
|
||||
|
||||
private[this] def skipConsistencyCheck(ivyRepo: xsbti.IvyRepository): Boolean =
|
||||
try { ivyRepo.skipConsistencyCheck } catch { case _: NoSuchMethodError => false }
|
||||
try {
|
||||
ivyRepo.skipConsistencyCheck
|
||||
} catch { case _: NoSuchMethodError => false }
|
||||
|
||||
private[this] def descriptorOptional(ivyRepo: xsbti.IvyRepository): Boolean =
|
||||
try { ivyRepo.descriptorOptional } catch { case _: NoSuchMethodError => false }
|
||||
try {
|
||||
ivyRepo.descriptorOptional
|
||||
} catch { case _: NoSuchMethodError => false }
|
||||
|
||||
private[this] def bootRepository(repo: xsbti.Repository): Resolver = {
|
||||
import xsbti.Predefined
|
||||
|
|
|
|||
|
|
@ -367,7 +367,11 @@ object EvaluateTask {
|
|||
|
||||
def withStreams[T](structure: BuildStructure, state: State)(f: Streams => T): T = {
|
||||
val str = std.Streams.closeable(structure.streams(state))
|
||||
try { f(str) } finally { str.close() }
|
||||
try {
|
||||
f(str)
|
||||
} finally {
|
||||
str.close()
|
||||
}
|
||||
}
|
||||
|
||||
def getTask[T](
|
||||
|
|
|
|||
|
|
@ -624,7 +624,9 @@ object BuiltinCommands {
|
|||
catch {
|
||||
case NonFatal(e) =>
|
||||
try export0(s)
|
||||
finally { throw e }
|
||||
finally {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
export0(newS)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -189,8 +189,7 @@ object Plugins extends PluginsFunctions {
|
|||
val allEnabledByClause = defined.filterNot(_.isRoot).flatMap(d => asEnabledByClauses(d))
|
||||
|
||||
// Note: Here is where the function begins. We're given a list of plugins now.
|
||||
(requestedPlugins, log) =>
|
||||
{
|
||||
(requestedPlugins, log) => {
|
||||
timed("Plugins.deducer#function", log) {
|
||||
def explicitlyDisabled(p: AutoPlugin): Boolean = hasExclude(requestedPlugins, p)
|
||||
val alwaysEnabled: List[AutoPlugin] =
|
||||
|
|
|
|||
|
|
@ -40,8 +40,7 @@ object ScopeFilter {
|
|||
val pf = projects(data)
|
||||
val cf = configurations(data)
|
||||
val tf = tasks(data)
|
||||
s =>
|
||||
pf(s.project) && cf(s.config) && tf(s.task)
|
||||
s => pf(s.project) && cf(s.config) && tf(s.task)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -49,8 +48,7 @@ object ScopeFilter {
|
|||
new ScopeFilter {
|
||||
private[sbt] def apply(data: Data): Scope => Boolean = {
|
||||
val d = delegate(data)
|
||||
scope =>
|
||||
{
|
||||
scope => {
|
||||
val accept = d(scope)
|
||||
println((if (accept) "ACCEPT " else "reject ") + scope)
|
||||
accept
|
||||
|
|
@ -273,8 +271,7 @@ object ScopeFilter {
|
|||
private[sbt] def apply(data: Data): In => Boolean = {
|
||||
val a = self(data)
|
||||
val b = other(data)
|
||||
s =>
|
||||
a(s) && b(s)
|
||||
s => a(s) && b(s)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -283,8 +280,7 @@ object ScopeFilter {
|
|||
private[sbt] def apply(data: Data): In => Boolean = {
|
||||
val a = self(data)
|
||||
val b = other(data)
|
||||
s =>
|
||||
a(s) || b(s)
|
||||
s => a(s) || b(s)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -292,8 +288,7 @@ object ScopeFilter {
|
|||
def unary_- : Base[In] = new Base[In] {
|
||||
private[sbt] def apply(data: Data): In => Boolean = {
|
||||
val a = self(data)
|
||||
s =>
|
||||
!a(s)
|
||||
s => !a(s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,9 @@ object SessionVar {
|
|||
|
||||
def read[T](key: ScopedKey[Task[T]], state: State)(implicit f: JsonFormat[T]): Option[T] =
|
||||
Project.structure(state).streams(state).use(key) { s =>
|
||||
try { Some(s.getInput(key, DefaultDataID).read[T]) } catch { case NonFatal(_) => None }
|
||||
try {
|
||||
Some(s.getInput(key, DefaultDataID).read[T])
|
||||
} catch { case NonFatal(_) => None }
|
||||
}
|
||||
|
||||
def load[T](key: ScopedKey[Task[T]], state: State)(implicit f: JsonFormat[T]): Option[T] =
|
||||
|
|
|
|||
|
|
@ -117,7 +117,9 @@ private[sbt] object TemplateCommandUtil {
|
|||
val interfaceClass = getInterfaceClass(interfaceClassName, loader)
|
||||
val interface = interfaceClass.getDeclaredConstructor().newInstance().asInstanceOf[AnyRef]
|
||||
val method = interfaceClass.getMethod(methodName, argTypes: _*)
|
||||
try { method.invoke(interface, args: _*) } catch {
|
||||
try {
|
||||
method.invoke(interface, args: _*)
|
||||
} catch {
|
||||
case e: InvocationTargetException => throw e.getCause
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,19 +64,16 @@ object Clean {
|
|||
// Don't use a regular logger because the logger actually writes to the target directory.
|
||||
val debug = (logLevel in scope).?.value.orElse(state.value.get(logLevel.key)) match {
|
||||
case Some(Level.Debug) =>
|
||||
(string: String) =>
|
||||
println(s"[debug] $string")
|
||||
(string: String) => println(s"[debug] $string")
|
||||
case _ =>
|
||||
(_: String) =>
|
||||
{}
|
||||
(_: String) => {}
|
||||
}
|
||||
val delete = tryDelete(debug)
|
||||
cleanFiles.value.sorted.reverseIterator.foreach(delete)
|
||||
(fileOutputs in scope).value.foreach { g =>
|
||||
val filter: TypedPath => Boolean = {
|
||||
val globFilter = g.toTypedPathFilter
|
||||
tp =>
|
||||
!globFilter(tp) || excludeFilter(tp)
|
||||
tp => !globFilter(tp) || excludeFilter(tp)
|
||||
}
|
||||
deleteContents(g.base.toFile, filter, FileTreeView.DEFAULT, delete)
|
||||
delete(g.base.toFile)
|
||||
|
|
|
|||
|
|
@ -456,8 +456,7 @@ object Continuous extends DeprecatedContinuous {
|
|||
}
|
||||
}
|
||||
}
|
||||
() =>
|
||||
{
|
||||
() => {
|
||||
val res = f.view.map(_()).min
|
||||
// Print the default watch message if there are multiple tasks
|
||||
if (configs.size > 1)
|
||||
|
|
@ -500,11 +499,9 @@ object Continuous extends DeprecatedContinuous {
|
|||
if (excludedBuildFilter(entry)) onMetaBuildEvent(c, event) else Watch.Ignore
|
||||
).min
|
||||
}
|
||||
event: Event =>
|
||||
event -> oe(event)
|
||||
event: Event => event -> oe(event)
|
||||
}
|
||||
event: Event =>
|
||||
f.view.map(_.apply(event)).minBy(_._2)
|
||||
event: Event => f.view.map(_.apply(event)).minBy(_._2)
|
||||
}
|
||||
val monitor: FileEventMonitor[FileAttributes] = new FileEventMonitor[FileAttributes] {
|
||||
|
||||
|
|
@ -654,15 +651,12 @@ object Continuous extends DeprecatedContinuous {
|
|||
.map { inputStreamKey =>
|
||||
val is = extracted.runTask(inputStreamKey, state)._2
|
||||
val handler = c.watchSettings.inputHandler.getOrElse(defaultInputHandler(inputParser))
|
||||
() =>
|
||||
handler(is)
|
||||
() => handler(is)
|
||||
}
|
||||
.getOrElse(() => Watch.Ignore)
|
||||
(string: String) =>
|
||||
(default(string) :: alternative() :: Nil).min
|
||||
(string: String) => (default(string) :: alternative() :: Nil).min
|
||||
}
|
||||
() =>
|
||||
{
|
||||
() => {
|
||||
val stringBuilder = new StringBuilder
|
||||
while (inputStream.available > 0) stringBuilder += inputStream.read().toChar
|
||||
val newBytes = stringBuilder.toString
|
||||
|
|
|
|||
|
|
@ -119,8 +119,7 @@ private[sbt] object EvaluateConfigurations {
|
|||
offset: Int
|
||||
): LazyClassLoaded[Seq[Setting[_]]] = {
|
||||
val l = evaluateSbtFile(eval, file, lines, imports, offset)
|
||||
loader =>
|
||||
l(loader).settings
|
||||
loader => l(loader).settings
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -160,8 +159,7 @@ private[sbt] object EvaluateConfigurations {
|
|||
eval.unlinkDeferred()
|
||||
// Tracks all the files we generated from evaluating the sbt file.
|
||||
val allGeneratedFiles = (definitions.generated ++ dslEntries.flatMap(_.generated))
|
||||
loader =>
|
||||
{
|
||||
loader => {
|
||||
val projects = {
|
||||
val compositeProjects = definitions.values(loader).collect {
|
||||
case p: CompositeProject => p
|
||||
|
|
|
|||
|
|
@ -132,7 +132,9 @@ private[sbt] object Load {
|
|||
}
|
||||
|
||||
private def bootIvyHome(app: xsbti.AppConfiguration): Option[File] =
|
||||
try { Option(app.provider.scalaProvider.launcher.ivyHome) } catch {
|
||||
try {
|
||||
Option(app.provider.scalaProvider.launcher.ivyHome)
|
||||
} catch {
|
||||
case _: NoSuchMethodError => None
|
||||
}
|
||||
|
||||
|
|
@ -176,8 +178,7 @@ private[sbt] object Load {
|
|||
val imports =
|
||||
BuildUtil.baseImports ++ config.detectedGlobalPlugins.imports
|
||||
|
||||
loader =>
|
||||
{
|
||||
loader => {
|
||||
val loaded = EvaluateConfigurations(eval, files, imports)(loader)
|
||||
// TODO - We have a potential leak of config-classes in the global directory right now.
|
||||
// We need to find a way to clean these safely, or at least warn users about
|
||||
|
|
@ -421,8 +422,7 @@ private[sbt] object Load {
|
|||
|
||||
def lazyEval(unit: BuildUnit): () => Eval = {
|
||||
lazy val eval = mkEval(unit)
|
||||
() =>
|
||||
eval
|
||||
() => eval
|
||||
}
|
||||
|
||||
def mkEval(unit: BuildUnit): Eval =
|
||||
|
|
@ -616,8 +616,7 @@ private[sbt] object Load {
|
|||
checkProjectBase(against, fResolved)
|
||||
fResolved
|
||||
}
|
||||
p =>
|
||||
p.copy(base = resolve(p.base))
|
||||
p => p.copy(base = resolve(p.base))
|
||||
}
|
||||
|
||||
def resolveProjects(loaded: PartBuild): LoadedBuild = {
|
||||
|
|
|
|||
|
|
@ -24,8 +24,7 @@ object Resolve {
|
|||
:: resolveConfig(index, key, mask) _
|
||||
:: Nil
|
||||
)
|
||||
scope =>
|
||||
rs.foldLeft(scope)((s, f) => f(s))
|
||||
scope => rs.foldLeft(scope)((s, f) => f(s))
|
||||
}
|
||||
|
||||
def resolveTask(mask: ScopeMask)(scope: Scope): Scope =
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ scalaVersion := "2.12.8"
|
|||
scalacOptions ++= Seq("-feature", "-language:postfixOps")
|
||||
|
||||
addSbtPlugin("org.scala-sbt" % "sbt-houserules" % "0.3.9")
|
||||
addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.5.1")
|
||||
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.0.0")
|
||||
addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.4.1")
|
||||
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "3.0.2")
|
||||
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
|
||||
|
|
|
|||
|
|
@ -68,7 +68,9 @@ class Run(newLoader: Seq[File] => ClassLoader, trapExit: Boolean) extends ScalaR
|
|||
log.info("Running " + mainClass + " " + options.mkString(" "))
|
||||
|
||||
def execute() =
|
||||
try { run0(mainClass, classpath, options, log) } catch {
|
||||
try {
|
||||
run0(mainClass, classpath, options, log)
|
||||
} catch {
|
||||
case e: java.lang.reflect.InvocationTargetException => throw e.getCause
|
||||
}
|
||||
def directExecute(): Try[Unit] =
|
||||
|
|
@ -109,7 +111,9 @@ class Run(newLoader: Seq[File] => ClassLoader, trapExit: Boolean) extends ScalaR
|
|||
val currentThread = Thread.currentThread
|
||||
val oldLoader = Thread.currentThread.getContextClassLoader
|
||||
currentThread.setContextClassLoader(loader)
|
||||
try { main.invoke(null, options.toArray[String]); () } catch {
|
||||
try {
|
||||
main.invoke(null, options.toArray[String]); ()
|
||||
} catch {
|
||||
case t: Throwable =>
|
||||
t.getCause match {
|
||||
case e: java.lang.IllegalAccessError =>
|
||||
|
|
|
|||
|
|
@ -59,7 +59,9 @@ object TrapExit {
|
|||
|
||||
private[this] def runUnmanaged(execute: => Unit, log: Logger): Int = {
|
||||
log.warn("Managed execution not possible: security manager not installed.")
|
||||
try { execute; 0 } catch {
|
||||
try {
|
||||
execute; 0
|
||||
} catch {
|
||||
case e: Exception =>
|
||||
log.error("Error during execution: " + e.toString)
|
||||
log.trace(e)
|
||||
|
|
@ -153,7 +155,9 @@ private final class TrapExit(delegateManager: SecurityManager) extends SecurityM
|
|||
def runManaged(f: Supplier[Unit], xlog: xsbti.Logger): Int = {
|
||||
val _ = running.incrementAndGet()
|
||||
try runManaged0(f, xlog)
|
||||
finally { running.decrementAndGet(); () }
|
||||
finally {
|
||||
running.decrementAndGet(); ()
|
||||
}
|
||||
}
|
||||
private[this] def runManaged0(f: Supplier[Unit], xlog: xsbti.Logger): Int = {
|
||||
val log: Logger = xlog
|
||||
|
|
|
|||
|
|
@ -176,10 +176,14 @@ object TestServer {
|
|||
try {
|
||||
f(testServer)
|
||||
} finally {
|
||||
try { testServer.bye() } finally {}
|
||||
try {
|
||||
testServer.bye()
|
||||
} finally {}
|
||||
}
|
||||
case _ =>
|
||||
try { testServer.bye() } finally {}
|
||||
try {
|
||||
testServer.bye()
|
||||
} finally {}
|
||||
hostLog("Server started but not connected properly... restarting...")
|
||||
withTestServer(testBuild)(f)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,8 +61,7 @@ final class ScriptedTests(
|
|||
val g = groupDir.getName
|
||||
val n = nme.getName
|
||||
val label = s"$g / $n"
|
||||
() =>
|
||||
{
|
||||
() => {
|
||||
println(s"Running $label")
|
||||
val result = testResources.readWriteResourceDirectory(g, n) { testDirectory =>
|
||||
val buffer = new BufferedLogger(new FullLogger(log))
|
||||
|
|
@ -140,7 +139,7 @@ final class ScriptedTests(
|
|||
|
||||
def logTests(size: Int, how: String) =
|
||||
log.info(
|
||||
f"Running $size / $totalSize (${size * 100D / totalSize}%3.2f%%) scripted tests with $how"
|
||||
f"Running $size / $totalSize (${size * 100d / totalSize}%3.2f%%) scripted tests with $how"
|
||||
)
|
||||
logTests(runFromSourceBasedTests.size, "RunFromSourceMain")
|
||||
logTests(launcherBasedTests.size, "sbt/launcher")
|
||||
|
|
|
|||
|
|
@ -100,13 +100,19 @@ trait Streams[Key] {
|
|||
def use[T](key: Key)(f: TaskStreams[Key] => T): T = {
|
||||
val s = apply(key)
|
||||
s.open()
|
||||
try { f(s) } finally { s.close() }
|
||||
try {
|
||||
f(s)
|
||||
} finally {
|
||||
s.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
trait CloseableStreams[Key] extends Streams[Key] with java.io.Closeable
|
||||
object Streams {
|
||||
private[this] val closeQuietly = (c: Closeable) =>
|
||||
try { c.close() } catch { case _: IOException => () }
|
||||
try {
|
||||
c.close()
|
||||
} catch { case _: IOException => () }
|
||||
|
||||
def closeable[Key](delegate: Streams[Key]): CloseableStreams[Key] = new CloseableStreams[Key] {
|
||||
private[this] val streams = new collection.mutable.HashMap[Key, ManagedStreams[Key]]
|
||||
|
|
|
|||
|
|
@ -29,7 +29,11 @@ object TaskGen extends std.TaskExtra {
|
|||
Execute.noTriggers,
|
||||
ExecuteProgress.empty[Task]
|
||||
)(std.Transform(dummies))
|
||||
try { x.run(root)(service) } finally { shutdown() }
|
||||
try {
|
||||
x.run(root)(service)
|
||||
} finally {
|
||||
shutdown()
|
||||
}
|
||||
}
|
||||
def tryRun[T](root: Task[T], checkCycles: Boolean, maxWorkers: Int): T =
|
||||
run(root, checkCycles, maxWorkers) match {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,9 @@ object TaskRunnerCircularTest extends Properties("TaskRunner Circular") {
|
|||
else
|
||||
iterate(task(t - 1).named((t - 1).toString))
|
||||
}
|
||||
try { checkResult(tryRun(iterate(top), true, workers), intermediate) } catch {
|
||||
try {
|
||||
checkResult(tryRun(iterate(top), true, workers), intermediate)
|
||||
} catch {
|
||||
case i: Incomplete if cyclic(i) => ("Unexpected cyclic exception: " + i) |: false
|
||||
}
|
||||
}
|
||||
|
|
@ -40,7 +42,9 @@ object TaskRunnerCircularTest extends Properties("TaskRunner Circular") {
|
|||
else
|
||||
iterate(task(t - 1).named((t - 1).toString), i - 1)
|
||||
}
|
||||
try { tryRun(top, true, workers); false } catch { case i: Incomplete => cyclic(i) }
|
||||
try {
|
||||
tryRun(top, true, workers); false
|
||||
} catch { case i: Incomplete => cyclic(i) }
|
||||
}
|
||||
|
||||
def cyclic(i: Incomplete) =
|
||||
|
|
|
|||
|
|
@ -89,7 +89,11 @@ object TaskTest {
|
|||
Execute.noTriggers,
|
||||
ExecuteProgress.empty[Task]
|
||||
)(taskToNode(idK[Task]))
|
||||
try { x.run(root)(service) } finally { shutdown() }
|
||||
try {
|
||||
x.run(root)(service)
|
||||
} finally {
|
||||
shutdown()
|
||||
}
|
||||
}
|
||||
def tryRun[T](
|
||||
root: Task[T],
|
||||
|
|
|
|||
|
|
@ -37,15 +37,18 @@ object CompletionService {
|
|||
val future = try completion.submit { new Callable[T] { def call = work() } } catch {
|
||||
case _: RejectedExecutionException => throw Incomplete(None, message = Some("cancelled"))
|
||||
}
|
||||
() =>
|
||||
future.get()
|
||||
() => future.get()
|
||||
}
|
||||
def manage[A, T](
|
||||
service: CompletionService[A, T]
|
||||
)(setup: A => Unit, cleanup: A => Unit): CompletionService[A, T] =
|
||||
wrap(service) { (node, work) => () =>
|
||||
setup(node)
|
||||
try { work() } finally { cleanup(node) }
|
||||
try {
|
||||
work()
|
||||
} finally {
|
||||
cleanup(node)
|
||||
}
|
||||
}
|
||||
def wrap[A, T](
|
||||
service: CompletionService[A, T]
|
||||
|
|
|
|||
|
|
@ -81,7 +81,9 @@ private[sbt] final class Execute[F[_] <: AnyRef](
|
|||
"State: " + state.toString + "\n\nResults: " + results + "\n\nCalls: " + callers + "\n\n"
|
||||
|
||||
def run[A](root: F[A])(implicit strategy: Strategy): Result[A] =
|
||||
try { runKeep(root)(strategy)(root) } catch { case i: Incomplete => Inc(i) }
|
||||
try {
|
||||
runKeep(root)(strategy)(root)
|
||||
} catch { case i: Incomplete => Inc(i) }
|
||||
|
||||
def runKeep[A](root: F[A])(implicit strategy: Strategy): RMap[F, Result] = {
|
||||
assert(state.isEmpty, "Execute already running/ran.")
|
||||
|
|
|
|||
|
|
@ -104,13 +104,20 @@ class JUnitXmlTestsListener(val outputDir: String, logger: Logger) extends Tests
|
|||
)
|
||||
|
||||
val result =
|
||||
<testsuite hostname={ hostname } name={ name } tests={ tests + "" } errors={ errors + "" } failures={ failures + "" } skipped={ ignoredSkippedPending + "" } time={ (duration / 1000.0).toString } timestamp={formatISO8601DateTime(timestamp)}>
|
||||
<testsuite hostname={hostname} name={name} tests={tests + ""} errors={errors + ""} failures={
|
||||
failures + ""
|
||||
} skipped={ignoredSkippedPending + ""} time={(duration / 1000.0).toString} timestamp={
|
||||
formatISO8601DateTime(timestamp)
|
||||
}>
|
||||
{properties}
|
||||
{
|
||||
for (e <- events) yield <testcase classname={ name } name={
|
||||
for (e <- events)
|
||||
yield
|
||||
<testcase classname={name} name={
|
||||
e.selector match {
|
||||
case selector: TestSelector => selector.testName.split('.').last
|
||||
case nested: NestedTestSelector => nested.suiteId().split('.').last + "." + nested.testName()
|
||||
case nested: NestedTestSelector =>
|
||||
nested.suiteId().split('.').last + "." + nested.testName()
|
||||
case other => s"(It is not a test it is a ${other.getClass.getCanonicalName})"
|
||||
}
|
||||
} time={(e.duration() / 1000.0).toString}>
|
||||
|
|
@ -125,9 +132,15 @@ class JUnitXmlTestsListener(val outputDir: String, logger: Logger) extends Tests
|
|||
""
|
||||
}
|
||||
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 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 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 _ => {}
|
||||
|
|
|
|||
|
|
@ -272,7 +272,11 @@ object TestFramework {
|
|||
private[this] def withContextLoader[T](loader: ClassLoader)(eval: => T): T = {
|
||||
val oldLoader = Thread.currentThread.getContextClassLoader
|
||||
Thread.currentThread.setContextClassLoader(loader)
|
||||
try { eval } finally { Thread.currentThread.setContextClassLoader(oldLoader) }
|
||||
try {
|
||||
eval
|
||||
} finally {
|
||||
Thread.currentThread.setContextClassLoader(oldLoader)
|
||||
}
|
||||
}
|
||||
@deprecated("1.3.0", "This has been replaced by the ClassLoaders.test task.")
|
||||
def createTestLoader(
|
||||
|
|
|
|||
Loading…
Reference in New Issue