What does mvn clean do?
Options
- Removes the output of the previous build (
target) (Correct option) - Deletes your source code from the project folder
- Downloads all the dependencies again from the web
- Runs the tests of the project in a clean state
Answer
Removes files generated by the previous build (the target folder)
Why
Maven has several lifecycles. The clean lifecycle removes everything the previous build produced.
A typical command is mvn clean package: clean first, then compile, test and package, so old leftovers cannot cause strange results.
For a normal build, the phases run in order: validate, compile, test, package, verify, install, deploy.
Remember
clean = delete previous build output.