Apache Maven Basic Operations
maven
mvn
maven basic command
maven commands
Maven is the engine. All the work is done by plugins.
Maven Plugins
Clean
Clean up after the build.
# mvn clean
Compiler
Compiles Java sources.
# mvn compiler
Failsafe
Run the JUnit integration tests in an isolated classloader.
# mvn failsafe
Install
Install the built artifact into the local repository.
# mvn install
You can also install into local repository an existing jar. For more details follow How to include library into maven local repository tutorial.
Resources
Copy the resources to the output directory for including in the JAR.
# mvn resources
Site
Generate a site for the current project.
# mvn site
Surefire
Run the JUnit unit tests in an isolated classloader.
# mvn surefire
Verifier
Useful for integration tests - verifies the existence of certain conditions.
# mvn verifier
Also can be used combinations of plugins, like
# mvn clean package install
Maven Archetypes
Maven archetypes are project templates which can be used to generate empty projects. Maven contains a lot of archetypes, but here are the most used archetypes.
Eclipse Archetype
This Maven archetype can generate a new Java project including files for the Eclipse IDE. You can generate that archetype using this Maven command:
# mvn eclipse:eclipse
Before running this archetype you need to have an existing maven project file (pom.xml).
IDEA Archetype
Similar to the Eclipse archetype, there is an IntelliJ IDEA archetype. You can generate the IDEA archetype using this Maven command:
# mvn idea:idea
Conclusions
Maven is a powerful tool used in all steps of development process from dependencies management to deployment. Any comments or suggestions are welcome.