Maven cheatsheet
Tuesday, January 6th, 2009Search for maven artifacts
http://maven.ozacc.com/ http://www.mvnrepository.com/
Create a new project (standard application)
mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app
Create a new project (web application)
mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-webapp -DgroupId=com.mycompany.app -DartifactId=my-webapp
Resolve all dependencies
mvn dependency:resolve
Resolve all dependencies & their source attachments
mvn dependency:sources
Analyze dependencies
mvn dependency:analyze
Generate Ant build files
mvn ant:ant
Remove target directory & all build data
mvn clean
Compile
mvn compile
Build the package (JAR is the default)
mvn package
Only compile the unit tests
mvn test-compile
Compile & execute unit tests
mvn test
Compile & execute a single test
mvn -Dtest=MySingleTest test
Copy all the dependencies to target/dependency
mvn dependency:copy-dependencies
Assemble a package with all dependencies included
mvn assembly:assembly -DdescriptorId=jar-with-dependencies
Assemble a package with the sources
mvn assembly:assembly -DdescriptorId=src mvn source:jar mvn source:test-jar
Skip the tests when packaging
mvn -Dmaven.test.skip=true ...
Install an external jar into our local repo
mvn install:install-file -DgroupId=javax.transaction -DartifactId=jta -Dversion=1.0.1B -Dpackaging=jar -Dfile=/path/to/file
VCS Checkin
mvn -Dusername=username -Dpassword=password -Dmessage="Some message" scm:checkin
Prepare a release
mvn release:prepare
Translate 1.5+ project with retrotranslator
mvn package retrotranslator:translate-project
