3

An easy way to get rid of *everything* generated by SBT? asks for an easy way to clean up all files generated from sbt, and didn't find one. I'll ask for a hard one. How do I get a make cleanall with sbt?

UPDATE: For a definition of everything, you have to know why you ever need to clean all. There are two common reasons:

  1. To distribute something: You need to confirm that someone can take a fresh machine, download your code, and build it without problem. (Or, someone can't, and you want to debug).

  2. When something has gone horribly wrong. Some funny version of some jar somewhere is breaking something somehow. Sometimes it's easiest to just start fresh, rather than try to debug... (See Jim Gray's Why Computers Stop)

Community
  • 1
  • 1
SRobertJames
  • 6,827
  • 12
  • 48
  • 89
  • 1
    Use the other answer about rm dirs named target. But wait, removing everything would include deleting installs to local maven and ivy, which is also a problem (snapshots). – som-snytt May 13 '14 at 01:25
  • 3
    sbt's launcher downloads sbt JARs (bootstrapping) and also downloads and caches library JARs into Ivy cache had you run sbt on a fresh machine. Do you count them into *everything*? – Eugene Yokota May 13 '14 at 04:34

1 Answers1

1

Here are the usual suspects of things you need to clean:

  • ~/.sbt/boot - Safe cache of sbt itself to avoid disappearing JAR oddiites
  • ~/.sbt/**/target - Compiled global plugin/build definitions.
  • ~/.ivy2/cache - Ivy cache of resolved dependencies
  • ~/.ivy2/local - publishLocal files
  • <cwd>/project/**/target - Compiled build/plugin definitioins
  • <cwd>/**/target - Artifacts from building your project, including compiler caches, classfiles, etc.

sbt is unable to provide a "clean everything" task directly, because deleting the JARs/classes sbt is actively using to run your build leads to super odd and evil behavior. But you could write a simple BASH script which can accomplish this if desired.

jsuereth
  • 5,444
  • 37
  • 40