我有一个SBT构建,其中测试将临时文件创建到名为temp的目录中。调用清理任务时,如何告诉SBT删除此文件夹?
最佳答案
在包含temp
目录的项目中使用此设置:
cleanFiles <+= baseDirectory { base => base / "temp" }
这会将“temp”目录添加到文件列表中,以便在
clean
运行时以递归方式删除。<
的意思是“根据其他任务/设置进行配置”,+
的意思是附加到当前文件列表中,baseDirectory
是提供项目基本目录的设置。您可以看到如何使用
clean
命令配置inspect
,有关详细信息,请参见Inspecting Settings页面。经过编辑的sbt session 将显示这种情况下的用法:> inspect clean
Task: Unit
Description:
Deletes files produced by the build, such as generated sources, compiled classes, and task caches.
Dependencies:
clean-files
clean-keep-files
> inspect clean-files
Setting: scala.collection.Seq[java.io.File] = List(<project>/lib_managed, <project>/target, <project>/temp)
Description:
The files to recursively delete during a clean.
Dependencies:
managed-directory
target
base-directory
您可以看到它显示了它是任务还是设置,类型,描述以及用作输入的任务/设置。
关于scala - 添加其他目录以清理SBT构建中的任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10471596/