Sunday, March 29, 2015

Maven Cheat Sheet


In this note I'll mention some useful Maven commands with short description. From my point of view those are really often used and easy to forget if You switch to project with Ant or another build tool.

At the very beginning short quote from original Maven site: www.maven.apache.org
Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.
So let's start with list:

1. mvn generate:archetype - starts process of auto project creation

2. mvn generate:archetype > output.txt - saves all possible archetypes into external file, really useful because of great number of options.

3. mvn –Dtest=TestApp#testApp testruns exact test from specified test class

4. mvn –Dtest=TestApp#* testruns all tests from specified test class

5. mvn -Dgroups=’broken’ - runs all tests with specified group

6. mvn -Dtest=TestCircle#testOne testTwo test - runs several tests in the row

7.  mvn sitebasic information about project

8. mvn cleanremove target folder before any other goal to be executed

9. mvn test-compile - executes tests and compiling project

10. mvn dependency:resolve - resolves project dependencies 

11.  mvn idea:idea - generates project for IntelliJ Idea

12. mvn eclipse:eclipse - generates project for Eclipse

13. Some most common Maven phases:
  • 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.
  • site: generates site documentation for this project
Sure it's definitely not a complete list of Maven options, but those listed above I'd like always keep in mind, for all others I can type help or simply Google that :)

No comments:

Post a Comment