mirror of https://github.com/sbt/sbt.git
Allow cleanKeepFiles to contain directories
The directory contents will be kept as will empty directories.
This commit is contained in:
parent
6c748d97c5
commit
ea3e5c3548
|
|
@ -557,9 +557,11 @@ object Defaults extends BuildCommon
|
|||
|
||||
def doClean(clean: Seq[File], preserve: Seq[File]): Unit =
|
||||
IO.withTemporaryDirectory { temp =>
|
||||
val mappings = preserve.filter(_.exists).zipWithIndex map { case (f, i) => (f, new File(temp, i.toHexString)) }
|
||||
val (dirs, files) = preserve.filter(_.exists).flatMap(_.***.get).partition(_.isDirectory)
|
||||
val mappings = files.zipWithIndex map { case (f, i) => (f, new File(temp, i.toHexString)) }
|
||||
IO.move(mappings)
|
||||
IO.delete(clean)
|
||||
IO.createDirectories(dirs) // recreate empty directories
|
||||
IO.move(mappings.map(_.swap))
|
||||
}
|
||||
def runMainTask(classpath: Initialize[Task[Classpath]], scalaRun: Initialize[Task[ScalaRun]]): Initialize[InputTask[Unit]] =
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
cleanKeepFiles ++= Seq(
|
||||
target.value / "keep",
|
||||
target.value / "keepfile",
|
||||
target.value / "keepdir"
|
||||
)
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
$ touch target/keep/a target/keepdir/ target/deletefile target/deletedir/b target/keepfile
|
||||
$ exists target/keep/ target/keep/a target/keepdir/ target/deletefile target/deletedir/ target/keepfile
|
||||
|
||||
> clean
|
||||
$ exists target/keep/ target/keep/a target/keepdir/ target/keepfile
|
||||
$ absent target/delete target/deletedir target/deletefile
|
||||
Loading…
Reference in New Issue