As a supplement, I include clean
in my mvn
command, as in mvn clean package
, for example, in at least the following situations:
After pulling from git because someone might have deleted a source file (we use git for source control)
After switching git branch
After I delete or rename a file (including if I convert a Java class to be an inner class of another class; also including non-Java resource files)
(there are probably numerous more situations)
I recently experienced that when building a plugin (a so-called custom processor) for Apache NiFi with just mvn package
, NiFi would allow me to specify using my new version, but still used the old one. I never understood how leaving out clean
could lead to this confusing behaviour. When I did mvn clean package
, everything worked.
On one hand, if just editing existing Java files, there is no need to repeat clean
next time you build. On the other hand, clean
never hurts. Many colleagues use it every time just to be on the safe side.