在 SBT 构建中添加其他目录以清理任务 [英] Add additional directory to clean task in SBT build

查看:37
本文介绍了在 SBT 构建中添加其他目录以清理任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 SBT 版本,其中测试将临时文件创建到一个名为 temp 的目录中.当我调用 clean 任务时,如何告诉 SBT 删除此文件夹?

I have a SBT build where the tests create temporary files into a directory called temp. How can I tell SBT to delete this folder when I call the clean task?

推荐答案

在包含 temp 目录的项目中使用此设置:

Use this setting in the project containing the temp directory:

cleanFiles <+= baseDirectory { base => base / "temp" }

这会将temp"目录添加到文件列表中,以便在 clean 运行时递归删除.

This adds the "temp" directory to the list of files to recursively delete when clean runs.

< 表示根据其他任务/设置进行配置",+ 表示附加到当前文件列表,baseDirectory 是提供项目基本目录的设置.

The < means "configure in terms of other tasks/settings", the + means append to the current list of files, and baseDirectory is the setting providing the base directory of the project.

您可以查看如何使用 inspect 命令配置 clean,在 检查设置 页面.已编辑的 sbt 会话显示了这种情况下的用法:

You can see how clean is configured using the inspect command, documented in more detail on the Inspecting Settings page. An edited sbt session shows usage in this case:

> 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

您可以看到它向您显示它是任务还是设置、类型、描述以及用作输入的任务/设置.

You can see this shows you if it is a task or setting, the type, a description, and the tasks/settings used as inputs.

这篇关于在 SBT 构建中添加其他目录以清理任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