diff --git a/main/Defaults.scala b/main/Defaults.scala index da3155018..92b3d74a1 100644 --- a/main/Defaults.scala +++ b/main/Defaults.scala @@ -37,7 +37,7 @@ object Defaults extends BuildCommon def lock(app: xsbti.AppConfiguration): xsbti.GlobalLock = app.provider.scalaProvider.launcher.globalLock - def extractAnalysis[T](a: Attributed[T]): (T, inc.Analysis) = + def extractAnalysis[T](a: Attributed[T]): (T, inc.Analysis) = (a.data, a.metadata get Keys.analysis getOrElse inc.Analysis.Empty) def analysisMap[T](cp: Seq[Attributed[T]]): Map[T, inc.Analysis] = @@ -173,7 +173,7 @@ object Defaults extends BuildCommon ) def addBaseSources = Seq( unmanagedSources <<= (unmanagedSources, baseDirectory, includeFilter in unmanagedSources, excludeFilter in unmanagedSources) map { - (srcs,b,f,excl) => (srcs +++ b * (f -- excl)).get + (srcs,b,f,excl) => (srcs +++ b * (f -- excl)).get } ) @@ -261,7 +261,7 @@ object Defaults extends BuildCommon } } - lazy val testTasks: Seq[Setting[_]] = testTaskOptions(test) ++ testTaskOptions(testOnly) ++ Seq( + lazy val testTasks: Seq[Setting[_]] = testTaskOptions(test) ++ testTaskOptions(testOnly) ++ Seq( testLoader <<= (fullClasspath, scalaInstance, taskTemporaryDirectory) map { (cp, si, temp) => TestFramework.createTestLoader(data(cp), si, IO.createUniqueDirectory(temp)) }, testFrameworks in GlobalScope :== { import sbt.TestFrameworks._ @@ -312,7 +312,7 @@ object Defaults extends BuildCommon def testExecutionTask(task: Scoped): Initialize[Task[Tests.Execution]] = (testOptions in task, parallelExecution in task, tags in task) map { (opts, par, ts) => new Tests.Execution(opts, par, ts) } - def testOnlyTask = + def testOnlyTask = InputTask( loadForParser(definedTestNames)( (s, i) => testOnlyParser(s, i getOrElse Nil) ) ) { result => (streams, loadedTestFrameworks, testExecution in testOnly, testLoader, definedTests, resolvedScoped, result, state) flatMap { case (s, frameworks, config, loader, discovered, scoped, (tests, frameworkOptions), st) => @@ -371,9 +371,9 @@ object Defaults extends BuildCommon (files, dirs) map { (rs, rdirs) => (rs --- rdirs) x (relativeTo(rdirs)|flat) toSeq } - + def collectFiles(dirs: ScopedTaskable[Seq[File]], filter: ScopedTaskable[FileFilter], excludes: ScopedTaskable[FileFilter]): Initialize[Task[Seq[File]]] = - (dirs, filter, excludes) map { (d,f,excl) => d.descendentsExcept(f,excl).get } + (dirs, filter, excludes) map { (d,f,excl) => d.descendantsExcept(f,excl).get } def artifactPathSetting(art: SettingKey[Artifact]) = (crossTarget, projectID, art, scalaVersion in artifactName, artifactName) { (t, module, a, sv, toString) => t / toString(sv, module, a) asFile } def artifactSetting = ((artifact, artifactClassifier).identity zipWith configuration.?) { case ((a,classifier),cOpt) => @@ -381,7 +381,7 @@ object Defaults extends BuildCommon val combined = cPart.toList ++ classifier.toList if(combined.isEmpty) a.copy(classifier = None, configurations = cOpt.toList) else { val classifierString = combined mkString "-" - val confs = cOpt.toList flatMap { c => artifactConfigurations(a, c, classifier) } + val confs = cOpt.toList flatMap { c => artifactConfigurations(a, c, classifier) } a.copy(classifier = Some(classifierString), `type` = Artifact.classifierType(classifierString), configurations = confs) } } @@ -445,7 +445,7 @@ object Defaults extends BuildCommon } def runnerTask = runner <<= runnerInit - def runnerInit: Initialize[Task[ScalaRun]] = + def runnerInit: Initialize[Task[ScalaRun]] = (taskTemporaryDirectory, scalaInstance, baseDirectory, javaOptions, outputStrategy, fork, javaHome, trapExit, connectInput) map { (tmp, si, base, options, strategy, forkRun, javaHomeDir, trap, connectIn) => if(forkRun) { @@ -460,7 +460,7 @@ object Defaults extends BuildCommon target <<= docDirectory, // deprecate docDirectory in favor of 'target in doc'; remove when docDirectory is removed scalacOptions <<= scaladocOptions or scalacOptions, // deprecate scaladocOptions in favor of 'scalacOptions in doc'; remove when scaladocOptions is removed key in TaskGlobal <<= (cacheDirectory, compileInputs, target, configuration, streams) map { (cache, in, out, config, s) => - // For Scala/Java hybrid projects, the output docs are rebased to `scala` or `java` sub-directory accordingly. We do hybrid + // For Scala/Java hybrid projects, the output docs are rebased to `scala` or `java` sub-directory accordingly. We do hybrid // mode iff both *.scala and *.java files exist -- other doc resources (package.html, *.jpg etc.) don't influence the decision. val srcs = in.config.sources val hybrid = srcs.exists(_.name.endsWith(".scala")) && srcs.exists(_.name.endsWith(".java")) @@ -494,9 +494,9 @@ object Defaults extends BuildCommon (new Console(cs.scalac))(data(cp), options, initCommands, cleanup, s.log).foreach(msg => error(msg)) println() } - + def compileTask = (compileInputs, streams) map { (i,s) => Compiler(i,s.log) } - def compileIncSetupTask = + def compileIncSetupTask = (dependencyClasspath, cacheDirectory, skip in compile, definesClass) map { (cp, cacheDir, skip, definesC) => Compiler.IncSetup(analysisMap(cp), definesC, skip, cacheDir / "compile") } @@ -576,7 +576,7 @@ object Defaults extends BuildCommon def transitiveDependencies(base: ProjectRef, structure: LoadedBuild, includeRoot: Boolean, classpath: Boolean = true, aggregate: Boolean = false): Seq[ProjectRef] = { - def tdeps(enabled: Boolean, f: ProjectRef => Seq[ProjectRef]): Seq[ProjectRef] = + def tdeps(enabled: Boolean, f: ProjectRef => Seq[ProjectRef]): Seq[ProjectRef] = { val full = if(enabled) Dag.topologicalSort(base)(f) else Nil if(includeRoot) full else full dropRight 1 @@ -596,12 +596,12 @@ object Defaults extends BuildCommon } val CompletionsID = "completions" - + def noAggregation: Seq[Scoped] = Seq(run, console, consoleQuick, consoleProject) lazy val disableAggregation = noAggregation map disableAggregate def disableAggregate(k: Scoped) = aggregate in Scope.GlobalScope.copy(task = Select(k.key)) :== false - + lazy val baseTasks: Seq[Setting[_]] = projectTasks ++ packageBase lazy val baseClasspaths: Seq[Setting[_]] = Classpaths.publishSettings ++ Classpaths.baseSettings @@ -612,7 +612,7 @@ object Defaults extends BuildCommon lazy val itSettings: Seq[Setting[_]] = inConfig(IntegrationTest)(testSettings) lazy val defaultConfigs: Seq[Setting[_]] = inConfig(Compile)(compileSettings) ++ inConfig(Test)(testSettings) ++ inConfig(Runtime)(Classpaths.configSettings) - + // settings that are not specific to a configuration lazy val projectBaseSettings: Seq[Setting[_]] = projectCore ++ paths ++ baseClasspaths ++ baseTasks ++ compileBase ++ disableAggregation @@ -645,7 +645,7 @@ object Classpaths excludeFilter in unmanagedJars <<= (defaultExcludes in unmanagedJars) or (excludeFilter in unmanagedJars), includeFilter in unmanagedJars <<= classpathFilter or (includeFilter in unmanagedJars), unmanagedJars <<= (configuration, unmanagedBase, includeFilter in unmanagedJars, excludeFilter in unmanagedJars) map { (config, base, filter, excl) => - (base * (filter -- excl) +++ (base / config.name).descendentsExcept(filter, excl)).classpath + (base * (filter -- excl) +++ (base / config.name).descendantsExcept(filter, excl)).classpath } ) def defaultPackageKeys = Seq(packageBin, packageSrc, packageDoc) @@ -792,7 +792,7 @@ object Classpaths (projectID, allDependencies, ivyXML, ivyConfigurations, defaultConfiguration, ivyScala, ivyValidate, projectInfo) map { (pid, deps, ivyXML, confs, defaultConf, ivyS, validate, pinfo) => new InlineConfiguration(pid, pinfo, deps, ivyXML, confs, defaultConf, ivyS, validate) } - + def sbtClassifiersTasks = inTask(updateSbtClassifiers)(Seq( transitiveClassifiers in GlobalScope in updateSbtClassifiers ~= ( _.filter(_ != DocClassifier) ), externalResolvers <<= (externalResolvers, appConfiguration) map { (defaultRs, ac) => @@ -855,7 +855,7 @@ object Classpaths out.cachedDescriptor.exists val outCacheFile = cacheFile / "output" - def skipWork: In => UpdateReport = + def skipWork: In => UpdateReport = Tracked.lastOutput[In, UpdateReport](outCacheFile) { case (_, Some(out)) => out case _ => error("Skipping update requested, but update has not previously run successfully.") @@ -913,7 +913,7 @@ object Classpaths } def analyzed[T](data: T, analysis: inc.Analysis) = Attributed.blank(data).put(Keys.analysis, analysis) - def makeProducts: Initialize[Task[Seq[File]]] = + def makeProducts: Initialize[Task[Seq[File]]] = (compile, compileInputs, copyResources) map { (_, i, _) => i.config.classesDirectory :: Nil } def exportProductsTask: Initialize[Task[Classpath]] = (products.task, packageBin.task, exportJars, compile) flatMap { (psTask, pkgTask, useJars, analysis) => @@ -985,7 +985,7 @@ object Classpaths (tasks.toSeq.join).map(_.flatten.distinct) } - + def mapped(confString: Option[String], masterConfs: Seq[String], depConfs: Seq[String], default: String, defaultMapping: String): String => Seq[String] = { lazy val defaultMap = parseMapping(defaultMapping, masterConfs, depConfs, _ :: Nil) @@ -1011,7 +1011,7 @@ object Classpaths def parseList(s: String, allConfs: Seq[String]): Seq[String] = (trim(s split ",") flatMap replaceWildcard(allConfs)).distinct def replaceWildcard(allConfs: Seq[String])(conf: String): Seq[String] = if(conf == "") Nil else if(conf == "*") allConfs else conf :: Nil - + private def trim(a: Array[String]): List[String] = a.toList.map(_.trim) def missingConfiguration(in: String, conf: String) = error("Configuration '" + conf + "' not defined in '" + in + "'") @@ -1139,7 +1139,7 @@ trait BuildExtra extends BuildCommon } } def externalIvyFile(file: Initialize[File] = baseDirectory / "ivy.xml", iScala: Initialize[Option[IvyScala]] = ivyScala): Setting[Task[ModuleSettings]] = - external(file, iScala)( (f, is, v) => new IvyFileConfiguration(f, is, v) ) + external(file, iScala)( (f, is, v) => new IvyFileConfiguration(f, is, v) ) def externalPom(file: Initialize[File] = baseDirectory / "pom.xml", iScala: Initialize[Option[IvyScala]] = ivyScala): Setting[Task[ModuleSettings]] = external(file, iScala)( (f, is, v) => new PomConfiguration(f, is, v) ) @@ -1156,7 +1156,7 @@ trait BuildExtra extends BuildCommon (fullClasspath in config, runner in (config, run), streams) map { (cp, r, s) => toError(r.run(mainClass, data(cp), arguments, s.log)) } - + def fullRunInputTask(scoped: InputKey[Unit], config: Configuration, mainClass: String, baseArguments: String*): Setting[InputTask[Unit]] = scoped <<= inputTask { result => ( initScoped(scoped.scopedKey, runnerInit) zipWith (fullClasspath in config, streams, result).identityMap) { (rTask, t) => @@ -1173,7 +1173,7 @@ trait BuildExtra extends BuildCommon } def initScoped[T](sk: ScopedKey[_], i: Initialize[T]): Initialize[T] = initScope(fillTaskAxis(sk.scope, sk.key), i) def initScope[T](s: Scope, i: Initialize[T]): Initialize[T] = i mapReferenced Project.mapScope(Scope.replaceThis(s)) - + /** Disables post-compilation hook for determining tests for tab-completion (such as for 'test-only'). * This is useful for reducing test:compile time when not running test. */ def noTestCompletion(config: Configuration = Test): Setting[_] = inConfig(config)( Seq(definedTests <<= Defaults.detectTests) ).head diff --git a/sbt/src/sbt-test/source-dependencies/parent-member-change/test b/sbt/src/sbt-test/source-dependencies/parent-member-change/test index af7153b5f..95ba12295 100644 --- a/sbt/src/sbt-test/source-dependencies/parent-member-change/test +++ b/sbt/src/sbt-test/source-dependencies/parent-member-change/test @@ -1,7 +1,7 @@ > compile # modify A.scala so that the signature of its method changes to be identical to -# that of the method in its descendent in C.scala +# that of the method in its descendant in C.scala $ copy-file changes/A.scala A.scala # Should recompile C.scala and report this error, failing the compile --> compile \ No newline at end of file +-> compile diff --git a/util/io/Path.scala b/util/io/Path.scala index 6634ac1e1..0d8f3a321 100644 --- a/util/io/Path.scala +++ b/util/io/Path.scala @@ -27,7 +27,7 @@ final class RichFile(val asFile: File) /** The wrapped file converted to a URL.*/ def asURL = asFile.toURI.toURL def absolutePath: String = asFile.getAbsolutePath - + /** The last component of this path.*/ def name = asFile.getName /** The extension part of the name of this path. This is the part of the name after the last period, or the empty string if there is no period.*/ @@ -59,18 +59,18 @@ trait PathExtra extends Alternatives with Mapper with PathLow implicit def richFile(file: File): RichFile = new RichFile(file) implicit def filesToFinder(cc: Traversable[File]): PathFinder = PathFinder.strict(cc) } -object Path extends PathExtra +object Path extends PathExtra { def apply(f: File): RichFile = new RichFile(f) def apply(f: String): RichFile = new RichFile(new File(f)) def fileProperty(name: String): File = new File(System.getProperty(name)) def userHome: File = fileProperty("user.home") - + def absolute(file: File): File = new File(file.toURI.normalize).getAbsoluteFile def makeString(paths: Seq[File]): String = makeString(paths, pathSeparator) def makeString(paths: Seq[File], sep: String): String = paths.map(_.getAbsolutePath).mkString(sep) def newerThan(a: File, b: File): Boolean = a.exists && (!b.exists || a.lastModified > b.lastModified) - + /** The separator character of the platform.*/ val sep = java.io.File.separatorChar @@ -125,8 +125,8 @@ sealed abstract class PathFinder /** Excludes all paths from excludePaths from the paths selected by this PathFinder.*/ def ---(excludePaths: PathFinder): PathFinder = new ExcludeFiles(this, excludePaths) /** Constructs a new finder that selects all paths with a name that matches filter and are - * descendents of paths selected by this finder.*/ - def **(filter: FileFilter): PathFinder = new DescendentOrSelfPathFinder(this, filter) + * descendants of paths selected by this finder.*/ + def **(filter: FileFilter): PathFinder = new DescendantOrSelfPathFinder(this, filter) def *** : PathFinder = **(AllPassFilter) /** Constructs a new finder that selects all paths with a name that matches filter and are * immediate children of paths selected by this finder.*/ @@ -148,13 +148,16 @@ sealed abstract class PathFinder for(file <- get; mapped <- apply(file)) yield (file, mapped) } - /** Selects all descendent paths with a name that matches include and do not have an intermediate + /** Selects all descendant paths with a name that matches include and do not have an intermediate * path with a name that matches intermediateExclude. Typical usage is: * - * descendentsExcept("*.jar", ".svn")*/ - def descendentsExcept(include: FileFilter, intermediateExclude: FileFilter): PathFinder = + * descendantsExcept("*.jar", ".svn")*/ + def descendantsExcept(include: FileFilter, intermediateExclude: FileFilter): PathFinder = (this ** include) --- (this ** intermediateExclude ** include) - + @deprecated("Use `descendantsExcept` instead.", "0.11.3") + 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.*/ final def get: Seq[File] = @@ -193,12 +196,12 @@ private abstract class FilterFiles extends PathFinder with FileFilter def parent: PathFinder def filter: FileFilter final def accept(file: File) = filter.accept(file) - + protected def handleFile(file: File, fileSet: mutable.Set[File]): Unit = for(matchedFile <- wrapNull(file.listFiles(this))) fileSet += new File(file, matchedFile.getName) } -private class DescendentOrSelfPathFinder(val parent: PathFinder, val filter: FileFilter) extends FilterFiles +private class DescendantOrSelfPathFinder(val parent: PathFinder, val filter: FileFilter) extends FilterFiles { private[sbt] def addTo(fileSet: mutable.Set[File]) { @@ -206,14 +209,14 @@ private class DescendentOrSelfPathFinder(val parent: PathFinder, val filter: Fil { if(accept(file)) fileSet += file - handleFileDescendent(file, fileSet) + handleFileDescendant(file, fileSet) } } - private def handleFileDescendent(file: File, fileSet: mutable.Set[File]) + private def handleFileDescendant(file: File, fileSet: mutable.Set[File]) { handleFile(file, fileSet) for(childDirectory <- wrapNull(file listFiles DirectoryFilter)) - handleFileDescendent(new File(file, childDirectory.getName), fileSet) + handleFileDescendant(new File(file, childDirectory.getName), fileSet) } } private class ChildPathFinder(val parent: PathFinder, val filter: FileFilter) extends FilterFiles @@ -236,11 +239,11 @@ private class ExcludeFiles(include: PathFinder, exclude: PathFinder) extends Pat { val includeSet = new mutable.LinkedHashSet[File] include.addTo(includeSet) - + val excludeSet = new mutable.HashSet[File] exclude.addTo(excludeSet) - + includeSet --= excludeSet pathSet ++= includeSet } -} \ No newline at end of file +}