Monday, July 2, 2007

Clean project

The problem:

Your project creates a collection of output like classes, jars, websites and more. You want to delete this output!

The solution:

Ok this is kinda a joke. Simply type "mvn clean" and your project's output is gone. How does this work? Well Maven works like a 70 year old man on an all bran diet, very regular. Java source files go into "src/main/java" while testing sources go in "src/test/java". In the same vein plug ins such as site, generate their output into a folder called "target".

Any Maven project will share this convention, since you know when looking at a Maven project folder that "src" contains sources, resources and such, and "target" contains output created from the sources. So think about it this way: sources (in "src" folder) are transformed via Maven plug ins into output (in "target" folder).

I will mention that these conventions can be overridden, but.... that is not a good idea and you should never do so.