Search code examples
eclipsemavenmaven-clean-plugin

Maven clean lifecycle


i have read about maven's clean and site lifecycle at lot of places, but not able to understand how exactly it works. Please explain me how Maven's clean Lifecycle processes with some example. how it is different from build. as before build starts, cleaning is done, right? what happens in pre and post clean phases.


Solution

  • In Maven based project, many cached output existed in your “target” folder. When you want to build your project for deployment, you have to make sure clean all the cached output so that you are always get the latest for deployment.

    For example: If you rename a class, the previous compiled version will remain in target/classes until you run clean. This maybe completely harmless, but it could cause issues if it is autodetected by classpath scanning and the like.