Grails Quick Tip - Cleaning Up

Mr. Haki, once again, wrote a really cool blog post about grails clean and how it can be configured to delete all or only certain generated files in the working directory.

When reading the blog post a trick came to my mind that was once mentioned by Burt Beckwith in his excellent book Programming Grails.

Burt said he often replaces the standard configuration in BuildConfig.groovy

grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"

with

grails.project.work.dir = "target"

This has the advantage that all generated classes, including plugin-classes, are saved in a single directory. This is really cool as installed plugins would otherwise be saved and cached in the ~/.grails/ directory.

Grails Work Dir Target

Once things mess up and a clean state is needed, a simple rm -rf target gives us a completely zero state in terms of generated artefacts.