Reputation: 2663
I am using maven for the build purpose and normally we use the maven command mvn clean -Dmaven.test.skip=true package
only to build the web application. I know we can use the mvn install
command also to build a web application. But can anyone provide me with the exact difference between these two commands?
I found some notes on the clean and install commands. But i just want to know what's the advantage of using mvn clean
command instead of using install
command.
Upvotes: 1
Views: 9799
Reputation: 1
Maven has this concept of Maven Phases. Please go through the Maven Phases of this doc. So when you run a phase (say maven phase x
) all the phases up to that phase is executed (that is phase 1 to phase x
).
You need mvn clean
to clean up artifacts created by prior builds. mvn package
will package your code into your specified format in your POM. mvn install
will also install the package made by Maven into the local repository.
Also note that clean
and site
are not part of phases of the default life-cycle. You have to fire it before your package
or install
command. Needless to say ordering does matter here.
Upvotes: 0
Reputation: 91
The main different between mvn clean -Dmaven.test.skip=true package
and mvn install
is that the first command line cleans the target
directory and packages without running the tests. The second one compiles, tests, packages and installs the JAR or WAR file into the local repository at ~/.m2/repository
.
Upvotes: 0
Reputation: 8357
As explained here.
clean is its own action in Maven. mvn clean install tell Maven to do the clean action in each module before running the install action for each module.
What this does is clear any compiled files you have, making sure that you're really compiling each module from scratch.
Upvotes: -1