Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.0k views
in Technique[技术] by (71.8m points)

scala - Add additional directory to clean task in SBT build

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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(<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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...