deprecations

This commit is contained in:
Mark Harrah 2013-02-25 09:24:04 -05:00
parent a61421dcb8
commit f6d73128fc
62 changed files with 225 additions and 242 deletions

View File

@ -251,7 +251,7 @@ trait UnionImplicits
new UnionCache[H :+: T, UB]
{
val size = 1 + t.size
def c = mf.erasure
def c = mf.runtimeClass
def find(value: UB): Found[_] =
if(c.isInstance(value)) new Found[head.Internal](head, c, head.convert(value.asInstanceOf[H]), size - 1) else t.find(value)
def at(i: Int): (InputCache[_ <: UB], Class[_]) = if(size == i + 1) (head, c) else t.at(i)
@ -259,8 +259,8 @@ trait UnionImplicits
implicit def unionNil[UB]: UnionCache[HNil, UB] = new UnionCache[HNil, UB] {
def size = 0
def find(value: UB) = error("No valid sum type for " + value)
def at(i: Int) = error("Invalid union index " + i)
def find(value: UB) = sys.error("No valid sum type for " + value)
def at(i: Int) = sys.error("Invalid union index " + i)
}
final class Found[I](val cache: InputCache[_] { type Internal = I }, val clazz: Class[_], val value: I, val index: Int)

View File

@ -95,7 +95,7 @@ object New
def designator(p: List[String]): Projection =
p match
{
case Nil => error("Empty path")
case Nil => sys.error("Empty path")
case x :: Nil => projection( singleton(Nil), x)
case xs => projection( singleton(p.dropRight(1)), p.last )
}

View File

@ -32,7 +32,7 @@ object ConflictWarning
log.log(config.level, conflictMsgs.mkString(msg, "\n ", ""))
if(config.failOnConflict)
error("Conflicts in " + conflicts.map(_._1).mkString(", ") )
sys.error("Conflicts in " + conflicts.map(_._1).mkString(", ") )
}
}
@ -51,7 +51,7 @@ object ConflictWarning
log.log(config.level, conflictMsgs.mkString(pre, "\n ", ""))
if(config.failOnConflict) {
val summary = crossMismatches.map{ case ((org,raw),_) => idString(org,raw)}.mkString(", ")
error("Conflicting cross-version suffixes in: " + summary)
sys.error("Conflicting cross-version suffixes in: " + summary)
}
}
}

View File

@ -478,10 +478,10 @@ private object IvySbt
{
def check(found: NodeSeq, expected: String, label: String) =
if(found.isEmpty)
error("Missing " + label + " in inline Ivy XML.")
sys.error("Missing " + label + " in inline Ivy XML.")
else {
val str = found.text
if(str != expected) error("Inconsistent " + label + " in inline Ivy XML. Expected '" + expected + "', got '" + str + "'")
if(str != expected) sys.error("Inconsistent " + label + " in inline Ivy XML. Expected '" + expected + "', got '" + str + "'")
}
check(info \ "@organisation", module.organization, "organisation")
check(info \ "@module", module.name, "name")
@ -637,7 +637,7 @@ private object IvySbt
md match
{
case dmd: DefaultModuleDescriptor => dmd
case _ => error("Unknown ModuleDescriptor type.")
case _ => sys.error("Unknown ModuleDescriptor type.")
}
def getConfigurations(module: ModuleDescriptor, configurations: Option[Iterable[Configuration]]) =
configurations match

View File

@ -102,6 +102,6 @@ private class FileDownloader extends ResourceDownloader with NotNull
val part = new File(dest.getAbsolutePath + ".part")
FileUtil.copy(resource.openStream, part, null)
if(!part.renameTo(dest))
error("Could not move temporary file " + part + " to final location " + dest)
sys.error("Could not move temporary file " + part + " to final location " + dest)
}
}

View File

@ -275,7 +275,7 @@ class MakePom(val log: Logger)
def toID(name: String) = checkID(name.filter(isValidIDCharacter).mkString, name)
def isValidIDCharacter(c: Char) = c.isLetterOrDigit
private def checkID(id: String, name: String) = if(id.isEmpty) error("Could not convert '" + name + "' to an ID") else id
private def checkID(id: String, name: String) = if(id.isEmpty) sys.error("Could not convert '" + name + "' to an ID") else id
def mavenRepository(repo: MavenRepository): XNode =
mavenRepository(toID(repo.name), repo.name, repo.root)
def mavenRepository(id: String, name: String, root: String): XNode =

View File

@ -22,7 +22,7 @@ package sbt
class ProjectResolver(name: String, map: Map[ModuleRevisionId, ModuleDescriptor]) extends ResolverAdapter
{
def getName = name
def setName(name: String) = error("Setting name not supported by ProjectResolver")
def setName(name: String) = sys.error("Setting name not supported by ProjectResolver")
override def toString = "ProjectResolver(" + name + ", mapped: " + map.keys.mkString(", ") + ")"
def getDependency(dd: DependencyDescriptor, data: ResolveData): ResolvedModuleRevision =
@ -59,7 +59,7 @@ class ProjectResolver(name: String, map: Map[ModuleRevisionId, ModuleDescriptor]
}
// doesn't support publishing
def publish(artifact: IArtifact, src: File, overwrite: Boolean) = error("Publish not supported by ProjectResolver")
def publish(artifact: IArtifact, src: File, overwrite: Boolean) = sys.error("Publish not supported by ProjectResolver")
def beginPublishTransaction(module: ModuleRevisionId, overwrite: Boolean) {}
def abortPublishTransaction() {}
def commitPublishTransaction() {}
@ -77,5 +77,5 @@ class ProjectResolver(name: String, map: Map[ModuleRevisionId, ModuleDescriptor]
def dumpSettings() {}
def setSettings(settings: ResolverSettings) { this.settings = Some(settings) }
def getRepositoryCacheManager = settings match { case Some(s) => s.getDefaultRepositoryCacheManager; case None => error("No settings defined for ProjectResolver") }
def getRepositoryCacheManager = settings match { case Some(s) => s.getDefaultRepositoryCacheManager; case None => sys.error("No settings defined for ProjectResolver") }
}

View File

@ -64,7 +64,7 @@ object Sync
"\n\t" + target + "\nfrom\n\t" + srcs.mkString("\n\t\t")
}
if(!dups.isEmpty)
error("Duplicate mappings:" + dups.mkString)
sys.error("Duplicate mappings:" + dups.mkString)
}
import java.io.{File, IOException}

View File

@ -66,7 +66,7 @@ object Tests
option match
{
case Filter(include) => testFilters += include
case Filters(includes) => if(!orderedFilters.isEmpty) error("Cannot define multiple ordered test filters.") else orderedFilters = includes
case Filters(includes) => if(!orderedFilters.isEmpty) sys.error("Cannot define multiple ordered test filters.") else orderedFilters = includes
case Exclude(exclude) => excludeTestsSet ++= exclude
case Listeners(listeners) => testListeners ++= listeners
case Setup(setupFunction) => setup += setupFunction

View File

@ -7,7 +7,7 @@ import interpreter.AbstractFileClassLoader
import io.{AbstractFile, PlainFile, VirtualDirectory}
import ast.parser.Tokens
import reporters.{ConsoleReporter, Reporter}
import util.BatchSourceFile
import scala.reflect.internal.util.BatchSourceFile
import Tokens.{EOF, NEWLINE, NEWLINES, SEMI}
import java.io.File
import java.nio.ByteBuffer

View File

@ -50,7 +50,7 @@ object CommandUtil
else
layoutDetails(details)
} catch {
case pse: PatternSyntaxException => error("Invalid regular expression (java.util.regex syntax).\n" + pse.getMessage)
case pse: PatternSyntaxException => sys.error("Invalid regular expression (java.util.regex syntax).\n" + pse.getMessage)
}
}
def searchHelp(selected: String, detailMap: Map[String, String]): Map[String, String] =

View File

@ -93,7 +93,7 @@ object InputTask
private[this] def dummyTask[I]: (AttributeKey[Option[I]], Task[I]) =
{
val key = localKey[Option[I]]
val f: () => I = () => error(s"Internal sbt error: InputTask stub was not substituted properly.")
val f: () => I = () => sys.error(s"Internal sbt error: InputTask stub was not substituted properly.")
val t: Task[I] = Task(Info[I]().set(key, None), Pure(f, false))
(key, t)
}

View File

@ -267,7 +267,7 @@ object TaskMacro
val WrapName = "parser_\u2603\u2603"
@compileTimeOnly("`parsed` can only be used within an input task macro, such as := or Def.inputTask.")
def parser_\u2603\u2603[T](i: Initialize[State => Parser[T]]): T = error("This method is an implementation detail and should not be referenced.")
def parser_\u2603\u2603[T](i: Initialize[State => Parser[T]]): T = sys.error("This method is an implementation detail and should not be referenced.")
def wrap[T: c.WeakTypeTag](c: Context)(ts: c.Expr[Any], pos: c.Position): c.Expr[T] =
InputWrapper.wrapImpl[T,ParserInput.type](c, ParserInput, WrapName)(ts, pos)
@ -314,14 +314,14 @@ object TaskMacro
// Tree for InputTask.<name>[<tpeA>, <tpeB>](arg1)(arg2)
def inputTaskCreate(name: String, tpeA: Type, tpeB: Type, arg1: Tree, arg2: Tree) =
{
val typedApp = TypeApply(Select(it, name), TypeTree(tpeA) :: TypeTree(tpeB) :: Nil)
val typedApp = TypeApply(util.select(it, name), TypeTree(tpeA) :: TypeTree(tpeB) :: Nil)
val app = ApplyTree( ApplyTree(typedApp, arg1 :: Nil), arg2 :: Nil)
c.Expr[Initialize[InputTask[T]]](app)
}
// Tree for InputTask.createFree[<tpe>](arg1)
def inputTaskCreateFree(tpe: Type, arg: Tree) =
{
val typedApp = TypeApply(Select(it, InputTaskCreateFreeName), TypeTree(tpe) :: Nil)
val typedApp = TypeApply(util.select(it, InputTaskCreateFreeName), TypeTree(tpe) :: Nil)
val app = ApplyTree(typedApp, arg :: Nil)
c.Expr[Initialize[InputTask[T]]](app)
}

View File

@ -87,7 +87,7 @@ object BuildLoader
val cs = info.components
for {
resolve <- cs.resolver(new ResolveInfo(uri, staging, config, state))
val base = resolve()
base = resolve()
build <- cs.builder(new BuildInfo(uri, base, config, state))
} yield () => {
val unit = build()

View File

@ -87,7 +87,7 @@ object BuildStreams
axis match
{
case Global => GlobalPath
case This => error("Unresolved This reference for " + label + " in " + displayFull(scoped))
case This => sys.error("Unresolved This reference for " + label + " in " + displayFull(scoped))
case Select(t) => show(t)
}
def nonProjectPath[T](scoped: ScopedKey[T]): Seq[String] =
@ -106,8 +106,8 @@ object BuildStreams
case Global => refTarget(GlobalScope, units(root).localBase, data) / GlobalPath
case Select(br @ BuildRef(uri)) => refTarget(br, units(uri).localBase, data) / BuildUnitPath
case Select(pr @ ProjectRef(uri, id)) => refTarget(pr, units(uri).defined(id).base, data)
case Select(pr) => error("Unresolved project reference (" + pr + ") in " + displayFull(scoped))
case This => error("Unresolved project reference (This) in " + displayFull(scoped))
case Select(pr) => sys.error("Unresolved project reference (" + pr + ") in " + displayFull(scoped))
case This => sys.error("Unresolved project reference (This) in " + displayFull(scoped))
}
def refTarget(ref: ResolvedReference, fallbackBase: File, data: Settings[Scope]): File =

View File

@ -14,7 +14,7 @@ object ConsoleProject
val bindings = ("currentState" -> state) :: ("extracted" -> extracted ) :: Nil
val unit = extracted.currentUnit
val compiler = Compiler.compilers(ClasspathOptions.repl)(state.configuration, log).scalac
val imports = Load.getImports(unit.unit) ++ Load.importAll(bindings.map(_._1))
val imports = BuildUtil.getImports(unit.unit) ++ BuildUtil.importAll(bindings.map(_._1))
val importString = imports.mkString("", ";\n", ";\n\n")
val initCommands = importString + extra
(new Console(compiler))(unit.classpath, options, initCommands, cleanupCommands)(Some(unit.loader), bindings)

View File

@ -24,7 +24,7 @@ object Cross
def versionAndCommand(spacePresent: Boolean) = {
val knownVersions = crossVersions(state)
val version = token(StringBasic.examples(knownVersions : _*))
val spacedVersion = if(spacePresent) version else version & spacedFirst(Switch)
val spacedVersion = if(spacePresent) version else version & spacedFirst(SwitchCommand)
val optionalCommand = token(Space ~> matched(state.combinedParser)) ?? ""
spacedVersion ~ optionalCommand
}

View File

