Main Tutorials

How to clean project with Maven

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.

To clean your project cached output, issue this command :


mvn clean

See output…


D:\workspace-new\mkyongweb-core>mvn clean
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building mkyongweb-core Maven Webapp
[INFO]    task-segment: [clean]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] Deleting directory D:\workspace-new\mkyongweb-core\target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Fri Apr 15 16:42:58 SGT 2011
[INFO] Final Memory: 3M/6M
[INFO] ------------------------------------------------------------------------

When “mvn clean” is executed, everything under “target” folder will be deleted.

Deployment for production
To deploy your project for production, it’s always recommended to use “mvn clean package“, to make sure you always get the latest for deployment.

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments