There are many commands which you need to use for Maven in your daily development life.
Below is the list of some useful Maven commands.
Create Java Project
mvn archetype:generate -DarchetypeArtifactId=maven-archetype-quickstart
This Maven command used to generate new Java project. You can refer tutorial for more information on how to create Java project using maven.
This ‘clean’ command will clean the target folder of your project.
mvn clean install
This ‘install’ command will build the project, always better to put ‘clean’ before ‘install’ command, So a new copy your project’s build always built.
The ‘package’ command used for packaging your project as jar, war or ear.
Run JUnit tests
The ‘test’ command will run the JUnit in your peoject.
mvn test –Dtest=org.java.connect.maven.MyTest
The above command used to run only select test class.
mvn install -Dmaven.test.skip=true
The above use to skip the test classes while building the project, by default test classes also will run while ‘install’ command.
mvn eclipse:clean eclipse:eclipse
The command ‘eclipse:eclipse’ adds eclipse support files in your project so you can import into eclipse.
mvn eclipse:clean eclipse:eclipse –DdownloadSources=true
Above command will download the sources of each dependency of project. It will download the source if available and attached the source in eclipse as well so you see all dependencies’ classes java code in eclipse.
The above command on your project will generate javadoc for project.