mirror of https://github.com/sbt/sbt.git
Merge pull request #4999 from eatkins/clean-directories
Restore old cleanFiles behavior
This commit is contained in:
commit
c38ce111fe
|
|
@ -89,11 +89,14 @@ private[sbt] object Clean {
|
||||||
val excludeFilter = cleanFilter(scope).value
|
val excludeFilter = cleanFilter(scope).value
|
||||||
val delete = cleanDelete(scope).value
|
val delete = cleanDelete(scope).value
|
||||||
val targetDir = (target in scope).?.value.map(_.toPath)
|
val targetDir = (target in scope).?.value.map(_.toPath)
|
||||||
val targetFiles = (if (full) targetDir else None).fold(Nil: Seq[Path]) { t =>
|
def recursiveFiles(dir: Path): Seq[Path] =
|
||||||
view.list(t.toGlob / **).collect { case (p, _) if !excludeFilter(p) => p }
|
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
|
val allFiles = cleanPaths.view ++ targetFiles
|
||||||
.flatMap(_.map(_.toPath)) ++ targetFiles
|
|
||||||
allFiles.sorted.reverseIterator.foreach(delete)
|
allFiles.sorted.reverseIterator.foreach(delete)
|
||||||
|
|
||||||
// This is the special portion of the task where we clear out the relevant streams
|
// This is the special portion of the task where we clear out the relevant streams
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
cleanFiles += baseDirectory.value / "foo"
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
baz
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
> clean
|
||||||
|
|
||||||
|
$ absent foo/bar/baz.txt
|
||||||
Loading…
Reference in New Issue