Maven is a Java project management and project comprehension tool. It's primary goal is to make
the developers life easier by providing a well defined project structure, well defined development
processes to follow, and a coherent body of documentation that keeps your developers and clients
apprised of what's happening with your project.
Maven is distributed at no charge for commercial or non-commercial use
and is licensed under the Apache License, Version 2.0.
More information about Maven can be found at: http://maven.apache.org
The latest Maven version can be downloaded from:
http://maven.apache.org/download.html
Maven commands.
Information
none
Operating system used
Windows Vista Home Premium SP 2
Software prerequisites
Maven 3.0 or higher.
Procedure
- A maven command looks like:
mvn <phase>
mvn <plugin-prefix>:<goal>
mvn <groupId>:<artifactId>[:<plugin-version>]:<goal>
mvn <phase> <plugin-prefix>:<goal> <phase> ....
The above mentioned phase, plugin-prefix, goal, groupId, artifactId and plugin-version can be found in the pom.xml and effective pom.xml.
Example pom.xml:
:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
:
Example effective pom.xml:
:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<executions>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
:
</execution>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
:
</execution>
</executions>
:
</plugin>
:
- goal
Every goal is a specific task executed by a plugin.
- plugin-prefix
A plugin generally provides a set of goals and can be referenced by its plugin-prefix.
- An official maven artifactId always starts with the word "maven":
maven-<plugin-prefix>-plugin
In this example, to execute the "compile" goal, you can type:
mvn org.apache.maven.plugins:maven-compiler-plugin:compile
- or -
mvn compiler:compile
- If you create your own plugin you must NEVER start with the word "maven".
You will typically name your plugin:
<plugin-prefix>-maven-plugin
For example:
test-maven-plugin
- phase
A maven build lifecycle is the order of phases (<phase>..</phase>) defined in the effective pom.xml.
Available maven lifecycle phases are:
- validate
- initialize
- generate-sources
- process-sources
- generate-resources
- process-resources
- compile
- process-classes
- generate-test-sources
- process-test-sources
- generate-test-resources
- process-test-resources
- test-compile
- process-test-classes
- test
- prepare-package
- package
- pre-integration-test
- integration-test
- post-integration-test
- verify
- install
- deploy
- pre-site
- site
- post-site
- site-deploy
- pre-clean
- clean
- post-clean
Note:
Not all phases can be used, see your effective pom.xml which phases you can use.
When a phase is called via maven command line, for example mvn compile, only phases upto and including that phase (as specified in the effective pom.xml) will be executed.
If you look at this effective pom.xml the following phases are defined (in this order):
- test-compile
- compile
- clean
- install
- process-resources
- process-test-resources
- test
- package
- deploy
- site
- site-deploy
If you type: mvn install
It will execute the following phases (in this order): test-compile, compile, clean and install.
If you type: mvn compile
It will execute the following phases (in this order): test-compile, compile.
If you type: mvn test
It will execute the following phases (in this order): test-compile, compile, clean, install, process-resources, process-test-resources and test.
Each phase in turn has one or more goals (see <goal>..</goal> in your effective pom.xml), which will be executed in the order specified in the effective pom.xml.
If you only want to execute a specific goal, type: mvn <plugin-prefix>:<goal>
For example: mvn compiler:compile
Maven executes the phases and/or goals in the order they are specified in the command line.
- If you want to know more about a groupId:artifactId, plugin or cmd, use the maven help plugin.
You must specify either: both "groupId" and "artifactId" parameters OR a "plugin" parameter
OR a "cmd" parameter. For instance:
- mvn help:describe -Dcmd=install
- mvn help:describe -Dcmd=help:describe
- mvn help:describe -Dplugin=org.apache.maven.plugins:maven-help-plugin
- mvn help:describe -DgroupId=org.apache.maven.plugins -DartifactId=maven-help-plugin
-
mvn help:describe -Dgoal=compile -DartifactId=maven-compiler-plugin -DgroupId=org.apache.maven.plugins -Ddetail
-
mvn help:describe -DgroupId=org.mortbay.jetty -DartifactId=jetty-maven-plugin -Dgoal=run -Ddetail
- mvn help:help -Ddetail=true
|
|