Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions io/src/main/scala/sbt/io/IO.scala
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ object IO {
* If a file already exists, the last modified time is set to the current time.
* It is not guaranteed that all files will have the same last modified time after this call.
*/
def touch(files: Traversable[File]): Unit = files.foreach(f => { touch(f); () })
def touch(files: Iterable[File]): Unit = files.foreach(f => { touch(f); () })

/**
* Creates a file at the given location if it doesn't exist.
Expand All @@ -318,7 +318,7 @@ object IO {
}

/** Creates directories `dirs` and all parent directories. It tries to work around a race condition in `File.mkdirs()` by retrying up to a limit. */
def createDirectories(dirs: Traversable[File]): Unit =
def createDirectories(dirs: Iterable[File]): Unit =
dirs.foreach(createDirectory)

/** Creates directory `dir` and all parent directories. It tries to work around a race condition in `File.mkdirs()` by retrying up to a limit. */
Expand Down Expand Up @@ -617,7 +617,7 @@ object IO {
private[sbt] def wrapNull(a: Array[File]) = if (a == null) new Array[File](0) else a

@deprecated("Please specify whether to use a static timestamp", "1.3.2")
def jar(sources: Traversable[(File, String)], outputJar: File, manifest: Manifest): Unit =
def jar(sources: Iterable[(File, String)], outputJar: File, manifest: Manifest): Unit =
archive(sources.toSeq, outputJar, Some(manifest), None)

/**
Expand All @@ -630,15 +630,15 @@ object IO {
* @param time static timestamp to use for all entries, if any, in milliseconds since Epoch
*/
def jar(
sources: Traversable[(File, String)],
sources: Iterable[(File, String)],
outputJar: File,
manifest: Manifest,
time: Option[Long]
): Unit =
archive(sources.toSeq, outputJar, Some(manifest), time)

@deprecated("Please specify whether to use a static timestamp", "1.3.2")
def zip(sources: Traversable[(File, String)], outputZip: File): Unit =
def zip(sources: Iterable[(File, String)], outputZip: File): Unit =
archive(sources.toSeq, outputZip, None, None)

/**
Expand All @@ -649,7 +649,7 @@ object IO {
* @param outputZip The file to write the zip to.
* @param time static timestamp to use for all entries, if any.
*/
def zip(sources: Traversable[(File, String)], outputZip: File, time: Option[Long]): Unit =
def zip(sources: Iterable[(File, String)], outputZip: File, time: Option[Long]): Unit =
archive(sources.toSeq, outputZip, None, time)

private def archive(
Expand Down Expand Up @@ -812,7 +812,7 @@ object IO {
} else None
}

def copy(sources: Traversable[(File, File)]): Set[File] = copy(sources, CopyOptions())
def copy(sources: Iterable[(File, File)]): Set[File] = copy(sources, CopyOptions())

/**
* For each pair in `sources`, copies the contents of the first File (the source) to the location
Expand All @@ -823,11 +823,11 @@ object IO {
* Any parent directories that do not exist are created.
* The set of all target files is returned, whether or not they were updated by this method.
*/
def copy(sources: Traversable[(File, File)], options: CopyOptions): Set[File] =
def copy(sources: Iterable[(File, File)], options: CopyOptions): Set[File] =
copy(sources, options.overwrite, options.preserveLastModified, options.preserveExecutable)

def copy(
sources: Traversable[(File, File)],
sources: Iterable[(File, File)],
overwrite: Boolean,
preserveLastModified: Boolean,
preserveExecutable: Boolean
Expand Down Expand Up @@ -1110,7 +1110,7 @@ object IO {
* For each pair in `files`, moves the contents of the first File to the location of the second.
* See `sbt.io.IO$.move(java.io.File,java.io.File):Unit` for the behavior of the individual move operations.
*/
def move(files: Traversable[(File, File)]): Unit =
def move(files: Iterable[(File, File)]): Unit =
files.foreach(Function.tupled(move(_, _)))

/**
Expand Down
8 changes: 4 additions & 4 deletions io/src/main/scala/sbt/io/Path.scala
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,11 @@ object PathFinder {

def apply(file: File): PathFinder = new SingleFile(file)

def apply(files: => Traversable[File]): PathFinder = new PathFinder {
def apply(files: => Iterable[File]): PathFinder = new PathFinder {
override def get(): Seq[File] = files.toIndexedSeq.distinct
}

def strict(files: Traversable[File]): PathFinder = apply(files)
def strict(files: Iterable[File]): PathFinder = apply(files)

sealed trait Combinator extends Any {

Expand All @@ -357,7 +357,7 @@ object PathFinder {
* 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.
* If `errorIfNone` is false, the path is dropped from the returned Iterable.
*/
def pair[T](mapper: File => Option[T], errorIfNone: Boolean = true): Seq[(File, T)]

Expand Down Expand Up @@ -544,7 +544,7 @@ sealed trait PathFinderDefaults extends PathFinder.Combinator {
* 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.
* If `errorIfNone` is false, the path is dropped from the returned Iterable.
*/
def pair[T](mapper: File => Option[T], errorIfNone: Boolean = true): Seq[(File, T)] = {
val apply = if (errorIfNone) (a: File) => mapper(a).orElse(fail(a)) else mapper
Expand Down
4 changes: 2 additions & 2 deletions io/src/main/scala/sbt/io/PathMapper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ abstract class Mapper {
* Selects all descendants of `base` directory and maps them to a path relative to `base`.
* `base` itself is not included.
*/
def allSubpaths(base: File): Traversable[(File, String)] =
def allSubpaths(base: File): Iterable[(File, String)] =
selectSubpaths(base, AllPassFilter)

/**
* Selects descendants of `base` directory matching `filter` and maps them to a path relative to `base`.
* `base` itself is not included.
*/
def selectSubpaths(base: File, filter: FileFilter): Traversable[(File, String)] =
def selectSubpaths(base: File, filter: FileFilter): Iterable[(File, String)] =
PathFinder(base).globRecursive(filter).get().collect {
case f if f != base => f -> base.toPath.relativize(f.toPath).toString
}
Expand Down
2 changes: 1 addition & 1 deletion io/src/main/scala/sbt/io/syntax.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ object syntax extends IOSyntax0 {
def url(s: String): URL = uri(s).toURL

implicit def fileToRichFile(file: File): RichFile = new RichFile(file)
implicit def filesToFinder(cc: Traversable[File]): PathFinder = PathFinder.strict(cc)
implicit def filesToFinder(cc: Iterable[File]): PathFinder = PathFinder.strict(cc)
}
20 changes: 10 additions & 10 deletions io/src/main/scala/sbt/nio/file/FileTreeView.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ object FileTreeView {
* @param globs the search queries
* @return all of the paths that match the search query.
*/
def list(globs: Traversable[Glob]): Seq[(Path, FileAttributes)] = all(globs, fileTreeView)
def list(globs: Iterable[Glob]): Seq[(Path, FileAttributes)] = all(globs, fileTreeView)

/**
* Returns a filtered list of the existing paths on the file system that match the [[Glob]]
Expand All @@ -145,7 +145,7 @@ object FileTreeView {
* @param filter the filter for the path name and attributes of each file in the result set
* @return all of the paths that match the search query.
*/
def list(globs: Traversable[Glob], filter: PathFilter): Seq[(Path, FileAttributes)] =
def list(globs: Iterable[Glob], filter: PathFilter): Seq[(Path, FileAttributes)] =
all(globs, fileTreeView, filter)

/**
Expand Down Expand Up @@ -205,7 +205,7 @@ object FileTreeView {
* @param globs the search queries
* @return all of the paths that match the search query.
*/
def iterator(globs: Traversable[Glob]): Iterator[(Path, FileAttributes)] =
def iterator(globs: Iterable[Glob]): Iterator[(Path, FileAttributes)] =
FileTreeView.iterator(globs, fileTreeView)

/**
Expand Down Expand Up @@ -233,7 +233,7 @@ object FileTreeView {
* @param filter the pathfilter
* @return all of the paths that match the search query.
*/
def iterator(globs: Traversable[Glob], filter: PathFilter): Iterator[(Path, FileAttributes)] =
def iterator(globs: Iterable[Glob], filter: PathFilter): Iterator[(Path, FileAttributes)] =
FileTreeView.iterator(globs, fileTreeView, filter)
}
private[sbt] type Nio[+T] = FileTreeView[(Path, T)]
Expand All @@ -253,33 +253,33 @@ object FileTreeView {
}
(path: Path) => view.list(path).map(converter)
}
def flatMap[B, A >: T](f: (Path, A) => Traversable[B]): FileTreeView.Nio[B] = {
val converter: ((Path, A)) => Traversable[(Path, B)] = { case (path: Path, attrs) =>
def flatMap[B, A >: T](f: (Path, A) => Iterable[B]): FileTreeView.Nio[B] = {
val converter: ((Path, A)) => Iterable[(Path, B)] = { case (path: Path, attrs) =>
f(path, attrs).map(path -> _)
}
(path: Path) => view.list(path).flatMap(converter(_))
}
}

private[sbt] def all(
globs: Traversable[Glob],
globs: Iterable[Glob],
view: FileTreeView.Nio[FileAttributes]
): Seq[(Path, FileAttributes)] =
all(globs, view, AllPass)
private[sbt] def all(
globs: Traversable[Glob],
globs: Iterable[Glob],
view: FileTreeView.Nio[FileAttributes],
filter: PathFilter
): Seq[(Path, FileAttributes)] =
iterator(globs, view, filter).toVector

private[sbt] def iterator(
globs: Traversable[Glob],
globs: Iterable[Glob],
view: FileTreeView.Nio[FileAttributes]
): Iterator[(Path, FileAttributes)] =
iterator(globs, view, (_, _) => true)
private[sbt] def iterator(
globs: Traversable[Glob],
globs: Iterable[Glob],
view: FileTreeView.Nio[FileAttributes],
filter: PathFilter
): Iterator[(Path, FileAttributes)] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import org.scalatest.flatspec.AnyFlatSpec
import sbt.io.IO
import sbt.nio.file.{ FileTreeView, Glob, RecursiveGlob }

class TraversableGlobSpec extends AnyFlatSpec {
"Traversable globs" should "collect multiple directories" in {
class IterableGlobSpec extends AnyFlatSpec {
"Iterable globs" should "collect multiple directories" in {
IO.withTemporaryDirectory { dirFile =>
val dir = dirFile.toPath
val subdir = Files.createDirectories(dir.resolve("subdir"))
Expand Down
1 change: 0 additions & 1 deletion project/HouseRulesPluglin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ object HouseRulesPlugin extends AutoPlugin {
scalacOptions += "-language:implicitConversions",
scalacOptions ++= Seq(
"-Wconf:msg=Compiler synthesis of Manifest and OptManifest is deprecated:silent",
"-Wconf:msg=type Traversable in package scala:silent",
),
scalacOptions ++= {
sys.props.get("sbt.build.fatal") match {
Expand Down