@ -3,7 +3,7 @@
*/
package sbt
import Build.data
import Attributed.data
import Scope.{fillTaskAxis, GlobalScope, ThisScope}
import xsbt.api.Discovery
import xsbti.compile.CompileOrder
@ -115,7 +115,7 @@ object Defaults extends BuildCommon
commands :== Nil,
retrieveManaged :== false,
buildStructure := Project.structure(state.value),
settings := buildStructure.value.data,
settingsData := buildStructure.value.data,
artifactClassifier :== None,
artifactClassifier in packageSrc :== Some(SourceClassifier),
artifactClassifier in packageDoc :== Some(DocClassifier),
@ -158,9 +158,6 @@ object Defaults extends BuildCommon
scalaSource := sourceDirectory.value / "scala",
javaSource := sourceDirectory.value / "java",
unmanagedSourceDirectories := Seq(scalaSource.value, javaSource.value),
// remove when sourceFilter, defaultExcludes are removed
includeFilter in unmanagedSources <<= (sourceFilter in unmanagedSources) or (includeFilter in unmanagedSources),
excludeFilter in unmanagedSources <<= (defaultExcludes in unmanagedSources) or (excludeFilter in unmanagedSources),
unmanagedSources <<= collectFiles(unmanagedSourceDirectories, includeFilter in unmanagedSources, excludeFilter in unmanagedSources),
watchSources in ConfigGlobal <++= unmanagedSources,
managedSourceDirectories := Seq(sourceManaged.value),
@ -175,8 +172,6 @@ object Defaults extends BuildCommon
unmanagedResourceDirectories := Seq(resourceDirectory.value),
managedResourceDirectories := Seq(resourceManaged.value),
resourceDirectories <<= Classpaths.concatSettings(unmanagedResourceDirectories, managedResourceDirectories),
// remove when defaultExcludes are removed
excludeFilter in unmanagedResources <<= (defaultExcludes in unmanagedResources) or (excludeFilter in unmanagedResources),
unmanagedResources <<= collectFiles(unmanagedResourceDirectories, includeFilter in unmanagedResources, excludeFilter in unmanagedResources),
watchSources in ConfigGlobal ++= unmanagedResources.value,
resourceGenerators :== Nil,
@ -187,7 +182,7 @@ object Defaults extends BuildCommon
lazy val outputConfigPaths = Seq(
cacheDirectory := crossTarget.value / CacheDirectoryName / thisProject.value.id / configuration.value.name,
classDirectory := crossTarget.value / (prefix(configuration.value.name) + "classes"),
docDirectory := crossTarget.value / (prefix(configuration.value.name) + "api")
target in doc := crossTarget.value / (prefix(configuration.value.name) + "api")
)
def addBaseSources = Seq(
unmanagedSources := {
@ -615,7 +610,6 @@ object Defaults extends BuildCommon
@deprecated("Use `docTaskSettings` instead", "0.12.0")
def docSetting(key: TaskKey[File]) = docTaskSettings(key)
def docTaskSettings(key: TaskKey[File] = doc): Seq[Setting[_]] = inTask(key)(compileInputsSettings ++ Seq(
target := docDirectory.value, // deprecate docDirectory in favor of 'target in doc'; remove when docDirectory is removed
apiMappings ++= { if(autoAPIMappings.value) APIMappings.extract(dependencyClasspath.value, streams.value.log).toMap else Map.empty[File,URL] },
key in TaskGlobal <<= (compileInputs, target, configuration, apiMappings, streams) map { (in, out, config, xapis, s) =>
val srcs = in.config.sources
@ -806,9 +800,6 @@ object Classpaths
exportedProducts <<= exportProductsTask,
classpathConfiguration := findClasspathConfig(internalConfigurationMap.value, configuration.value, classpathConfiguration.?.value, update.value),
managedClasspath := managedJars(classpathConfiguration.value, classpathTypes.value, update.value),
// remove when defaultExcludes and classpathFilter are removed
excludeFilter in unmanagedJars <<= (defaultExcludes in unmanagedJars) or (excludeFilter in unmanagedJars),
includeFilter in unmanagedJars <<= classpathFilter or (includeFilter in unmanagedJars),
unmanagedJars := findUnmanagedJars(configuration.value, unmanagedBase.value, includeFilter in unmanagedJars value, excludeFilter in unmanagedJars value)
)
def defaultPackageKeys = Seq(packageBin, packageSrc, packageDoc)
@ -1099,14 +1090,14 @@ object Classpaths
def deliverPattern(outputPath: File): String = (outputPath / "[artifact]-[revision](-[classifier]).[ext]").absolutePath
def projectDependenciesTask: Initialize[Task[Seq[ModuleID]]] =
(thisProjectRef, settings, buildDependencies) map { (ref, data, deps) =>
(thisProjectRef, settingsData, buildDependencies) map { (ref, data, deps) =>
deps.classpath(ref) flatMap { dep => (projectID in dep.project) get data map {
_.copy(configurations = dep.configuration, explicitArtifacts = Nil) }
}
}
def depMap: Initialize[Task[Map[ModuleRevisionId, ModuleDescriptor]]] =
(thisProjectRef, settings, buildDependencies, streams) flatMap { (root, data, deps, s) =>
(thisProjectRef, settingsData, buildDependencies, streams) flatMap { (root, data, deps, s) =>
depMap(deps classpathTransitiveRefs root, data, s.log)
}
@ -1142,9 +1133,9 @@ object Classpaths
BuildDependencies(cp.toMap, agg.toMap)
}
def internalDependencies: Initialize[Task[Classpath]] =
(thisProjectRef, classpathConfiguration, configuration, settings, buildDependencies) flatMap internalDependencies0
(thisProjectRef, classpathConfiguration, configuration, settingsData, buildDependencies) flatMap internalDependencies0
def unmanagedDependencies: Initialize[Task[Classpath]] =
(thisProjectRef, configuration, settings, buildDependencies) flatMap unmanagedDependencies0
(thisProjectRef, configuration, settingsData, buildDependencies) flatMap unmanagedDependencies0
def mkIvyConfiguration: Initialize[Task[IvyConfiguration]] =
(fullResolvers, ivyPaths, otherResolvers, moduleConfigurations, offline, checksums in update, appConfiguration, target, streams) map { (rs, paths, other, moduleConfs, off, check, app, t, s) =>
warnResolversConflict(rs ++: other, s.log)
@ -1408,7 +1399,7 @@ trait BuildExtra extends BuildCommon
def seq(settings: Setting[_]*): SettingsDefinition = new Def.SettingList(settings)
def externalIvySettings(file: Initialize[File] = baseDirectory / "ivysettings.xml", addMultiResolver: Boolean = true): Setting[Task[IvyConfiguration]] =
def externalIvySettings(file: Initialize[File] = inBase("ivysettings.xml"), addMultiResolver: Boolean = true): Setting[Task[IvyConfiguration]] =
externalIvySettingsURI(file(_.toURI), addMultiResolver)
def externalIvySettingsURL(url: URL, addMultiResolver: Boolean = true): Setting[Task[IvyConfiguration]] =
externalIvySettingsURI(Def.value(url.toURI), addMultiResolver)
@ -1421,9 +1412,11 @@ trait BuildExtra extends BuildCommon
new ExternalIvyConfiguration(base, u, Some(lock(app)), extraResolvers, s.log) }
}
}
def externalIvyFile(file: Initialize[File] = baseDirectory / "ivy.xml", iScala: Initialize[Option[IvyScala]] = ivyScala): Setting[Task[ModuleSettings]] =
private[this] def inBase(name: String): Initialize[File] = Def.setting { baseDirectory.value / name }
def externalIvyFile(file: Initialize[File] = inBase("ivy.xml"), iScala: Initialize[Option[IvyScala]] = ivyScala): Setting[Task[ModuleSettings]] =
moduleSettings := new IvyFileConfiguration(file.value, iScala.value, ivyValidate.value, managedScalaInstance.value)
def externalPom(file: Initialize[File] = baseDirectory / "pom.xml", iScala: Initialize[Option[IvyScala]] = ivyScala): Setting[Task[ModuleSettings]] =
def externalPom(file: Initialize[File] = inBase("pom.xml"), iScala: Initialize[Option[IvyScala]] = ivyScala): Setting[Task[ModuleSettings]] =
moduleSettings := new PomConfiguration(file.value, ivyScala.value, ivyValidate.value, managedScalaInstance.value)
def runInputTask(config: Configuration, mainClass: String, baseArguments: String*): Initialize[InputTask[Unit]] =
@ -1477,7 +1470,7 @@ trait BuildCommon
}
final class RichAttributed private[sbt](s: Seq[Attributed[File]])
{
def files: Seq[File] = Build data s
def files: Seq[File] = Attributed.data(s)
}
final class RichFiles private[sbt](s: Seq[File])
{

View File

@ -46,7 +46,7 @@ object EvaluateConfigurations
val parsed = parseConfiguration(lines, imports, offset)
val (importDefs, projects) = if(parsed.definitions.isEmpty) (Nil, (l: ClassLoader) => Nil) else {
val definitions = evaluateDefinitions(eval, name, parsed.imports, parsed.definitions)
val imp = Load.importAllRoot(definitions.enclosingModule :: Nil)
val imp = BuildUtil.importAllRoot(definitions.enclosingModule :: Nil)
val projs = (loader: ClassLoader) => definitions.values(loader).map(p => resolveBase(file.getParentFile, p.asInstanceOf[Project]))
(imp, projs)
}
@ -149,7 +149,7 @@ object Index
if(duplicates.isEmpty)
multiMap.collect { case (k, v) if validID(k) => (k, v.head) } toMap;
else
error(duplicates map { case (k, tps) => "'" + k + "' (" + tps.mkString(", ") + ")" } mkString("AttributeKey ID collisions detected for: ", ", ", ""))
sys.error(duplicates map { case (k, tps) => "'" + k + "' (" + tps.mkString(", ") + ")" } mkString("AttributeKey ID collisions detected for: ", ", ", ""))
}
private[this] type TriggerMap = collection.mutable.HashMap[Task[_], Seq[Task[_]]]
def triggers(ss: Settings[Scope]): Triggers[Task] =

View File

@ -77,7 +77,7 @@ object EvaluateTask
val pluginKey = pluginData
val config = defaultConfig(Project.extract(state), pluginDef)
val evaluated = apply(pluginDef, ScopedKey(pluginKey.scope, pluginKey.key), state, root, config)
val (newS, result) = evaluated getOrElse error("Plugin data does not exist for plugin definition at " + pluginDef.root)
val (newS, result) = evaluated getOrElse sys.error("Plugin data does not exist for plugin definition at " + pluginDef.root)
Project.runUnloadHooks(newS) // discard states
processResult(result, log)
}

View File

@ -55,9 +55,9 @@ final case class Extracted(structure: BuildStructure, session: SessionSettings,
private[this] def resolve[T](key: ScopedKey[T]): ScopedKey[T] =
Project.mapScope(Scope.resolveScope(GlobalScope, currentRef.build, rootProject) )( key.scopedKey )
private def getOrError[T](scope: Scope, key: AttributeKey[_], value: Option[T])(implicit display: Show[ScopedKey[_]]): T =
value getOrElse error(display(ScopedKey(scope, key)) + " is undefined.")
value getOrElse sys.error(display(ScopedKey(scope, key)) + " is undefined.")
private def getOrError[T](scope: Scope, key: AttributeKey[T])(implicit display: Show[ScopedKey[_]]): T =
structure.data.get(scope, key) getOrElse error(display(ScopedKey(scope, key)) + " is undefined.")
structure.data.get(scope, key) getOrElse sys.error(display(ScopedKey(scope, key)) + " is undefined.")
def append(settings: Seq[Setting[_]], state: State): State =
{

View File

@ -1,6 +1,6 @@
package sbt
import Load._
import Load.{BuildStructure => _, _}
import Def.{ScopedKey,Setting}
import Scoped._
import Keys._

View File

@ -89,12 +89,6 @@ object Keys
// Filters
val includeFilter = SettingKey[FileFilter]("include-filter", "Filter for including sources and resources files from default directories.", CSetting)
val excludeFilter = SettingKey[FileFilter]("exclude-filter", "Filter for excluding sources and resources files from default directories.", CSetting)
@deprecated("Use `includeFilter`, scoped by respective classpath related task instead. For example, `includeFilter in unmanagedJars`", "0.11.0")
val classpathFilter = SettingKey[FileFilter]("classpath-filter", "Filter for selecting unmanaged dependencies.", DSetting)
@deprecated("Use `includeFilter`, scoped by respective source related task instead. For example, `includeFilter in unmanagedSources`", "0.11.0")
val sourceFilter = SettingKey[FileFilter]("source-filter", "Filter for selecting sources from default directories.", DSetting)
@deprecated("Use `excludeFilter`, scoped by respective task instead. For example, `excludeFilter in unmanagedSources`", "0.11.0")
val defaultExcludes = SettingKey[FileFilter]("default-excludes", "Filter for excluding files, such as sources and resources, by default.", DSetting)
// Resource paths
val resourceDirectory = SettingKey[File]("resource-directory", "Default unmanaged resource directory, used for user-defined resources.", ASetting)
@ -108,8 +102,6 @@ object Keys
// Output paths
val classDirectory = SettingKey[File]("class-directory", "Directory for compiled classes and copied resources.", AMinusSetting)
@deprecated("Use `target`, scoped by the doc task. For example, `target in Compile in doc`", "0.11.0")
val docDirectory = SettingKey[File]("doc-directory", "Directory for generated documentation.", DSetting)
@deprecated("Use the cacheDirectory provided by streams.", "0.13.0")
val cacheDirectory = SettingKey[File]("cache-directory", "Directory used for caching task data.", BMinusSetting)
val cleanFiles = SettingKey[Seq[File]]("clean-files", "The files to recursively delete during a clean.", BSetting)
@ -329,8 +321,6 @@ object Keys
val concurrentRestrictions = SettingKey[Seq[Tags.Rule]]("concurrent-restrictions", "Rules describing restrictions on concurrent task execution.", BSetting)
val cancelable = SettingKey[Boolean]("cancelable", "Enables (true) or disables (false) the ability to interrupt task execution with CTRL+C.", BMinusSetting)
val settingsData = std.FullInstance.settingsData
@deprecated("Use Keys.settingsData.", "0.12.0")
val settings = settingsData
val streams = TaskKey[TaskStreams]("streams", "Provides streams for logging and persisting data.", DTask)
val isDummyTask = AttributeKey[Boolean]("is-dummy-task", "Internal: used to identify dummy tasks. sbt injects values for these tasks at the start of task execution.", Invisible)
val taskDefinitionKey = AttributeKey[ScopedKey[_]]("task-definition-key", "Internal: used to map a task back to its ScopedKey.", Invisible)
@ -349,7 +339,7 @@ object Keys
def dummy[T: Manifest](name: String, description: String): (TaskKey[T], Task[T]) = (TaskKey[T](name, description, DTask), dummyTask(name))
def dummyTask[T](name: String): Task[T] =
{
val base: Task[T] = task( error("Dummy task '" + name + "' did not get converted to a full task.") ) named name
val base: Task[T] = task( sys.error("Dummy task '" + name + "' did not get converted to a full task.") ) named name
base.copy(info = base.info.set(isDummyTask, true))
}
def isDummy(t: Task[_]): Boolean = t.info.attributes.get(isDummyTask) getOrElse false

View File

@ -18,7 +18,8 @@ package sbt
import Keys.{appConfiguration, baseDirectory, configuration, fullResolvers, fullClasspath, pluginData, streams, thisProject, thisProjectRef, update}
import Keys.{exportedProducts, isDummy, loadedBuild, resolvedScoped, taskDefinitionKey}
import tools.nsc.reporters.ConsoleReporter
import Build.{analyzed, data}
import Build.analyzed
import Attributed.data
import Scope.{GlobalScope, ThisScope}
import Types.const
import BuildPaths._
@ -28,7 +29,7 @@ package sbt
object Load
{
// note that there is State passed in but not pulled out
def defaultLoad(state: State, baseDirectory: File, log: Logger, isPlugin: Boolean = false, topLevelExtras: List[URI] = Nil): (() => Eval, BuildStructure) =
def defaultLoad(state: State, baseDirectory: File, log: Logger, isPlugin: Boolean = false, topLevelExtras: List[URI] = Nil): (() => Eval, sbt.BuildStructure) =
{
val globalBase = getGlobalBase(state)
val base = baseDirectory.getCanonicalFile
@ -40,7 +41,7 @@ object Load
definesClass.clear()
result
}
def defaultPreGlobal(state: State, baseDirectory: File, definesClass: DefinesClass, globalBase: File, log: Logger): LoadBuildConfiguration =
def defaultPreGlobal(state: State, baseDirectory: File, definesClass: DefinesClass, globalBase: File, log: Logger): sbt.LoadBuildConfiguration =
{
val provider = state.configuration.provider
val scalaProvider = provider.scalaProvider
@ -52,13 +53,13 @@ object Load
val delegates = defaultDelegates
val pluginMgmt = PluginManagement(loader)
val inject = InjectSettings(injectGlobal(state), Nil, const(Nil))
new LoadBuildConfiguration(stagingDirectory, classpath, loader, compilers, evalPluginDef, definesClass, delegates,
new sbt.LoadBuildConfiguration(stagingDirectory, classpath, loader, compilers, evalPluginDef, definesClass, delegates,
EvaluateTask.injectStreams, pluginMgmt, inject, None, Nil, log)
}
def injectGlobal(state: State): Seq[Setting[_]] =
(appConfiguration in GlobalScope :== state.configuration) +:
EvaluateTask.injectSettings
def defaultWithGlobal(state: State, base: File, rawConfig: LoadBuildConfiguration, globalBase: File, log: Logger): LoadBuildConfiguration =
def defaultWithGlobal(state: State, base: File, rawConfig: sbt.LoadBuildConfiguration, globalBase: File, log: Logger): sbt.LoadBuildConfiguration =
{
val globalPluginsDir = getGlobalPluginsDirectory(state, globalBase)
val withGlobal = loadGlobal(state, base, globalPluginsDir, rawConfig)
@ -66,19 +67,19 @@ object Load
loadGlobalSettings(base, globalBase, globalSettings, withGlobal)
}
def loadGlobalSettings(base: File, globalBase: File, files: Seq[File], config: LoadBuildConfiguration): LoadBuildConfiguration =
def loadGlobalSettings(base: File, globalBase: File, files: Seq[File], config: sbt.LoadBuildConfiguration): sbt.LoadBuildConfiguration =
{
val compiled: ClassLoader => Seq[Setting[_]] =
if(files.isEmpty || base == globalBase) const(Nil) else buildGlobalSettings(globalBase, files, config)
config.copy(injectSettings = config.injectSettings.copy(projectLoaded = compiled))
}
def buildGlobalSettings(base: File, files: Seq[File], config: LoadBuildConfiguration): ClassLoader => Seq[Setting[_]] =
def buildGlobalSettings(base: File, files: Seq[File], config: sbt.LoadBuildConfiguration): ClassLoader => Seq[Setting[_]] =
{
val eval = mkEval(data(config.classpath), base, defaultEvalOptions)
val imports = baseImports ++ importAllRoot(config.globalPluginNames)
val imports = BuildUtil.baseImports ++ BuildUtil.importAllRoot(config.globalPluginNames)
loader => EvaluateConfigurations(eval, files, imports)(loader).settings
}
def loadGlobal(state: State, base: File, global: File, config: LoadBuildConfiguration): LoadBuildConfiguration =
def loadGlobal(state: State, base: File, global: File, config: sbt.LoadBuildConfiguration): sbt.LoadBuildConfiguration =
if(base != global && global.exists) {
val gp = GlobalPlugin.load(global, state, config)
val pm = setGlobalPluginLoader(gp, config.pluginManagement)
@ -89,11 +90,11 @@ object Load
private[this] def setGlobalPluginLoader(gp: GlobalPlugin, pm: PluginManagement): PluginManagement =
{
val newLoader = ClasspathUtilities.toLoader(Build.data(gp.data.fullClasspath), pm.initialLoader)
val newLoader = ClasspathUtilities.toLoader(data(gp.data.fullClasspath), pm.initialLoader)
pm.copy(initialLoader = newLoader)
}
def defaultDelegates: LoadedBuild => Scope => Seq[Scope] = (lb: LoadedBuild) => {
def defaultDelegates: sbt.LoadedBuild => Scope => Seq[Scope] = (lb: sbt.LoadedBuild) => {
val rootProject = getRootProject(lb.units)
def resolveRef(project: Reference): ResolvedReference = Scope.resolveReference(lb.root, rootProject, project)
Scope.delegates(
@ -107,16 +108,16 @@ object Load
(project, extra) => Nil
)
}
def configInherit(lb: LoadedBuild, ref: ResolvedReference, config: ConfigKey, rootProject: URI => String): Seq[ConfigKey] =
def configInherit(lb: sbt.LoadedBuild, ref: ResolvedReference, config: ConfigKey, rootProject: URI => String): Seq[ConfigKey] =
ref match
{
case pr: ProjectRef => configInheritRef(lb, pr, config)
case BuildRef(uri) => configInheritRef(lb, ProjectRef(uri, rootProject(uri)), config)
}
def configInheritRef(lb: LoadedBuild, ref: ProjectRef, config: ConfigKey): Seq[ConfigKey] =
def configInheritRef(lb: sbt.LoadedBuild, ref: ProjectRef, config: ConfigKey): Seq[ConfigKey] =
configurationOpt(lb.units, ref.build, ref.project, config).toList.flatMap(_.extendsConfigs).map(c => ConfigKey(c.name))
def projectInherit(lb: LoadedBuild, ref: ProjectRef): Seq[ProjectRef] =
def projectInherit(lb: sbt.LoadedBuild, ref: ProjectRef): Seq[ProjectRef] =
getProject(lb.units, ref.build, ref.project).delegates
// build, load, and evaluate all units.
@ -128,7 +129,7 @@ object Load
// 6) Load all configurations using build definitions and plugins (their classpaths and loaded instances).
// 7) Combine settings from projects, plugins, and configurations
// 8) Evaluate settings
def apply(rootBase: File, s: State, config: LoadBuildConfiguration): (() => Eval, BuildStructure) =
def apply(rootBase: File, s: State, config: sbt.LoadBuildConfiguration): (() => Eval, sbt.BuildStructure) =
{
// load, which includes some resolution, but can't fill in project IDs yet, so follow with full resolution
val loaded = resolveProjects(load(rootBase, s, config))
@ -139,7 +140,7 @@ object Load
val data = makeSettings(settings, delegates, config.scopeLocal)( Project.showLoadingKey( loaded ) )
val index = structureIndex(data, settings, loaded.extra(data))
val streams = mkStreams(projects, loaded.root, data)
(rootEval, new BuildStructure(projects, loaded.root, settings, data, index, streams, delegates, config.scopeLocal))
(rootEval, new sbt.BuildStructure(projects, loaded.root, settings, data, index, streams, delegates, config.scopeLocal))
}
// map dependencies on the special tasks:
@ -171,28 +172,28 @@ object Load
def setDefinitionKey[T](tk: Task[T], key: ScopedKey[_]): Task[T] =
if(isDummy(tk)) tk else Task(tk.info.set(Keys.taskDefinitionKey, key), tk.work)
def structureIndex(data: Settings[Scope], settings: Seq[Setting[_]], extra: KeyIndex => BuildUtil[_]): StructureIndex =
def structureIndex(data: Settings[Scope], settings: Seq[Setting[_]], extra: KeyIndex => BuildUtil[_]): sbt.StructureIndex =
{
val keys = Index.allKeys(settings)
val attributeKeys = Index.attributeKeys(data) ++ keys.map(_.key)
val scopedKeys = keys ++ data.allKeys( (s,k) => ScopedKey(s,k))
val keyIndex = KeyIndex(scopedKeys)
val aggIndex = KeyIndex.aggregate(scopedKeys, extra(keyIndex))
new StructureIndex(Index.stringToKeyMap(attributeKeys), Index.taskToKeyMap(data), Index.triggers(data), keyIndex, aggIndex)
new sbt.StructureIndex(Index.stringToKeyMap(attributeKeys), Index.taskToKeyMap(data), Index.triggers(data), keyIndex, aggIndex)
}
// Reevaluates settings after modifying them. Does not recompile or reload any build components.
def reapply(newSettings: Seq[Setting[_]], structure: BuildStructure)(implicit display: Show[ScopedKey[_]]): BuildStructure =
def reapply(newSettings: Seq[Setting[_]], structure: sbt.BuildStructure)(implicit display: Show[ScopedKey[_]]): sbt.BuildStructure =
{
val transformed = finalTransforms(newSettings)
val newData = makeSettings(transformed, structure.delegates, structure.scopeLocal)
val newIndex = structureIndex(newData, transformed, index => buildUtil(structure.root, structure.units, index, newData))
val newIndex = structureIndex(newData, transformed, index => BuildUtil(structure.root, structure.units, index, newData))
val newStreams = mkStreams(structure.units, structure.root, newData)
new BuildStructure(units = structure.units, root = structure.root, settings = transformed, data = newData, index = newIndex, streams = newStreams, delegates = structure.delegates, scopeLocal = structure.scopeLocal)
new sbt.BuildStructure(units = structure.units, root = structure.root, settings = transformed, data = newData, index = newIndex, streams = newStreams, delegates = structure.delegates, scopeLocal = structure.scopeLocal)
}
def isProjectThis(s: Setting[_]) = s.key.scope.project match { case This | Select(ThisProject) => true; case _ => false }
def buildConfigurations(loaded: LoadedBuild, rootProject: URI => String, injectSettings: InjectSettings): Seq[Setting[_]] =
def buildConfigurations(loaded: sbt.LoadedBuild, rootProject: URI => String, injectSettings: InjectSettings): Seq[Setting[_]] =
{
((loadedBuild in GlobalScope :== loaded) +:
transformProjectOnly(loaded.root, rootProject, injectSettings.global)) ++
@ -215,7 +216,7 @@ object Load
buildSettings ++ projectSettings
}
}
def pluginGlobalSettings(loaded: LoadedBuild): Seq[Setting[_]] =
def pluginGlobalSettings(loaded: sbt.LoadedBuild): Seq[Setting[_]] =
loaded.units.toSeq flatMap { case (_, build) =>
build.unit.plugins.plugins flatMap { _.globalSettings }
}
@ -230,13 +231,13 @@ object Load
Project.transform(Scope.resolveScope(thisScope, uri, rootProject), settings)
def projectScope(project: Reference): Scope = Scope(Select(project), Global, Global, Global)
def lazyEval(unit: BuildUnit): () => Eval =
def lazyEval(unit: sbt.BuildUnit): () => Eval =
{
lazy val eval = mkEval(unit)
() => eval
}
def mkEval(unit: BuildUnit): Eval = mkEval(unit.definitions, unit.plugins, Nil)
def mkEval(defs: LoadedDefinitions, plugs: LoadedPlugins, options: Seq[String]): Eval =
def mkEval(unit: sbt.BuildUnit): Eval = mkEval(unit.definitions, unit.plugins, Nil)
def mkEval(defs: sbt.LoadedDefinitions, plugs: sbt.LoadedPlugins, options: Seq[String]): Eval =
mkEval(defs.target ++ plugs.classpath, defs.base, options)
def mkEval(classpath: Seq[File], base: File, options: Seq[String]): Eval =
new Eval(options, classpath, s => new ConsoleReporter(s), Some(evalOutputDirectory(base)))
@ -244,29 +245,29 @@ object Load
def configurations(srcs: Seq[File], eval: () => Eval, imports: Seq[String]): ClassLoader => LoadedSbtFile =
if(srcs.isEmpty) const(LoadedSbtFile.empty) else EvaluateConfigurations(eval(), srcs, imports)
def load(file: File, s: State, config: LoadBuildConfiguration): PartBuild =
def load(file: File, s: State, config: sbt.LoadBuildConfiguration): sbt.PartBuild =
load(file, builtinLoader(s, config.copy(pluginManagement = config.pluginManagement.shift, extraBuilds = Nil)), config.extraBuilds.toList )
def builtinLoader(s: State, config: LoadBuildConfiguration): BuildLoader =
def builtinLoader(s: State, config: sbt.LoadBuildConfiguration): BuildLoader =
{
val fail = (uri: URI) => error("Invalid build URI (no handler available): " + uri)
val fail = (uri: URI) => sys.error("Invalid build URI (no handler available): " + uri)
val resolver = (info: BuildLoader.ResolveInfo) => RetrieveUnit(info)
val build = (info: BuildLoader.BuildInfo) => Some(() => loadUnit(info.uri, info.base, info.state, info.config))
val components = BuildLoader.components(resolver, build, full = BuildLoader.componentLoader)
BuildLoader(components, fail, s, config)
}
def load(file: File, loaders: BuildLoader, extra: List[URI]): PartBuild = loadURI(IO.directoryURI(file), loaders, extra)
def loadURI(uri: URI, loaders: BuildLoader, extra: List[URI]): PartBuild =
def load(file: File, loaders: BuildLoader, extra: List[URI]): sbt.PartBuild = loadURI(IO.directoryURI(file), loaders, extra)
def loadURI(uri: URI, loaders: BuildLoader, extra: List[URI]): sbt.PartBuild =
{
IO.assertAbsolute(uri)
val (referenced, map, newLoaders) = loadAll(uri :: extra, Map.empty, loaders, Map.empty)
checkAll(referenced, map)
val build = new PartBuild(uri, map)
val build = new sbt.PartBuild(uri, map)
newLoaders transformAll build
}
def addOverrides(unit: BuildUnit, loaders: BuildLoader): BuildLoader =
def addOverrides(unit: sbt.BuildUnit, loaders: BuildLoader): BuildLoader =
loaders updatePluginManagement PluginManagement.extractOverrides(unit.plugins.fullClasspath)
def addResolvers(unit: BuildUnit, isRoot: Boolean, loaders: BuildLoader): BuildLoader =
def addResolvers(unit: sbt.BuildUnit, isRoot: Boolean, loaders: BuildLoader): BuildLoader =
unit.definitions.builds.flatMap(_.buildLoaders) match
{
case Nil => loaders
@ -276,10 +277,10 @@ object Load
if(isRoot) loaders.setRoot(resolver) else loaders.addNonRoot(unit.uri, resolver)
}
def loaded(unit: BuildUnit): (PartBuildUnit, List[ProjectReference]) =
def loaded(unit: sbt.BuildUnit): (sbt.PartBuildUnit, List[ProjectReference]) =
{
val defined = projects(unit)
if(defined.isEmpty) error("No projects defined in build unit " + unit)
if(defined.isEmpty) sys.error("No projects defined in build unit " + unit)
// since base directories are resolved at this point (after 'projects'),
// we can compare Files instead of converting to URIs
@ -289,16 +290,16 @@ object Load
val explicitRoots = unit.definitions.builds.flatMap(_.rootProject)
val projectsInRoot = if(explicitRoots.isEmpty) defined.filter(isRoot) else explicitRoots
val rootProjects = if(projectsInRoot.isEmpty) defined.head :: Nil else projectsInRoot
(new PartBuildUnit(unit, defined.map(d => (d.id, d)).toMap, rootProjects.map(_.id), buildSettings(unit)), externals)
(new sbt.PartBuildUnit(unit, defined.map(d => (d.id, d)).toMap, rootProjects.map(_.id), buildSettings(unit)), externals)
}
def buildSettings(unit: BuildUnit): Seq[Setting[_]] =
def buildSettings(unit: sbt.BuildUnit): Seq[Setting[_]] =
{
val buildScope = GlobalScope.copy(project = Select(BuildRef(unit.uri)))
val resolve = Scope.resolveBuildScope(buildScope, unit.uri)
Project.transform(resolve, unit.definitions.builds.flatMap(_.settings))
}
@tailrec def loadAll(bases: List[URI], references: Map[URI, List[ProjectReference]], loaders: BuildLoader, builds: Map[URI, PartBuildUnit]): (Map[URI, List[ProjectReference]], Map[URI, PartBuildUnit], BuildLoader) =
@tailrec def loadAll(bases: List[URI], references: Map[URI, List[ProjectReference]], loaders: BuildLoader, builds: Map[URI, sbt.PartBuildUnit]): (Map[URI, List[ProjectReference]], Map[URI, sbt.PartBuildUnit], BuildLoader) =
bases match
{
case b :: bs =>
@ -325,18 +326,18 @@ object Load
{
assert(base.isAbsolute, "Not absolute: " + base)
if(base.isFile)
error("Not a directory: " + base)
sys.error("Not a directory: " + base)
else if(!base.exists)
IO createDirectory base
}
def resolveAll(builds: Map[URI, PartBuildUnit]): Map[URI, LoadedBuildUnit] =
def resolveAll(builds: Map[URI, sbt.PartBuildUnit]): Map[URI, sbt.LoadedBuildUnit] =
{
val rootProject = getRootProject(builds)
builds map { case (uri,unit) =>
(uri, unit.resolveRefs( ref => Scope.resolveProjectRef(uri, rootProject, ref) ))
} toMap;
}
def checkAll(referenced: Map[URI, List[ProjectReference]], builds: Map[URI, PartBuildUnit])
def checkAll(referenced: Map[URI, List[ProjectReference]], builds: Map[URI, sbt.PartBuildUnit])
{
val rootProject = getRootProject(builds)
for( (uri, refs) <- referenced; ref <- refs)
@ -345,7 +346,7 @@ object Load
val loadedUnit = builds(refURI)
if(! (loadedUnit.defined contains refID) ) {
val projectIDs = loadedUnit.defined.keys.toSeq.sorted
error("No project '" + refID + "' in '" + refURI + "'.\nValid project IDs: " + projectIDs.mkString(", "))
sys.error("No project '" + refID + "' in '" + refURI + "'.\nValid project IDs: " + projectIDs.mkString(", "))
}
}
}
@ -360,21 +361,21 @@ object Load
}
p => p.copy(base = resolve(p.base))
}
def resolveProjects(loaded: PartBuild): LoadedBuild =
def resolveProjects(loaded: sbt.PartBuild): sbt.LoadedBuild =
{
val rootProject = getRootProject(loaded.units)
new LoadedBuild(loaded.root, loaded.units map { case (uri, unit) =>
new sbt.LoadedBuild(loaded.root, loaded.units map { case (uri, unit) =>
IO.assertAbsolute(uri)
(uri, resolveProjects(uri, unit, rootProject))
})
}
def resolveProjects(uri: URI, unit: PartBuildUnit, rootProject: URI => String): LoadedBuildUnit =
def resolveProjects(uri: URI, unit: sbt.PartBuildUnit, rootProject: URI => String): sbt.LoadedBuildUnit =
{
IO.assertAbsolute(uri)
val resolve = (_: Project).resolve(ref => Scope.resolveProjectRef(uri, rootProject, ref))
new LoadedBuildUnit(unit.unit, unit.defined mapValues resolve toMap, unit.rootProjects, unit.buildSettings)
new sbt.LoadedBuildUnit(unit.unit, unit.defined mapValues resolve toMap, unit.rootProjects, unit.buildSettings)
}
def projects(unit: BuildUnit): Seq[Project] =
def projects(unit: sbt.BuildUnit): Seq[Project] =
{
// we don't have the complete build graph loaded, so we don't have the rootProject function yet.
// Therefore, we use resolveProjectBuild instead of resolveProjectRef. After all builds are loaded, we can fully resolve ProjectReferences.
@ -382,24 +383,24 @@ object Load
// although the default loader will resolve the project base directory, other loaders may not, so run resolveBase here as well
unit.definitions.projects.map(resolveBuild compose resolveBase(unit.localBase))
}
def getRootProject(map: Map[URI, BuildUnitBase]): URI => String =
def getRootProject(map: Map[URI, sbt.BuildUnitBase]): URI => String =
uri => getBuild(map, uri).rootProjects.headOption getOrElse emptyBuild(uri)
def getConfiguration(map: Map[URI, LoadedBuildUnit], uri: URI, id: String, conf: ConfigKey): Configuration =
def getConfiguration(map: Map[URI, sbt.LoadedBuildUnit], uri: URI, id: String, conf: ConfigKey): Configuration =
configurationOpt(map, uri, id, conf) getOrElse noConfiguration(uri, id, conf.name)
def configurationOpt(map: Map[URI, LoadedBuildUnit], uri: URI, id: String, conf: ConfigKey): Option[Configuration] =
def configurationOpt(map: Map[URI, sbt.LoadedBuildUnit], uri: URI, id: String, conf: ConfigKey): Option[Configuration] =
getProject(map, uri, id).configurations.find(_.name == conf.name)
def getProject(map: Map[URI, LoadedBuildUnit], uri: URI, id: String): ResolvedProject =
def getProject(map: Map[URI, sbt.LoadedBuildUnit], uri: URI, id: String): ResolvedProject =
getBuild(map, uri).defined.getOrElse(id, noProject(uri, id))
def getBuild[T](map: Map[URI, T], uri: URI): T =
map.getOrElse(uri, noBuild(uri))
def emptyBuild(uri: URI) = error("No root project defined for build unit '" + uri + "'")
def noBuild(uri: URI) = error("Build unit '" + uri + "' not defined.")
def noProject(uri: URI, id: String) = error("No project '" + id + "' defined in '" + uri + "'.")
def noConfiguration(uri: URI, id: String, conf: String) = error("No configuration '" + conf + "' defined in project '" + id + "' in '" + uri +"'")
def emptyBuild(uri: URI) = sys.error("No root project defined for build unit '" + uri + "'")
def noBuild(uri: URI) = sys.error("Build unit '" + uri + "' not defined.")
def noProject(uri: URI, id: String) = sys.error("No project '" + id + "' defined in '" + uri + "'.")
def noConfiguration(uri: URI, id: String, conf: String) = sys.error("No configuration '" + conf + "' defined in project '" + id + "' in '" + uri +"'")
def loadUnit(uri: URI, localBase: File, s: State, config: LoadBuildConfiguration): BuildUnit =
def loadUnit(uri: URI, localBase: File, s: State, config: sbt.LoadBuildConfiguration): sbt.BuildUnit =
{
val normBase = localBase.getCanonicalFile
val defDir = projectStandard(normBase)
@ -413,11 +414,11 @@ object Load
val initialProjects = defs.flatMap(_.projectDefinitions(normBase).map(resolveBase(normBase)))
val loadedProjects = loadTransitive(initialProjects, imports, plugs, () => eval, config.injectSettings, Nil)
val loadedDefs = new LoadedDefinitions(defDir, Nil, plugs.loader, defs, loadedProjects, defNames)
new BuildUnit(uri, normBase, loadedDefs, plugs)
val loadedDefs = new sbt.LoadedDefinitions(defDir, Nil, plugs.loader, defs, loadedProjects, defNames)
new sbt.BuildUnit(uri, normBase, loadedDefs, plugs)
}
private[this] def loadTransitive(newProjects: Seq[Project], imports: Seq[String], plugins: LoadedPlugins, eval: () => Eval, injectSettings: InjectSettings, acc: Seq[Project]): Seq[Project] =
private[this] def loadTransitive(newProjects: Seq[Project], imports: Seq[String], plugins: sbt.LoadedPlugins, eval: () => Eval, injectSettings: InjectSettings, acc: Seq[Project]): Seq[Project] =
{
val loaded = newProjects map { project =>
val loadedSbtFiles = loadSettings(project.auto, project.base, imports, plugins, eval, injectSettings)
@ -434,7 +435,7 @@ object Load
loadTransitive(nextProjects, imports, plugins, eval, injectSettings, loadedProjects)
}
private[this] def loadSettings(auto: AddSettings, projectBase: File, buildImports: Seq[String], loadedPlugins: LoadedPlugins, eval: ()=>Eval, injectSettings: InjectSettings): LoadedSbtFile =
private[this] def loadSettings(auto: AddSettings, projectBase: File, buildImports: Seq[String], loadedPlugins: sbt.LoadedPlugins, eval: ()=>Eval, injectSettings: InjectSettings): LoadedSbtFile =
{
lazy val defaultSbtFiles = configurationSources(projectBase)
def settings(ss: Seq[Setting[_]]) = new LoadedSbtFile(ss, Nil, Nil)
@ -471,18 +472,18 @@ object Load
cp filter { f => !files.contains(f.data) }
}
def enableSbtPlugin(config: LoadBuildConfiguration): LoadBuildConfiguration =
def enableSbtPlugin(config: sbt.LoadBuildConfiguration): sbt.LoadBuildConfiguration =
config.copy(injectSettings = config.injectSettings.copy(
global = autoPluginSettings ++ config.injectSettings.global,
project = config.pluginManagement.inject ++ config.injectSettings.project
))
def activateGlobalPlugin(config: LoadBuildConfiguration): LoadBuildConfiguration =
def activateGlobalPlugin(config: sbt.LoadBuildConfiguration): sbt.LoadBuildConfiguration =
config.globalPlugin match
{
case Some(gp) => config.copy(injectSettings = config.injectSettings.copy(project = gp.inject))
case None => config
}
def plugins(dir: File, s: State, config: LoadBuildConfiguration): LoadedPlugins =
def plugins(dir: File, s: State, config: sbt.LoadBuildConfiguration): sbt.LoadedPlugins =
if(hasDefinition(dir))
buildPlugins(dir, s, enableSbtPlugin(activateGlobalPlugin(config)))
else
@ -493,21 +494,21 @@ object Load
import Path._
!(dir * -GlobFilter(DefaultTargetName)).get.isEmpty
}
def noPlugins(dir: File, config: LoadBuildConfiguration): LoadedPlugins =
def noPlugins(dir: File, config: sbt.LoadBuildConfiguration): sbt.LoadedPlugins =
loadPluginDefinition(dir, config, PluginData(config.classpath, None, None))
def buildPlugins(dir: File, s: State, config: LoadBuildConfiguration): LoadedPlugins =
def buildPlugins(dir: File, s: State, config: sbt.LoadBuildConfiguration): sbt.LoadedPlugins =
loadPluginDefinition(dir, config, buildPluginDefinition(dir, s, config))
def loadPluginDefinition(dir: File, config: LoadBuildConfiguration, pluginData: PluginData): LoadedPlugins =
def loadPluginDefinition(dir: File, config: sbt.LoadBuildConfiguration, pluginData: PluginData): sbt.LoadedPlugins =
{
val (definitionClasspath, pluginLoader) = pluginDefinitionLoader(config, pluginData)
loadPlugins(dir, pluginData.copy(dependencyClasspath = definitionClasspath), pluginLoader)
}
def pluginDefinitionLoader(config: LoadBuildConfiguration, dependencyClasspath: Seq[Attributed[File]]): (Seq[Attributed[File]], ClassLoader) =
def pluginDefinitionLoader(config: sbt.LoadBuildConfiguration, dependencyClasspath: Seq[Attributed[File]]): (Seq[Attributed[File]], ClassLoader) =
pluginDefinitionLoader(config, dependencyClasspath, Nil)
def pluginDefinitionLoader(config: LoadBuildConfiguration, pluginData: PluginData): (Seq[Attributed[File]], ClassLoader) =
def pluginDefinitionLoader(config: sbt.LoadBuildConfiguration, pluginData: PluginData): (Seq[Attributed[File]], ClassLoader) =
pluginDefinitionLoader(config, pluginData.dependencyClasspath, pluginData.definitionClasspath)
def pluginDefinitionLoader(config: LoadBuildConfiguration, depcp: Seq[Attributed[File]], defcp: Seq[Attributed[File]]): (Seq[Attributed[File]], ClassLoader) =
def pluginDefinitionLoader(config: sbt.LoadBuildConfiguration, depcp: Seq[Attributed[File]], defcp: Seq[Attributed[File]]): (Seq[Attributed[File]], ClassLoader) =
{
val definitionClasspath =
if(depcp.isEmpty)
@ -528,7 +529,7 @@ object Load
}
(definitionClasspath, pluginLoader)
}
def buildPluginDefinition(dir: File, s: State, config: LoadBuildConfiguration): PluginData =
def buildPluginDefinition(dir: File, s: State, config: sbt.LoadBuildConfiguration): PluginData =
{
val (eval,pluginDef) = apply(dir, s, config)
val pluginState = Project.setProject(Load.initialSession(pluginDef, eval), pluginDef, s)
@ -540,7 +541,7 @@ object Load
def loadDefinition(loader: ClassLoader, definition: String): Build =
ModuleUtilities.getObject(definition, loader).asInstanceOf[Build]
def loadPlugins(dir: File, data: PluginData, loader: ClassLoader): LoadedPlugins =
def loadPlugins(dir: File, data: PluginData, loader: ClassLoader): sbt.LoadedPlugins =
{
val (pluginNames, plugins) = if(data.classpath.isEmpty) (Nil, Nil) else {
val names = getPluginNames(data.classpath, loader)
@ -549,7 +550,7 @@ object Load
catch { case e: LinkageError => incompatiblePlugins(data, e) }
(names, loaded)
}
new LoadedPlugins(dir, data, loader, plugins, pluginNames)
new sbt.LoadedPlugins(dir, data, loader, plugins, pluginNames)
}
private[this] def incompatiblePlugins(data: PluginData, t: LinkageError): Nothing =
{
@ -561,7 +562,7 @@ object Load
throw new IncompatiblePluginsException(msgBase + msgExtra, t)
}
def getPluginNames(classpath: Seq[Attributed[File]], loader: ClassLoader): Seq[String] =
( binaryPlugins(Build.data(classpath), loader) ++ (analyzed(classpath) flatMap findPlugins) ).distinct
( binaryPlugins(data(classpath), loader) ++ (analyzed(classpath) flatMap findPlugins) ).distinct
def binaryPlugins(classpath: Seq[File], loader: ClassLoader): Seq[String] =
{
@ -592,17 +593,17 @@ object Load
}
}
def initialSession(structure: BuildStructure, rootEval: () => Eval, s: State): SessionSettings = {
def initialSession(structure: sbt.BuildStructure, rootEval: () => Eval, s: State): SessionSettings = {
val session = s get Keys.sessionSettings
val currentProject = session map (_.currentProject) getOrElse Map.empty
val currentBuild = session map (_.currentBuild) filter (uri => structure.units.keys exists (uri ==)) getOrElse structure.root
new SessionSettings(currentBuild, projectMap(structure, currentProject), structure.settings, Map.empty, Nil, rootEval)
}
def initialSession(structure: BuildStructure, rootEval: () => Eval): SessionSettings =
def initialSession(structure: sbt.BuildStructure, rootEval: () => Eval): SessionSettings =
new SessionSettings(structure.root, projectMap(structure, Map.empty), structure.settings, Map.empty, Nil, rootEval)
def projectMap(structure: BuildStructure, current: Map[URI, String]): Map[URI, String] =
def projectMap(structure: sbt.BuildStructure, current: Map[URI, String]): Map[URI, String] =
{
val units = structure.units
val getRoot = getRootProject(units)
@ -619,7 +620,7 @@ object Load
@deprecated("Use BuildUtil.baseImports", "0.13.0")
def baseImports = BuildUtil.baseImports
@deprecated("Use BuildUtil.checkCycles", "0.13.0")
def checkCycles(units: Map[URI, LoadedBuildUnit]): Unit = BuildUtil.checkCycles(units)
def checkCycles(units: Map[URI, sbt.LoadedBuildUnit]): Unit = BuildUtil.checkCycles(units)
@deprecated("Use BuildUtil.importAll", "0.13.0")
def importAll(values: Seq[String]): Seq[String] = BuildUtil.importAll(values)
@deprecated("Use BuildUtil.importAllRoot", "0.13.0")
@ -627,7 +628,7 @@ object Load
@deprecated("Use BuildUtil.rootedNames", "0.13.0")
def rootedName(s: String): String = BuildUtil.rootedName(s)
@deprecated("Use BuildUtil.getImports", "0.13.0")
def getImports(unit: BuildUnit): Seq[String] = BuildUtil.getImports(unit)
def getImports(unit: sbt.BuildUnit): Seq[String] = BuildUtil.getImports(unit)
def referenced[PR <: ProjectReference](definitions: Seq[ProjectDefinition[PR]]): Seq[PR] = definitions flatMap { _.referenced }
@ -663,12 +664,12 @@ object Load
@deprecated("PartBuildUnit is now top-level", "0.13.0")
type PartBuildUnit = sbt.PartBuildUnit
@deprecated("Use BuildUtil.apply", "0.13.0")
def buildUtil(root: URI, units: Map[URI, LoadedBuildUnit], keyIndex: KeyIndex, data: Settings[Scope]): BuildUtil[ResolvedProject] = BuildUtil(root, units, keyIndex, data)
def buildUtil(root: URI, units: Map[URI, sbt.LoadedBuildUnit], keyIndex: KeyIndex, data: Settings[Scope]): BuildUtil[ResolvedProject] = BuildUtil(root, units, keyIndex, data)
}
final case class LoadBuildConfiguration(stagingDirectory: File, classpath: Seq[Attributed[File]], loader: ClassLoader,
compilers: Compilers, evalPluginDef: (BuildStructure, State) => PluginData, definesClass: DefinesClass,
delegates: LoadedBuild => Scope => Seq[Scope], scopeLocal: ScopeLocal,
compilers: Compilers, evalPluginDef: (sbt.BuildStructure, State) => PluginData, definesClass: DefinesClass,
delegates: sbt.LoadedBuild => Scope => Seq[Scope], scopeLocal: ScopeLocal,
pluginManagement: PluginManagement, injectSettings: Load.InjectSettings, globalPlugin: Option[GlobalPlugin], extraBuilds: Seq[URI],
log: Logger)
{

View File

@ -172,7 +172,7 @@ object BuiltinCommands
def sortByRank(keys: Seq[AttributeKey[_]]): Seq[AttributeKey[_]] = keys.sortBy(_.rank)
def withDescription(keys: Seq[AttributeKey[_]]): Seq[AttributeKey[_]] = keys.filter(_.description.isDefined)
def isTask(mf: Manifest[_])(implicit taskMF: Manifest[Task[_]], inputMF: Manifest[InputTask[_]]): Boolean =
mf.erasure == taskMF.erasure || mf.erasure == inputMF.erasure
mf.runtimeClass == taskMF.runtimeClass || mf.runtimeClass == inputMF.runtimeClass
def topNRanked(n: Int) = (keys: Seq[AttributeKey[_]]) => sortByRank(keys).take(n)
def highPass(rankCutoff: Int) = (keys: Seq[AttributeKey[_]]) => sortByRank(keys).takeWhile(_.rank <= rankCutoff)

View File

@ -5,7 +5,7 @@ package sbt
import java.io.File
import java.net.URI
import Project._
import Project.{Initialize => _, Setting => _, _}
import Keys.{appConfiguration, stateBuildStructure, commands, configuration, historyPath, projectCommand, sessionSettings, shellPrompt, thisProject, thisProjectRef, watch}
import Scope.{GlobalScope,ThisScope}
import Def.{Flattened, Initialize, ScopedKey, Setting}
@ -143,7 +143,7 @@ object Project extends ProjectExtra
Def.showRelativeKey( ProjectRef(loaded.root, loaded.units(loaded.root).rootProjects.head), loaded.allProjectRefs.size > 1, keyNameColor)
private abstract class ProjectDef[PR <: ProjectReference](val id: String, val base: File, aggregate0: => Seq[PR], dependencies0: => Seq[ClasspathDep[PR]],
delegates0: => Seq[PR], settings0: => Seq[Setting[_]], val configurations: Seq[Configuration], val auto: AddSettings) extends ProjectDefinition[PR]
delegates0: => Seq[PR], settings0: => Seq[Def.Setting[_]], val configurations: Seq[Configuration], val auto: AddSettings) extends ProjectDefinition[PR]
{
lazy val aggregate = aggregate0
lazy val dependencies = dependencies0
@ -154,18 +154,18 @@ object Project extends ProjectExtra
}
def apply(id: String, base: File, aggregate: => Seq[ProjectReference] = Nil, dependencies: => Seq[ClasspathDep[ProjectReference]] = Nil,
delegates: => Seq[ProjectReference] = Nil, settings: => Seq[Setting[_]] = defaultSettings, configurations: Seq[Configuration] = Configurations.default,
delegates: => Seq[ProjectReference] = Nil, settings: => Seq[Def.Setting[_]] = defaultSettings, configurations: Seq[Configuration] = Configurations.default,
auto: AddSettings = AddSettings.allDefaults): Project =
{
DefaultParsers.parse(id, DefaultParsers.ID).left.foreach(errMsg => error("Invalid project ID: " + errMsg))
DefaultParsers.parse(id, DefaultParsers.ID).left.foreach(errMsg => sys.error("Invalid project ID: " + errMsg))
new ProjectDef[ProjectReference](id, base, aggregate, dependencies, delegates, settings, configurations, auto) with Project
}
def resolved(id: String, base: File, aggregate: => Seq[ProjectRef], dependencies: => Seq[ResolvedClasspathDependency], delegates: => Seq[ProjectRef],
settings: Seq[Setting[_]], configurations: Seq[Configuration], auto: AddSettings): ResolvedProject =
settings: Seq[Def.Setting[_]], configurations: Seq[Configuration], auto: AddSettings): ResolvedProject =
new ProjectDef[ProjectRef](id, base, aggregate, dependencies, delegates, settings, configurations, auto) with ResolvedProject
def defaultSettings: Seq[Setting[_]] = Defaults.defaultSettings
def defaultSettings: Seq[Def.Setting[_]] = Defaults.defaultSettings
final class Constructor(p: ProjectReference) {
def %(conf: Configuration): ClasspathDependency = %(conf.name)
@ -173,7 +173,7 @@ object Project extends ProjectExtra
def %(conf: String): ClasspathDependency = new ClasspathDependency(p, Some(conf))
}
def getOrError[T](state: State, key: AttributeKey[T], msg: String): T = state get key getOrElse error(msg)
def getOrError[T](state: State, key: AttributeKey[T], msg: String): T = state get key getOrElse sys.error(msg)
def structure(state: State): BuildStructure = getOrError(state, stateBuildStructure, "No build loaded.")
def session(state: State): SessionSettings = getOrError(state, sessionSettings, "Session not initialized.")
def isProjectLoaded(state: State): Boolean = (state has sessionSettings) && (state has stateBuildStructure)
@ -227,7 +227,7 @@ object Project extends ProjectExtra
}
def setCond[T](key: AttributeKey[T], vopt: Option[T], attributes: AttributeMap): AttributeMap =
vopt match { case Some(v) => attributes.put(key, v); case None => attributes.remove(key) }
def makeSettings(settings: Seq[Setting[_]], delegates: Scope => Seq[Scope], scopeLocal: ScopedKey[_] => Seq[Setting[_]])(implicit display: Show[ScopedKey[_]]) =
def makeSettings(settings: Seq[Def.Setting[_]], delegates: Scope => Seq[Scope], scopeLocal: ScopedKey[_] => Seq[Def.Setting[_]])(implicit display: Show[ScopedKey[_]]) =
Def.make(settings)(delegates, scopeLocal, display)
def equal(a: ScopedKey[_], b: ScopedKey[_], mask: ScopeMask): Boolean =
@ -240,11 +240,11 @@ object Project extends ProjectExtra
ScopedKey( f(key.scope), key.key)
}
def transform(g: Scope => Scope, ss: Seq[Setting[_]]): Seq[Setting[_]] = {
def transform(g: Scope => Scope, ss: Seq[Def.Setting[_]]): Seq[Def.Setting[_]] = {
val f = mapScope(g)
ss.map(_ mapKey f mapReferenced f)
}
def transformRef(g: Scope => Scope, ss: Seq[Setting[_]]): Seq[Setting[_]] = {
def transformRef(g: Scope => Scope, ss: Seq[Def.Setting[_]]): Seq[Def.Setting[_]] = {
val f = mapScope(g)
ss.map(_ mapReferenced f)
}
@ -270,7 +270,7 @@ object Project extends ProjectExtra
val definingScoped = definingScope match { case Some(sc) => ScopedKey(sc, key); case None => scoped }
val comp = Def.compiled(structure.settings, actual)(structure.delegates, structure.scopeLocal, display)
val definedAt = comp get definingScoped map { c =>
def fmt(s: Setting[_]) = s.pos match {
def fmt(s: Def.Setting[_]) = s.pos match {
case pos: FilePosition => (pos.path + ":" + pos.startLine) :: Nil
case NoPosition => Nil
}
@ -337,7 +337,7 @@ object Project extends ProjectExtra
for( (key,compiled) <- cMap; dep <- compiled.dependencies if dep == scoped) yield key
//@deprecated("Use SettingCompletions.setAll when available.", "0.13.0")
def setAll(extracted: Extracted, settings: Seq[Setting[_]]): SessionSettings =
def setAll(extracted: Extracted, settings: Seq[Def.Setting[_]]): SessionSettings =
SettingCompletions.setAll(extracted, settings).session
val ExtraBuilds = AttributeKey[List[URI]]("extra-builds", "Extra build URIs to load in addition to the ones defined by the project.")
@ -365,7 +365,7 @@ object Project extends ProjectExtra
projectReturn(s) match
{
case current :: returnTo :: rest => (setProjectReturn(s, returnTo :: rest), returnTo)
case _ => error("Not currently in a plugin definition")
case _ => sys.error("Not currently in a plugin definition")
}
case Current =>
val base = s.configuration.baseDirectory
@ -391,15 +391,15 @@ object Project extends ProjectExtra
implicit def projectToRef(p: Project): ProjectReference = LocalProject(p.id)
final class RichTaskSessionVar[S](i: Initialize[Task[S]])
final class RichTaskSessionVar[S](i: Def.Initialize[Task[S]])
{
import SessionVar.{persistAndSet, resolveContext, set, transform => tx}
def updateState(f: (State, S) => State): Initialize[Task[S]] = i(t => tx(t, f))
def storeAs(key: TaskKey[S])(implicit f: sbinary.Format[S]): Initialize[Task[S]] = (Keys.resolvedScoped, i) { (scoped, task) =>
def updateState(f: (State, S) => State): Def.Initialize[Task[S]] = i(t => tx(t, f))
def storeAs(key: TaskKey[S])(implicit f: sbinary.Format[S]): Def.Initialize[Task[S]] = (Keys.resolvedScoped, i) { (scoped, task) =>
tx(task, (state, value) => persistAndSet( resolveContext(key, scoped.scope, state), state, value)(f))
}
def keepAs(key: TaskKey[S]): Initialize[Task[S]] =
def keepAs(key: TaskKey[S]): Def.Initialize[Task[S]] =
(i, Keys.resolvedScoped)( (t,scoped) => tx(t, (state,value) => set(resolveContext(key, scoped.scope, state), state, value) ) )
}

View File

@ -130,7 +130,7 @@ object Resolvers
cwd
) !;
if (result != 0)
error("Nonzero exit code (" + result + "): " + command.mkString(" "))
sys.error("Nonzero exit code (" + result + "): " + command.mkString(" "))
}
def creates(file: File)(f: => Unit) =

View File

@ -12,8 +12,8 @@ final case class ScopedKeyData[A](scoped: ScopedKey[A], value: Any)
def description: String = fold(fmtMf("Task: %s"), fmtMf("Input task: %s"),
"Setting: %s = %s" format (key.manifest.toString, value.toString))
def fold[A](targ: OptManifest[_] => A, itarg: OptManifest[_] => A, s: => A): A =
if (key.manifest.erasure == classOf[Task[_]]) targ(key.manifest.typeArguments.head)
else if (key.manifest.erasure == classOf[InputTask[_]]) itarg(key.manifest.typeArguments.head)
if (key.manifest.runtimeClass == classOf[Task[_]]) targ(key.manifest.typeArguments.head)
else if (key.manifest.runtimeClass == classOf[InputTask[_]]) itarg(key.manifest.typeArguments.head)
else s
def fmtMf(s: String): OptManifest[_] => String = s format _
}

View File

@ -13,7 +13,7 @@ object Script
final val Name = "script"
lazy val command =
Command.command(Name) { state =>
val scriptArg = state.remainingCommands.headOption getOrElse error("No script file specified")
val scriptArg = state.remainingCommands.headOption getOrElse sys.error("No script file specified")
val script = new File(scriptArg).getAbsoluteFile
val hash = Hash.halve(Hash.toHex(Hash(script.getAbsolutePath)))
val base = new File(CommandUtil.bootDirectory(state), hash)

View File

@ -92,7 +92,7 @@ object SessionSettings
}
def writeSettings(pref: ProjectRef, settings: List[SessionSetting], original: Seq[Setting[_]], structure: BuildStructure): (Seq[SessionSetting], Seq[Setting[_]]) =
{
val project = Project.getProject(pref, structure).getOrElse(error("Invalid project reference " + pref))
val project = Project.getProject(pref, structure).getOrElse(sys.error("Invalid project reference " + pref))
val writeTo: File = BuildPaths.configurationSources(project.base).headOption.getOrElse(new File(project.base, "build.sbt"))
writeTo.createNewFile()

View File

@ -270,9 +270,9 @@ private[sbt] object SettingCompletions
def keyType[S](key: AttributeKey[_])(onSetting: Manifest[_] => S, onTask: Manifest[_] => S, onInput: Manifest[_] => S)(implicit tm: Manifest[Task[_]], im: Manifest[InputTask[_]]): S =
{
def argTpe = key.manifest.typeArguments.head
val e = key.manifest.erasure
if(e == tm.erasure) onTask(argTpe)
else if(e == im.erasure) onInput(argTpe)
val e = key.manifest.runtimeClass
if(e == tm.runtimeClass) onTask(argTpe)
else if(e == im.runtimeClass) onInput(argTpe)
else onSetting(key.manifest)
}
@ -299,7 +299,7 @@ private[sbt] object SettingCompletions
/** True if the `key` represents a setting or task that may be appended using an assignment method such as `+=`. */
def appendable(key: AttributeKey[_]): Boolean =
{
val underlying = keyUnderlyingType(key).erasure
val underlying = keyUnderlyingType(key).runtimeClass
appendableClasses.exists(_ isAssignableFrom underlying)
}

View File

@ -111,7 +111,7 @@ object Fork
def fork(javaHome: Option[File], jvmOptions: Seq[String], scalaJars: Iterable[File], arguments: Seq[String], workingDirectory: Option[File], env: Map[String,String], connectInput: Boolean, outputStrategy: OutputStrategy): Process =
{
if(scalaJars.isEmpty) error("Scala jars not specified")
if(scalaJars.isEmpty) sys.error("Scala jars not specified")
val scalaClasspathString = "-Xbootclasspath/a:" + scalaJars.map(_.getAbsolutePath).mkString(File.pathSeparator)
val mainClass = if(mainClassName.isEmpty) Nil else mainClassName :: Nil
val options = jvmOptions ++ (scalaClasspathString :: mainClass ::: arguments.toList)

View File

@ -98,7 +98,7 @@ object TrapExit
* If not, `notType` is called with the root cause.*/
private def withCause[CauseType <: Throwable, T](e: Throwable)(withType: CauseType => T)(notType: Throwable => T)(implicit mf: Manifest[CauseType]): T =
{
val clazz = mf.erasure
val clazz = mf.runtimeClass
if(clazz.isInstance(e))
withType(e.asInstanceOf[CauseType])
else

View File

@ -1,3 +1,3 @@
parallelExecution in test := false
parallelExecution in Test := false
libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.10.0" % "test"

View File

@ -3,7 +3,7 @@ import org.scalacheck._
object B extends Properties("B") {
val value = 3
property("Succeed") = Prop.secure {
Counter.i = value
Counter.setI(value)
true
}
}

View File

@ -1,3 +1,5 @@
object Counter {
var i = 0
private[this] var iv = 0
def i: Int = synchronized { iv }
def setI(value: Int): Unit = synchronized { iv = value }
}

View File

@ -31,7 +31,7 @@ class FileCommands(baseDirectory: File) extends BasicStatementHandler
def apply(command: String, arguments: List[String]): Unit =
commands.get(command).map( _(arguments) ).getOrElse(scriptError("Unknown command " + command))
def scriptError(message: String): Some[String] = error("Test script error: " + message)
def scriptError(message: String): Some[String] = sys.error("Test script error: " + message)
def spaced[T](l: Seq[T]) = l.mkString(" ")
def fromStrings(paths: List[String]) = paths.map(fromString)
def fromString(path: String) = new File(baseDirectory, path)
@ -77,7 +77,7 @@ class FileCommands(baseDirectory: File) extends BasicStatementHandler
{
val exitValue = sbt.Process(command :: args, baseDirectory) ! ;
if(exitValue != 0)
error("Nonzero exit value (" + exitValue + ")")
sys.error("Nonzero exit value (" + exitValue + ")")
}
}

View File

@ -38,9 +38,9 @@ class TestScriptParser(handlers: Map[Char, StatementHandler]) extends RegexParse
import IO.read
if(handlers.keys.exists(isWhitespace))
error("Start characters cannot be whitespace")
sys.error("Start characters cannot be whitespace")
if(handlers.keys.exists(key => key == '+' || key == '-'))
error("Start characters cannot be '+' or '-'")
sys.error("Start characters cannot be '+' or '-'")
def parse(scriptFile: File): List[(StatementHandler, Statement)] = parse(read(scriptFile), Some(scriptFile.getCanonicalPath))
def parse(script: String): List[(StatementHandler, Statement)] = parse(script, None)
@ -52,7 +52,7 @@ class TestScriptParser(handlers: Map[Char, StatementHandler]) extends RegexParse
case err: NoSuccess =>
{
val labelString = label.map("'" + _ + "' ").getOrElse("")
error("Could not parse test script, " + labelString + err.toString)
sys.error("Could not parse test script, " + labelString + err.toString)
}
}
}

View File

@ -48,12 +48,12 @@ object ScriptedPlugin extends Plugin {
val scriptedSettings = Seq(
ivyConfigurations += scriptedConf,
scriptedSbt <<= (appConfiguration)(_.provider.id.version),
libraryDependencies <<= (libraryDependencies, scriptedSbt) {(deps, version) => deps :+ "org.scala-sbt" % "scripted-sbt" % version % scriptedConf.toString },
sbtLauncher <<= (appConfiguration)(app => IO.classLocationFile(app.provider.scalaProvider.launcher.getClass)),
sbtTestDirectory <<= sourceDirectory / "sbt-test",
scriptedSbt := appConfiguration.value.provider.id.version,
libraryDependencies += "org.scala-sbt" % "scripted-sbt" % scriptedSbt.value % scriptedConf.toString ,
sbtLauncher := IO.classLocationFile(appConfiguration.value.provider.scalaProvider.launcher.getClass),
sbtTestDirectory := sourceDirectory.value / "sbt-test",
scriptedBufferLog := true,
scriptedClasspath <<= (classpathTypes, update) map { (ct, report) => PathFinder(Classpaths.managedJars(scriptedConf, ct, report).map(_.data)) },
scriptedClasspath := PathFinder(Classpaths.managedJars(scriptedConf, classpathTypes.value, update.value).map(_.data)),
scriptedTests <<= scriptedTestsTask,
scriptedRun <<= scriptedRunTask,
scriptedDependencies <<= (compile in Test, publishLocal) map { (analysis, pub) => Unit },

View File

@ -121,7 +121,7 @@ object ScriptedTests
{
val errors = for(test <- tests.par; err <- test()) yield err
if(errors.nonEmpty)
error(errors.mkString("Failed tests:\n\t", "\n\t", "\n"))
sys.error(errors.mkString("Failed tests:\n\t", "\n\t", "\n"))
}
def get(tests: Seq[String], baseDirectory: File, log: Logger): Seq[ScriptedTest] =
if(tests.isEmpty) listTests(baseDirectory, log) else parseTests(tests)

View File

@ -244,7 +244,7 @@ final class Execute[A[_] <: AnyRef](checkCycles: Boolean, triggers: Triggers[A])
}
}
def remove[K, V](map: Map[K, V], k: K): V = map.remove(k).getOrElse(error("Key '" + k + "' not in map :\n" + map))
def remove[K, V](map: Map[K, V], k: K): V = map.remove(k).getOrElse(sys.error("Key '" + k + "' not in map :\n" + map))
def addReverse(node: A[_], dependent: A[_]): Unit = reverse(node) ++= Seq(dependent)
def addCaller[T](caller: A[T], target: A[T]): Unit = callers.getOrUpdate(target, IDSet.create[A[T]]) += caller

View File

@ -56,7 +56,7 @@ final class TestRunner(framework: Framework, loader: ClassLoader, listeners: Seq
{
case (simple: TestFingerprint, _) => delegate.run(testDefinition.name, simple, handler, args)
case (basic, runner2: Runner2) => runner2.run(testDefinition.name, basic, handler, args)
case _ => error("Framework '" + framework + "' does not support test '" + testDefinition + "'")
case _ => sys.error("Framework '" + framework + "' does not support test '" + testDefinition + "'")
}
final def run(testDefinition: TestDefinition, args: Seq[String]): TestResult.Value =
@ -100,7 +100,7 @@ object TestFramework
{
case newStyle: Array[Fingerprint] => newStyle.toList
case oldStyle: Array[TestFingerprint] => oldStyle.toList
case _ => error("Could not call 'tests' on framework " + framework)
case _ => sys.error("Could not call 'tests' on framework " + framework)
}
private val ScalaCompilerJarPackages = "scala.tools." :: "jline." :: "ch.epfl.lamp." :: Nil

View File

@ -29,7 +29,7 @@ object ContextUtil {
}
}
def unexpectedTree[C <: Context](tree: C#Tree): Nothing = error("Unexpected macro application tree (" + tree.getClass + "): " + tree)
def unexpectedTree[C <: Context](tree: C#Tree): Nothing = sys.error("Unexpected macro application tree (" + tree.getClass + "): " + tree)
}
/** Utility methods for macros. Several methods assume that the context's universe is a full compiler (`scala.tools.nsc.Global`).
@ -161,9 +161,11 @@ final class ContextUtil[C <: Context](val ctx: C)
def singleton[T <: AnyRef with Singleton](i: T)(implicit it: ctx.TypeTag[i.type]): Symbol =
it.tpe match {
case SingleType(_, sym) if !sym.isFreeTerm && sym.isStatic => sym
case x => error("Instance must be static (was " + x + ").")
case x => sys.error("Instance must be static (was " + x + ").")
}
def select(t: Tree, name: String): Tree = Select(t, newTermName(name))
/** Returns the symbol for the non-private method named `name` for the class/module `obj`. */
def method(obj: Symbol, name: String): Symbol = {
val global: Global = ctx.universe.asInstanceOf[Global]

View File

@ -38,7 +38,7 @@ object InputWrapper
final val WrapName = "wrap_\u2603\u2603"
@compileTimeOnly("`value` can only be used within a task or setting macro, such as :=, +=, ++=, Def.task, or Def.setting.")
def wrap_\u2603\u2603[T](in: Any): T = error("This method is an implementation detail and should not be referenced.")
def wrap_\u2603\u2603[T](in: Any): T = sys.error("This method is an implementation detail and should not be referenced.")
def wrapKey[T: c.WeakTypeTag](c: Context)(ts: c.Expr[Any], pos: c.Position): c.Expr[T] = wrapImpl[T,InputWrapper.type](c, InputWrapper, WrapName)(ts, pos)
@ -54,7 +54,7 @@ object InputWrapper
val iw = util.singleton(s)
val tpe = c.weakTypeOf[T]
val nme = newTermName(wrapName).encoded
val sel = Select(Ident(iw), nme)
val sel = util.select(Ident(iw), nme)
sel.setPos(pos) // need to set the position on Select, because that is where the compileTimeOnly check looks
val tree = ApplyTree(TypeApply(sel, TypeTree(tpe) :: Nil), ts.tree :: Nil)
tree.setPos(ts.tree.pos)
@ -147,7 +147,7 @@ object Instance
// no inputs, so construct M[T] via Instance.pure or pure+flatten
def pure(body: Tree): Tree =
{
val typeApplied = TypeApply(Select(instance, PureName), TypeTree(treeType) :: Nil)
val typeApplied = TypeApply(util.select(instance, PureName), TypeTree(treeType) :: Nil)
val p = ApplyTree(typeApplied, Function(Nil, body) :: Nil)
if(t.isLeft) p else flatten(p)
}
@ -155,7 +155,7 @@ object Instance
// the returned Tree will have type M[T]
def flatten(m: Tree): Tree =
{
val typedFlatten = TypeApply(Select(instance, FlattenName), TypeTree(tt.tpe) :: Nil)
val typedFlatten = TypeApply(util.select(instance, FlattenName), TypeTree(tt.tpe) :: Nil)
ApplyTree(typedFlatten, m :: Nil)
}
@ -164,7 +164,7 @@ object Instance
{
val variable = input.local
val param = ValDef(util.parameterModifiers, variable.name, variable.tpt, EmptyTree)
val typeApplied = TypeApply(Select(instance, MapName), variable.tpt :: TypeTree(treeType) :: Nil)
val typeApplied = TypeApply(util.select(instance, MapName), variable.tpt :: TypeTree(treeType) :: Nil)
val mapped = ApplyTree(typeApplied, input.expr :: Function(param :: Nil, body) :: Nil)
if(t.isLeft) mapped else flatten(mapped)
}
@ -177,7 +177,7 @@ object Instance
val bindings = result.extract(param)
val f = Function(param :: Nil, Block(bindings, body))
val ttt = TypeTree(treeType)
val typedApp = TypeApply(Select(instance, ApplyName), TypeTree(result.representationC) :: ttt :: Nil)
val typedApp = TypeApply(util.select(instance, ApplyName), TypeTree(result.representationC) :: ttt :: Nil)
val app = ApplyTree(ApplyTree(typedApp, result.input :: f :: Nil), result.alistInstance :: Nil)
if(t.isLeft) app else flatten(app)
}

View File

@ -34,8 +34,8 @@ object KListBuilder extends TupleBuilder
params match
{
case ValDef(mods, name, tpt, _) :: xs =>
val head = ValDef(mods, name, tpt, Select(Ident(prev.name), "head"))
val tail = localValDef(TypeTree(), Select(Ident(prev.name), "tail"))
val head = ValDef(mods, name, tpt, select(Ident(prev.name), "head"))
val tail = localValDef(TypeTree(), select(Ident(prev.name), "tail"))
val base = head :: revBindings
bindKList(tail, if(xs.isEmpty) base else tail :: base, xs)
case Nil => revBindings.reverse
@ -60,7 +60,7 @@ object KListBuilder extends TupleBuilder
val representationC = PolyType(tcVariable :: Nil, klistType)
val resultType = appliedType(representationC, idTC :: Nil)
val input = klist
val alistInstance = TypeApply(Select(Ident(alist), "klist"), TypeTree(representationC) :: Nil)
val alistInstance = TypeApply(select(Ident(alist), "klist"), TypeTree(representationC) :: Nil)
def extract(param: ValDef) = bindKList(param, Nil, inputs.map(_.local))
}
}

View File

@ -34,8 +34,8 @@ object TupleNBuilder extends TupleBuilder
val input: Tree = mkTuple(inputs.map(_.expr))
val alistInstance: Tree = {
val select = Select(Ident(alist), TupleMethodName + inputs.size.toString)
TypeApply(select, inputs.map(in => TypeTree(in.tpe)))
val selectTree = select(Ident(alist), TupleMethodName + inputs.size.toString)
TypeApply(selectTree, inputs.map(in => TypeTree(in.tpe)))
}
def extract(param: ValDef): List[ValDef] = bindTuple(param, Nil, inputs.map(_.local), 1)
@ -43,7 +43,7 @@ object TupleNBuilder extends TupleBuilder
params match
{
case ValDef(mods, name, tpt, _) :: xs =>
val x = ValDef(mods, name, tpt, Select(Ident(param.name), "_" + i.toString))
val x = ValDef(mods, name, tpt, select(Ident(param.name), "_" + i.toString))
bindTuple(param, x :: revBindings, xs, i+1)
case Nil => revBindings.reverse
}

View File

@ -147,7 +147,7 @@ private[sbt] object Parser
case ConstantLong => new Constant(tag, new java.lang.Long(in.readLong()))
case ConstantDouble => new Constant(tag, new java.lang.Double(in.readDouble()))
case ConstantUTF8 => new Constant(tag, in.readUTF())
case _ => error("Unknown constant: " + tag)
case _ => sys.error("Unknown constant: " + tag)
}
}

View File

@ -52,6 +52,6 @@ object ReflectUtilities
mappings
}
def allVals[T](self: AnyRef)(implicit mt: scala.reflect.Manifest[T]): immutable.SortedMap[String, T] =
allValsC(self, mt.erasure).asInstanceOf[immutable.SortedMap[String,T]]
allValsC(self, mt.runtimeClass).asInstanceOf[immutable.SortedMap[String,T]]
}
final class UninitializedVal(val valName: String, val className: String) extends RuntimeException("val " + valName + " in class " + className + " was null.\nThis is probably an initialization problem and a 'lazy val' should be used.")

View File

@ -47,7 +47,7 @@ object ScalaInstance
else try {
apply(version, launcher.getScala(version, "", org))
} catch {
case x: NoSuchMethodError => error("Incompatible version of the xsbti.Launcher interface. Use an sbt 0.12+ launcher instead.")
case x: NoSuchMethodError => sys.error("Incompatible version of the xsbti.Launcher interface. Use an sbt 0.12+ launcher instead.")
}
/** Creates a ScalaInstance using the given provider to obtain the jars and loader.*/

View File

@ -122,7 +122,7 @@ object ClasspathUtilities
private lazy val (extraJars, extraDirs) =
{
import scala.tools.nsc.GenericRunnerCommand
val settings = (new GenericRunnerCommand(Nil, message => error(message))).settings
val settings = (new GenericRunnerCommand(Nil, message => sys.error(message))).settings
val bootPaths = IO.pathSplit(settings.bootclasspath.value).map(p => new File(p)).toList
val (bootJars, bootDirs) = separate(bootPaths)
val extJars =
@ -134,7 +134,7 @@ object ClasspathUtilities
for(dir <- dir.listFiles(DirectoryFilter))
findJars(dir)
}
for(path <- IO.pathSplit(settings.extdirs.value); val dir = new File(path) if dir.isDirectory)
for(path <- IO.pathSplit(settings.extdirs.value); dir = new File(path) if dir.isDirectory)
findJars(dir)
buffer.readOnly.map(_.getCanonicalFile)
}

View File

@ -20,7 +20,7 @@ abstract class EvaluateSettings[Scope]
private[this] val complete = new LinkedBlockingQueue[Option[Throwable]]
private[this] val static = PMap.empty[ScopedKey, INode]
private[this] def getStatic[T](key: ScopedKey[T]): INode[T] = static get key getOrElse error("Illegal reference to key " + key)
private[this] def getStatic[T](key: ScopedKey[T]): INode[T] = static get key getOrElse sys.error("Illegal reference to key " + key)
private[this] val transform: Initialize ~> INode = new (Initialize ~> INode) { def apply[T](i: Initialize[T]): INode[T] = i match {
case k: Keyed[s, T] => single(getStatic(k.scopedKey), k.transform)
@ -137,7 +137,7 @@ abstract class EvaluateSettings[Scope]
}
protected final def setValue(v: T) {
assert(state != Evaluated, "Already evaluated (trying to set value to " + v + "): " + toString)
if(v == null) error("Setting value cannot be null: " + keyString)
if(v == null) sys.error("Setting value cannot be null: " + keyString)
value = v
state = Evaluated
blocking foreach { _.unblocked() }

View File

@ -77,7 +77,7 @@ trait Init[Scope]
def asTransform(s: Settings[Scope]): ScopedKey ~> Id = new (ScopedKey ~> Id) {
def apply[T](k: ScopedKey[T]): T = getValue(s, k)
}
def getValue[T](s: Settings[Scope], k: ScopedKey[T]) = s.get(k.scope, k.key) getOrElse error("Internal settings error: invalid reference to " + showFullKey(k))
def getValue[T](s: Settings[Scope], k: ScopedKey[T]) = s.get(k.scope, k.key) getOrElse sys.error("Internal settings error: invalid reference to " + showFullKey(k))
def asFunction[T](s: Settings[Scope]): ScopedKey[T] => T = k => getValue(s, k)
def mapScope(f: Scope => Scope): MapScoped = new MapScoped {
def apply[T](k: ScopedKey[T]): ScopedKey[T] = k.copy(scope = f(k.scope))

View File

@ -18,7 +18,7 @@ object EditDistance {
0 to n foreach (x => d(x)(0) = x)
0 to m foreach (x => d(0)(x) = x)
for (i <- 1 to n ; val s_i = s(i - 1) ; j <- 1 to m) {
for (i <- 1 to n ; s_i = s(i - 1) ; j <- 1 to m) {
val t_j = t(j - 1)
val cost = if (s_i == t_j) matchCost else if(lower(s_i) == lower(t_j)) caseCost else subCost
val tcost = if (s_i == t_j) matchCost else transposeCost

View File

@ -127,7 +127,7 @@ object Parser extends ParserMain
def checkMatches(a: Parser[_], completions: Seq[String])
{
val bad = completions.filter( apply(a)(_).resultEmpty.isFailure)
if(!bad.isEmpty) error("Invalid example completions: " + bad.mkString("'", "', '", "'"))
if(!bad.isEmpty) sys.error("Invalid example completions: " + bad.mkString("'", "', '", "'"))
}
def tuple[A,B](a: Option[A], b: Option[B]): Option[(A,B)] =
(a,b) match { case (Some(av), Some(bv)) => Some((av, bv)); case _ => None }
@ -419,7 +419,7 @@ trait ParserMain
def stringLiteral(s: String, start: Int): Parser[String] =
{
val len = s.length
if(len == 0) error("String literal cannot be empty") else if(start >= len) success(s) else new StringLiteral(s, start)
if(len == 0) sys.error("String literal cannot be empty") else if(start >= len) success(s) else new StringLiteral(s, start)
}
}
sealed trait ValidParser[T] extends Parser[T]
@ -433,7 +433,7 @@ private final case class Invalid(fail: Failure) extends Parser[Nothing]
def failure = Some(fail)
def result = None
def resultEmpty = fail
def derive(c: Char) = error("Invalid.")
def derive(c: Char) = sys.error("Invalid.")
def completions(level: Int) = Completions.nil
override def toString = fail.errors.mkString("; ")
def valid = false

View File

@ -149,7 +149,7 @@ object Generator
if(duplicates.isEmpty)
ds.foreach(writeDefinition)
else
error("Duplicate names:\n\t" + duplicates.mkString("\n\t"))
sys.error("Duplicate names:\n\t" + duplicates.mkString("\n\t"))
}
def implName(name: String) = name + "0"
}

View File

@ -42,7 +42,7 @@ object IO
def classLocation(cl: Class[_]): URL =
{
val codeSource = cl.getProtectionDomain.getCodeSource
if(codeSource == null) error("No class location for " + cl)
if(codeSource == null) sys.error("No class location for " + cl)
else codeSource.getLocation
}
@ -54,12 +54,12 @@ object IO
/** Returns a URL for the directory or jar containing the class file for type `T` (as determined by an implicit Manifest).
* If the location cannot be determined, an error is generated.
* Note that Java standard library classes typically do not have a location associated with them.*/
def classLocation[T](implicit mf: SManifest[T]): URL = classLocation(mf.erasure)
def classLocation[T](implicit mf: SManifest[T]): URL = classLocation(mf.runtimeClass)
/** Returns the directory or jar file containing the the class file for type `T` (as determined by an implicit Manifest).
* If the location cannot be determined, an error is generated.
* Note that Java standard library classes typically do not have a location associated with them.*/
def classLocationFile[T](implicit mf: SManifest[T]): File = classLocationFile(mf.erasure)
def classLocationFile[T](implicit mf: SManifest[T]): File = classLocationFile(mf.runtimeClass)
/** Constructs a File corresponding to `url`, which must have a scheme of `file`.
* This method properly works around an issue with a simple conversion to URI and then to a File. */
@ -68,7 +68,7 @@ object IO
catch { case _: URISyntaxException => new File(url.getPath) }
/** Converts the given URL to a File. If the URL is for an entry in a jar, the File for the jar is returned. */
def asFile(url: URL): File = urlAsFile(url) getOrElse error("URL is not a file: " + url)
def asFile(url: URL): File = urlAsFile(url) getOrElse sys.error("URL is not a file: " + url)
def urlAsFile(url: URL): Option[File] =
url.getProtocol match
{
@ -132,7 +132,7 @@ object IO
if(created || absFile.isDirectory)
()
else if(setModified && !absFile.setLastModified(System.currentTimeMillis))
error("Could not update last modified time for file " + absFile)
sys.error("Could not update last modified time for file " + absFile)
}
def createDirectories(dirs: Traversable[File]): Unit =
dirs.foreach(createDirectory)
@ -145,10 +145,10 @@ object IO
if(dir.isDirectory)
()
else if(dir.exists) {
error(failBase + ": file exists and is not a directory.")
sys.error(failBase + ": file exists and is not a directory.")
}
else
error(failBase)
sys.error(failBase)
}
/** Gzips the file 'in' and writes it to 'out'. 'in' cannot be the same file as 'out'. */
@ -291,7 +291,7 @@ object IO
def create(tries: Int): File =
{
if(tries > MaximumTries)
error("Could not create temporary directory.")
sys.error("Could not create temporary directory.")
else
{
val randomName = "sbt_" + java.lang.Integer.toHexString(random.nextInt)
@ -392,7 +392,7 @@ object IO
private def archive(sources: Seq[(File,String)], outputFile: File, manifest: Option[Manifest])
{
if(outputFile.isDirectory)
error("Specified output file " + outputFile + " is a directory.")
sys.error("Specified output file " + outputFile + " is a directory.")
else
{
val outputDir = outputFile.getParentFile
@ -560,7 +560,7 @@ object IO
offset
val copied = loop(0)
if(copied != in.size)
error("Could not copy '" + sourceFile + "' to '" + targetFile + "' (" + copied + "/" + in.size + " bytes copied)")
sys.error("Could not copy '" + sourceFile + "' to '" + targetFile + "' (" + copied + "/" + in.size + " bytes copied)")
}
}
if(preserveLastModified)
@ -578,12 +578,10 @@ object IO
writer(file, content, charset, append) { _.write(content) }
def writer[T](file: File, content: String, charset: Charset, append: Boolean = false)(f: BufferedWriter => T): T =
{
if(charset.newEncoder.canEncode(content))
fileWriter(charset, append)(file) { f }
else
error("String cannot be encoded by charset " + charset.name)
}
sys.error("String cannot be encoded by charset " + charset.name)
def reader[T](file: File, charset: Charset = defaultCharset)(f: BufferedReader => T): T =
fileReader(charset)(file) { f }

View File

@ -72,7 +72,7 @@ object SignJar
{
val exitCode = fork(CommandName, arguments)
if(exitCode != 0)
error("Error " + action + " jar (exit code was " + exitCode + ".)")
sys.error("Error " + action + " jar (exit code was " + exitCode + ".)")
}
private val CommandName = "jarsigner"

View File

@ -161,9 +161,6 @@ sealed abstract class PathFinder
* <code>descendantsExcept("*.jar", ".svn")</code>*/
def descendantsExcept(include: FileFilter, intermediateExclude: FileFilter): PathFinder =
(this ** include) --- (this ** intermediateExclude ** include)
@deprecated("Use `descendantsExcept` instead.", "0.12.0")
def descendentsExcept(include: FileFilter, intermediateExclude: FileFilter): PathFinder =
descendantsExcept(include, intermediateExclude)
/** Evaluates this finder and converts the results to a `Seq` of distinct `File`s. The files returned by this method will reflect the underlying filesystem at the
* time of calling. If the filesystem changes, two calls to this method might be different.*/
@ -174,7 +171,7 @@ sealed abstract class PathFinder
addTo(pathSet)
pathSet.toSeq
}
@deprecated("Use `get`"/*, "0.9.7"*/) def getFiles: Seq[File] = get
/** Only keeps paths for which `f` returns true. It is non-strict, so it is not evaluated until the returned finder is evaluated.*/
final def filter(f: File => Boolean): PathFinder = PathFinder(get filter f)
/* Non-strict flatMap: no evaluation occurs until the returned finder is evaluated.*/

View File

@ -31,7 +31,7 @@ trait Mapper
IO.relativize(oldBase, file).map(normNewBase + _)
}
/** A mapper that throws an exception for any input. This is useful as the last mapper in a pipeline to ensure every input gets mapped.*/
def fail: Any => Nothing = f => error("No mapping for " + f)
def fail: Any => Nothing = f => sys.error("No mapping for " + f)
/** A path mapper that pairs a File with its name. For example, `/x/y/z.txt` gets paired with `z.txt`.*/
val flat: PathMap = f => Some(f.getName)

View File

@ -30,7 +30,7 @@ abstract class Using[Source, T]
import scala.reflect.{Manifest => SManifest}
abstract class WrapUsing[Source, T](implicit srcMf: SManifest[Source], targetMf: SManifest[T]) extends Using[Source, T]
{
protected def label[S](m: SManifest[S]) = m.erasure.getSimpleName
protected def label[S](m: SManifest[S]) = m.runtimeClass.getSimpleName
protected def openImpl(source: Source): T
protected final def open(source: Source): T =
translate("Error wrapping " + label(srcMf) + " in " + label(targetMf) + ": ") { openImpl(source) }

View File

@ -30,7 +30,7 @@ object IPC
try { new ServerSocket(nextPort, 1, loopback) }
catch { case _: Exception => createServer(attempts - 1) }
else
error("Could not connect to socket: maximum attempts exceeded")
sys.error("Could not connect to socket: maximum attempts exceeded")
createServer(10)
}
def server[T](f: IPC => Option[T]): T = serverImpl(makeServer, f)

View File

@ -28,7 +28,7 @@ object WriteContentSpecification extends Properties("Write content")
true
}
private def testUnzip[T](implicit mf: scala.reflect.Manifest[T]) =
unzipFile(IO.classLocationFile(mf.erasure))
unzipFile(IO.classLocationFile(mf.runtimeClass))
private def unzipFile(jar: File) =
IO.withTemporaryDirectory { tmp =>
IO.unzip(jar, tmp)