An easy way to get rid of *everything* generated by SBT?

后端 未结 4 1409
情话喂你
情话喂你 2020-12-07 17:10

Is there an easy way to get rid of everything getting generated as a result of performing an SBT build? It turns out it creates target directories all over the place. Perfor

4条回答
  •  情歌与酒
    2020-12-07 17:58

    On my system (Ubuntu Linux) with SBT 0.13.5 and some projects from the Coursera Functional Programming course I found the folders all totalled up to 2.1GB for 12 projects due to all the cache files and duplicated Scala downloads.

    The current SBT commands that work and get almost everything cleaned is:

    sbt clean clean-files
    

    This removes the top level "target" and "lib_managed" folders (23MB down to 3.2MB in this case) but leaves some target folders under project:

    ./project/project/project/target
    ./project/project/target
    ./project/target
    

    This is where the Linux find command (also posted by @jack-oconnor) is very helpful:

    find . -name target -type d -exec rm -rf {} \;
    

    This gets us back down to a mere 444KB for one of my own projects and the 2.1GB goes down to 5.0MB !

    In windows you won't have as many useful command line options, e.g. no star wildcards in path names, but you can always try and force it with:

    rmdir /s /q target project/target project/project/target
    

    The best I can do on automatically finding is a DIR command:

    dir /ad /s /b | find "target"
    

提交回复
热议问题