Originally written March 2013, migrated to blog in 2016. I’d avoided Maven for about 5 years, but I was wrong, the entire world moved to it, then Ivy, and all the rest that followed….
The source material and quick guide is at:
To create your Java project
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
To create your web project
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-webapp
- validate: validate the project is correct and all necessary information is available
- compile: compile the source code of the project
- test: test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed
- package: take the compiled code and package it in its distributable format, such as a JAR.
- integration-test: process and deploy the package if necessary into an environment where integration tests can be run
- verify: run any checks to verify the package is valid and meets quality criteria
- install: install the package into the local repository, for use as a dependency in other projects locally
- deploy: done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.
Most common commands
mvn package mvn clean install mvn clean dependency:copy-dependencies package
The plugin I am using is from url below, in eclipse->help->updates menu.
Sadly, it starts to use the embedded maven and that is not what I want, so then, into preferences->maven->Installations
and select c;\java\apache-maven-3.04 which means it also picks up the M2_REPO - from the global settings field below the installations. Note that there is allso a User Settings tab for maven preferences, which will use another settings.xml. Providing you never create that file you can leave it alone.