Merge pull request #4999 from eatkins/clean-directories

Restore old cleanFiles behavior
This commit is contained in:
eugene yokota 2019-08-28 20:42:23 -04:00 committed by GitHub
commit c38ce111fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 4 deletions

View File

@ -89,11 +89,14 @@ private[sbt] object Clean {
val excludeFilter = cleanFilter(scope).value
val delete = cleanDelete(scope).value
val targetDir = (target in scope).?.value.map(_.toPath)
val targetFiles = (if (full) targetDir else None).fold(Nil: Seq[Path]) { t =>
view.list(t.toGlob / **).collect { case (p, _) if !excludeFilter(p) => p }
def recursiveFiles(dir: Path): Seq[Path] =
view.list(dir.toGlob / **).collect { case (p, _) if !excludeFilter(p) => p }
val targetFiles = (if (full) targetDir else None).fold(Nil: Seq[Path])(recursiveFiles)
val cleanPaths = (cleanFiles in scope).?.value.getOrElse(Nil).flatMap { f =>
val path = f.toPath
if (Files.isDirectory(path)) path +: recursiveFiles(path) else path :: Nil
}
val allFiles = (cleanFiles in scope).?.value.toSeq
.flatMap(_.map(_.toPath)) ++ targetFiles
val allFiles = cleanPaths.view ++ targetFiles
allFiles.sorted.reverseIterator.foreach(delete)
// This is the special portion of the task where we clear out the relevant streams

View File

@ -0,0 +1 @@
cleanFiles += baseDirectory.value / "foo"

View File

@ -0,0 +1 @@
baz

View File

@ -0,0 +1,3 @@
> clean
$ absent foo/bar/baz.txt