I have written the following rule in sbt
to delete a directory but the code doesn't delete the directory. What I am doing wrong?
def clearOldUiBuild(implicit dir:File):Boolean = {
println(s"Deleting ui directory. Implicit directory ${dir}")
val uiBuildDirectory = dir / "public/ui"
println(s"ui build path ${uiBuildDirectory}")
val directoryExists = uiBuildDirectory.exists() && uiBuildDirectory.isDirectory()
println(s"ui exists? ${directoryExists}")
if(directoryExists){
println(s"deleting directory ${uiBuildDirectory}")
val retExecutable = uiBuildDirectory.setExecutable(true)
val retRead = uiBuildDirectory.setReadable(true)
val retWrite = uiBuildDirectory.setWritable(true)
println(s"set executable result ${retExecutable}, ${retRead}, ${retWrite}")
val ret = uiBuildDirectory.delete()
println(s"delete result ${ret}")
ret
} else {
println(s"directory doesn't exist")
true
}
}
output
[IJ][projectname] $ clear-old-ui-build
Deleting ui directory. Implicit directory C:...frontendweb
ui build path C:...frontendwebpublicui
ui exists? true
deleting directory C:..ui
set executable result true, true, false
delete result false
[trace] Stack trace suppressed: run 'last *:clearOldUiBuild' for the full output.
[error] (*:clearOldUiBuild) java.lang.Exception: Oops! UI Build crashed.
[error] Total time: 0 s, completed 08-Jan-2021 18:26:44
[IJ][myproject] $ last *:clearOldUiBuild
java.lang.Exception: Oops! UI Build crashed.
at $6ac9788b23c613fff84d$$anonfun$$sbtdef$1.apply(C:...frontendwebuild.sbt:341)
at $6ac9788b23c613fff84d$$anonfun$$sbtdef$1.apply(C:...uild.sbt:339)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
at sbt.std.Transform$$anon$4.work(System.scala:63)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.Execute.work(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
[error] (*:clearOldUiBuild) java.lang.Exception: Oops! UI Build crashed.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…