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?
To clean up the local working copy, do one of the following: Select the desired file or directory in the Project tool window and choose Subversion | Cleanup from the context menu of the selection. Open the desired file in the editor and choose VCS | Subversion | Cleanup from the main menu.
Run testsOpen the Maven tool window. Under the Lifecycle node select test. Note that goals specified in the Maven surefire plugin will be activated at this phase and all tests in a project or in a module will be run.
Maven clean goal (clean:clean) is bound to the clean phase in the clean lifecycle. Its clean:cleangoal deletes the output of a build by deleting the build directory. Thus, when mvn clean command executes, Maven deletes the build directory.
mvn clean install tells Maven to do the clean phase in each module before running the install phase for each module. What this does is clear any compiled files you have, making sure that you're really compiling each module from scratch.
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.
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:
The answer here with the most votes suggests running the clean
and install
Lifecycle items separately in IntelliJ, which is easy enough and works. But it’s worth mentioning that you can combine these steps (and/or others) by instead creating a new Run/Debug Configuration of type maven
and adding the command clean install
(or whichever combination of maven lifecycle methods you run on a recurring basis).
Thereafter, running a mvn clean install
is as simple as clicking the green button to run that Run/Debug Configuration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With