ot-clean, Complete use case
I would like to describe a very simple yet complete cleaning use case. The only prerequisite here is JDK or JRE 1.8+. Imagine that you have your working directory in
/mnt/work. Applications are producing logs or compilation files that you would like to remove executing a single command.
Step by step guide
- Download the latest ot-clean release.
- Unpack it to
/mnt/work/cleandirectory (for example).
- Go to
.clean.ymlwith the following content:
deletes: - **/*.log dirs: - /mnt/work - /home/yourusername
java -jar clean.jar.
- Check list of files that are going to be removed.
java -jar clean.jar -din order to remove them.
Now every time you want to perform cleanup. Just go to
/mnt/work/clean and type:
java -jar clean.jar -d
Feel free to put it in some more convenient place if you like.
What actually happen here?
The ot-clean is scanning your directories and is looking for certain project patterns. If application recognizes that it is maven project for example, then it tries to remove “target” directory. If the application finds
.clean.yml then is trying to remove all files listed in
deletes section. If there is
dirs section then is scanning also specified directories.
Example ot-clean output
Finds maven project automatically
[Maven]: D:\work\playground - Found directory: D:\work\playground\target [2 KB]
Finds directories specified in .clean.yml file
[.clean.yml]: D:\work\ot-miho\m - Found directory: D:\work\ot-miho\m\m-app\target [221 KB] - Found directory: D:\work\ot-miho\m\m-web\logs [131 bytes] - Found directory: D:\work\ot-miho\m\m-web\project\project\target [12 KB] - Found directory: D:\work\ot-miho\m\m-web\project\target [15 MB] - Found directory: D:\work\ot-miho\m\m-web\target [7 MB]
Summary: Found 72 element(s) [293 MB]
The idea is similar to
.gitignore. Therefore, if application finds
.clean.yml file somewhere during scanning it tries to parse it. You can keep custom cleaning files inside your projects. This way you can even share it via code repository if you like.
The ot-clean series
This blog post is one of the series about the ot-clean. Simple open source tool that maintains your projects directories cleaned from all the garbage. Feel free to look at the source code or readme page for more information. You can also submit pull request or post suggestion. This text participates in open source blogging competition.
All posts from the ot-clean series
- 06 May 2016 » ot-clean, Final version
- 04 May 2016 » ot-clean, Tests refactoring
- 29 Apr 2016 » ot-clean, Refactoring and cleaning DSL (4/4)
- 26 Apr 2016 » ot-clean, Refactoring and cleaning DSL (3/4)
- 22 Apr 2016 » ot-clean, Refactoring and cleaning DSL (2/4)
- 19 Apr 2016 » ot-clean, Refactoring and cleaning DSL (1/4)
- 15 Apr 2016 » ot-clean, MatcherAssert vs Assert, which assertThat?
- 12 Apr 2016 » ot-clean, Grails 2.x/3.x, PlayFramework 2.x support
- 08 Apr 2016 » ot-clean, Complete use case
- 05 Apr 2016 » ot-clean, Scan multiple unrelated directories
- 01 Apr 2016 » ot-clean, Coveralls integration and code cleanup
- 29 Mar 2016 » ot-clean, How to access maven artifact version at runtime?
- 25 Mar 2016 » ot-clean, Wildcards
- 21 Mar 2016 » ot-clean, Zero maintenance overhead
- 18 Mar 2016 » ot-clean, Functional config file preprocessing
- 15 Mar 2016 » ot-clean, Cascade and arguments
- 11 Mar 2016 » ot-clean, Handle any project using YAML format
- 08 Mar 2016 » ot-clean, Quickstart
- 04 Mar 2016 » ot-clean, YAML node alias surprise
- 01 Mar 2016 » ot-clean, Single clean to clean them all!
About the author
Grzegorz Gajos, Software Architect with international consulting and programming background. Co-founder of Open Tangerine Software House. Quality evangelist. An experienced entrepreneur, out of the box thinker and problem solver.