Java – Is it safe to run continuous builds with “mvn verify” instead of “mvn clean verify”

continuous integrationjavamaven-2

We are running our continuous builds on Hudson currently with "mvn clean verify". That is what we always did and so we never questioned it.

The question is: Is it safe to run a continuous build with "mvn verify" only?
So that would mean the maven-compiler-plugin would only compile classes that got changed since the last build and save precious time.

Will the feedback be the same quality as with "clean" or are there any drawbacks to be expected?

The product being tested is a typical Java web application with lots of generated code (JSPs, reports). There is also code around using Dependency Injection.

Best Answer

No, it's not safe! The Maven compiler plugin is not smart enough to figure out that the API of a class A has changed and that it should check all other classes which use this API, too. It will only compile A and create a jar with a lot of broken classes.

Note: It's usually better to run mvn clean in advance and then run the build/verify/compile/install. That allows you to run the second command several times without cleaning all the time.