mirror of https://github.com/sbt/sbt.git
use stable ordering for PathFinder.getFiles
This commit is contained in:
parent
15e785a1e4
commit
37e24daebf
|
|
@ -44,7 +44,7 @@ object Defaults
|
|||
def **(filter: FileFilter): Initialize[Seq[File]] = map0 { _ ** filter }
|
||||
protected[this] def map0(f: PathFinder => PathFinder): Initialize[Seq[File]]
|
||||
protected[this] def finder(f: PathFinder => PathFinder): Seq[File] => Seq[File] =
|
||||
in => f(in).getFiles.toSeq
|
||||
in => f(in).getFiles
|
||||
}
|
||||
def configSrcSub(key: ScopedSetting[File]): Initialize[File] = (key, configuration) { (src, conf) => src / nameForSrc(conf.name) }
|
||||
def nameForSrc(config: String) = if(config == "compile") "main" else config
|
||||
|
|
@ -102,7 +102,7 @@ object Defaults
|
|||
cacheDirectory <<= (cacheDirectory, configuration) { _ / _.name },
|
||||
classDirectory <<= (target, configuration) { (outDir, conf) => outDir / (prefix(conf.name) + "classes") },
|
||||
docDirectory <<= (target, configuration) { (outDir, conf) => outDir / (prefix(conf.name) + "api") },
|
||||
sources <<= (sourceDirectories, sourceFilter, defaultExcludes) map { (d,f,excl) => d.descendentsExcept(f,excl).getFiles.toSeq },
|
||||
sources <<= (sourceDirectories, sourceFilter, defaultExcludes) map { (d,f,excl) => d.descendentsExcept(f,excl).getFiles },
|
||||
scalaSource <<= sourceDirectory / "scala",
|
||||
javaSource <<= sourceDirectory / "java",
|
||||
resourceDirectory <<= sourceDirectory / "resources",
|
||||
|
|
@ -113,7 +113,7 @@ object Defaults
|
|||
generatedResources <<= (definedSbtPlugins, generatedResourceDirectory) map writePluginsDescriptor
|
||||
)
|
||||
def addBaseSources = Seq(
|
||||
sources <<= (sources, baseDirectory, sourceFilter, defaultExcludes) map { (srcs,b,f,excl) => (srcs +++ b * (f -- excl)).getFiles.toSeq }
|
||||
sources <<= (sources, baseDirectory, sourceFilter, defaultExcludes) map { (srcs,b,f,excl) => (srcs +++ b * (f -- excl)).getFiles }
|
||||
)
|
||||
|
||||
def compileBase = Seq(
|
||||
|
|
@ -230,15 +230,15 @@ object Defaults
|
|||
packageTasks(packageSrc, "src", packageSrcTask) ++
|
||||
packageTasks(packageDoc, "doc", packageDocTask)
|
||||
|
||||
private[this] val allSubpaths = (_: File).###.***.xx.toSeq
|
||||
private[this] val allSubpaths = (dir: File) => (dir.*** --- dir) x relativeTo(dir)
|
||||
|
||||
def packageBinTask = concat(classMappings, resourceMappings)
|
||||
def packageBinTask = classMappings
|
||||
def packageDocTask = doc map allSubpaths
|
||||
def packageSrcTask = concat(resourceMappings, sourceMappings)
|
||||
|
||||
private type Mappings = Initialize[Task[Seq[(File, String)]]]
|
||||
def concat(as: Mappings, bs: Mappings) = (as zipWith bs)( (a,b) => (a :^: b :^: KNil) map { case a :+: b :+: HNil => a ++ b } )
|
||||
def classMappings = (compileInputs, compile) map { (in, _) => allSubpaths(in.config.classesDirectory) }
|
||||
def classMappings = (compileInputs, products) map { (in, _) => allSubpaths(in.config.classesDirectory) }
|
||||
// drop base directories, since there are no valid mappings for these
|
||||
def sourceMappings = (sources, sourceDirectories, baseDirectory) map { (srcs, sdirs, base) =>
|
||||
( (srcs --- sdirs --- base) x (relativeTo(sdirs)|relativeTo(base))) toSeq
|
||||
|
|
@ -428,7 +428,7 @@ object Classpaths
|
|||
products <<= makeProducts,
|
||||
managedClasspath <<= (configuration, update) map managedJars,
|
||||
unmanagedJars <<= (configuration, unmanagedBase, classpathFilter, defaultExcludes) map { (config, base, filter, excl) =>
|
||||
(base * (filter -- excl) +++ (base / config.name).descendentsExcept(filter, excl)).getFiles.toSeq
|
||||
(base * (filter -- excl) +++ (base / config.name).descendentsExcept(filter, excl)).getFiles
|
||||
}
|
||||
)
|
||||
def defaultPackageTasks: Seq[ScopedTask[_]] =
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ object Keys
|
|||
val compile = TaskKey[Analysis]("compile")
|
||||
val compilers = TaskKey[Compiler.Compilers]("compilers")
|
||||
val doc = TaskKey[File]("doc")
|
||||
val copyResources = TaskKey[Traversable[(File,File)]]("copy-resources")
|
||||
val copyResources = TaskKey[Seq[(File,File)]]("copy-resources")
|
||||
val resources = TaskKey[Seq[File]]("resources")
|
||||
val aggregate = SettingKey[Aggregation]("aggregate")
|
||||
val generatedResources = TaskKey[Seq[File]]("generated-resources")
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ The command has the following syntax:
|
|||
def paths(implicit base: File): String => Seq[File] =
|
||||
_ split sep flatMap files(base)
|
||||
|
||||
def files(base: File)(path: String): Seq[File] = readFinder(Path.fromFile(base), path).getFiles.toSeq
|
||||
def files(base: File)(path: String): Seq[File] = readFinder(Path.fromFile(base), path).getFiles
|
||||
|
||||
def file(base: File) = (path: String) => Path.fromString(base, path).asFile
|
||||
|
||||
|
|
|
|||
|
|
@ -301,7 +301,7 @@ sealed abstract class PathFinder extends NotNull
|
|||
/** Applies `mapper` to each path selected by this PathFinder and returns the path paired with the non-empty result.
|
||||
* If the result is empty (None) and `errorIfNone` is true, an exception is thrown.
|
||||
* If `errorIfNone` is false, the path is dropped from the returned Traversable.*/
|
||||
def x[T](mapper: File => Option[T], errorIfNone: Boolean = true): Traversable[(File,T)] =
|
||||
def x[T](mapper: File => Option[T], errorIfNone: Boolean = true): Seq[(File,T)] =
|
||||
{
|
||||
val apply = if(errorIfNone) mapper | fail else mapper
|
||||
for(file <- getFiles; mapped <- apply(file)) yield (file, mapped)
|
||||
|
|
@ -324,14 +324,20 @@ sealed abstract class PathFinder extends NotNull
|
|||
addTo(pathSet)
|
||||
pathSet.toSet
|
||||
}
|
||||
/** Evaluates this finder and converts the results to a `Seq` of `File`s.*/
|
||||
final def getFiles: Seq[File] =
|
||||
{
|
||||
import collection.JavaConversions._
|
||||
val pathSet: mutable.Set[Path] = new java.util.LinkedHashSet[Path]
|
||||
addTo(pathSet)
|
||||
pathSet.map(_.asFile).toSeq
|
||||
}
|
||||
/** 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: Path => Boolean): PathFinder = Path.lazyPathFinder(get.filter(f))
|
||||
/* Non-strict flatMap: no evaluation occurs until the returned finder is evaluated.*/
|
||||
final def flatMap(f: Path => PathFinder): PathFinder = Path.lazyPathFinder(get.flatMap(p => f(p).get))
|
||||
/** Evaluates this finder and converts the results to an `Array` of `URL`s..*/
|
||||
final def getURLs: Array[URL] = Path.getURLs(get)
|
||||
/** Evaluates this finder and converts the results to a `Set` of `File`s.*/
|
||||
final def getFiles: immutable.Set[File] = Path.getFiles(get)
|
||||
final def getURLs: Array[URL] = getFiles.toArray.map(_.toURI.toURL)
|
||||
/** Evaluates this finder and converts the results to a `Set` of absolute path strings.*/
|
||||
final def getPaths: immutable.Set[String] = strictMap(_.absolutePath)
|
||||
/** Evaluates this finder and converts the results to a `Set` of relative path strings.*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue