Monday, March 25, 2013

Useful maven targets

Kickstart of maven commands.

mvn compile
compiles the project

mvn clean compile
cleans and compiles the project. List of targets is supported as arguments to maven

mvn jar:jar
makes jar file in target folder

mvn assembly:assembly
builds the project, run project tests and makes a jar with dependancies. Assembly module is needed.


mvn assembly:single
builds the project, skip project tests and makes a jar with dependanciesAssembly module is needed.

mvn tests
run project tests

mvn test -Dtest=SaleTest
run specific test. No need path to be specified. No need extension to be specified (SaleTest, not SaleTest.java)


mvn install
installs current project in the repository, so other projects could depend on it

mvn install -DskipTests

installs current project in the repository, so other projects could depend on it; skip executing tests, which could prevent installation of project (the artefact)


mvn jetty:run
Runs the project in jetty web server - for web applications


.