I have a web application that is packaged as a war
file ( including several jar
files ).
I noticed that when I run mvn install - the only projects that are compiled are those who have changed - then it replaces these jar
s in the war
file.
If that's the case - when should I use mvn clean install instead of simply use mvn install?
I guess that if I change any resources than I would have to use mvn clean install - Am I right?
And if I'm right, then whenever I only change classes, is mvn install good enough?
Mostly, the only reason to do a clean is if you do something that would remove or rename a class or resource in the output directory, such as renaming a .java file or changing something that generates classes so that it generates them with different names. In those cases, the old class or resource files will still exist in the output directory and may cause strange behavior.
Other than that, just use install, and you'll be fine. Then Maven will only build what needs to be built to bring the output directories up to date.
Use clean when you want to build your projects from scratch. If your build does not take a lot of time use clean every time you are running build. Otherwise it is up to you.
Surely do it if you are not sure that everything is indeed updated.
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