How to clean or clean build my Maven project in IntelliJ IDEA?

Sajad NasiriNezhad picture Sajad NasiriNezhad · Feb 15, 2016 · Viewed 34.2k times · Source

I'm using Apache Maven in my Java project. in NetBeans there are build and clean build icons but there aren't in IntellIJ IDEA. How can I clean or clean build my project in it?

Answer

Basil Bourque picture Basil Bourque · Aug 24, 2017

Maven > Lifecycle > clean

Open the Maven Projects panel. Click lower-left corner for pop-up menu if that panel is not already visible.

In that panel, open the Lifecycle item. There you will find clean and install items for you to run.

Screenshot of IntelliJ > Maven > Lifecycle > clean

As commented, you can also invoke this by command-line/console. But if already using IntelliJ, I do not see the point. Just show/hide this pane as you work. I use it countless times a day to hit install to build complete app, and hit clean whenever I suspect not all of the project is up-to-date in the build-results.

Build > Rebuild Project

If you are having weird problems in running the app in development also try the menu item Build > Rebuild Project.

I have asked what is the difference between a Build > Rebuild Project versus doing a Maven clean. But I still do not understand the precise details. So when things seem wonky, I do both to right the ship.

Tips:

  • Restarting IntelliJ may help when behavior seems odd.
  • Keep Intellij updated.