Add additional directory to clean task in SBT build

前端 未结 4 747
粉色の甜心
粉色の甜心 2020-12-19 03:32

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?

4条回答
  •  情书的邮戳
    2020-12-19 04:08

    Use this setting in the project containing the temp directory:

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

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

    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.

    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(/lib_managed, /target, /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.

提交回复
热议问题