mirror of
https://github.com/sbt/sbt.git
synced 2026-08-22 06:07:24 +02:00
Restore old cleanFiles behavior
I inadvertently changed the semantics of clean so that cleanFiles would only delete the file if it was a regular file. In older versions of sbt, if a file in cleanFiles was a directory, it would be recursively deleted.
This commit is contained in:
@@ -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
|
||||||
Reference in New Issue
Block a user