Java Developer

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

deletes:
 - **/*.log
dirs:
 - /mnt/work
 - /home/yourusername

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]

Example summary

Summary: Found 72 element(s) [293 MB]

Why bother?

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.

Project status

Build Status

All posts from the ot-clean series


Like it? Share it on , , ,

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.