Maven 2
Maven 2 [1] is a through development of Maven (See also the Maven site). Information on maven can be found at the Apache Maven Site and on the Mojo Codehaus site.
On the maven site there are 2 excellent starting guides:
- Maven in 5 minutes
- Maven gettings started Guide, A 30 minutes introduction
Starting maven 2
To start just begin with:
mvn clean install
Builds all the modules, and installs them in the local repository. The local repository is created in your home directory (or alternative location that you created it), and is the location that all downloaded binaries and the projects you built are stored. Normally this location is %USERPROFILE%/.m2
Phases and Goals
The most common default lifecycle phases executed
- 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.
There are two other Maven lifecycles of note beyond the default list above. They are
- clean: cleans up artifacts created by prior builds
- site: generates site documentation for this project
Phases are actually mapped to underlying goals. The specific goals executed per phase is dependant upon the packaging type of the project. For example, package executes jar:jar if the project type is a JAR, and war:war is the project type is - you guessed it - a WAR.
An interesting thing to note is that phases and goals may be executed in sequence.
mvn clean dependency:copy-dependencies package
This command will clean the project, copy dependencies, and package the project (executing all phases up to package, of course).
Missing something
In case something missing you get:
- xxx:maven-simian-plugin:plugin:1.6.1
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=xxx -DartifactId=maven-simian-plugin -Dversion=1.6.1 -Dpackaging=plugin -Dfile=</path/to/file>
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=xxx -DartifactId=maven-simian-plugin -Dversion=1.6.1 -Dpackaging=plugin -Dfile=</path/to/file> -Durl=[url] -DrepositoryId=[id]
Path to dependency:
- xxx:plsql:jar:1.0-SNAPSHOT
- xxx:maven-simian-plugin:plugin:1.6.1
1 required artifact is missing.
Repository
A useful place to look for Maven2 repository are
- mvn-repository, The main site name
- mvn-repository, Maven site.
Configuration
Maven 2 uses the settings file to configure settings in the settings.xml file located in the conf directory. A schema is available at: http://maven.apache.org/xsd/settings-1.0.0.xsd Configuration Example
Plugins
Maven is - at its heart - a plugin execution framework; all work is done by plugins. Look at the links below for a specific goal to execute. The most common plugins are listed below
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
- Overview of available plugins at Apache Maven
- Rose India, Maven2Eclipse Plug-in
- Overview of the collection plugins at Mojo Codehaus
- Code Google Maven Plugins
Sandbox
Not all plugins are released to use. In some cases it is necessary to build the plugin yourself.
More...
Plugin Errors
If you get a message like: The PluginDescriptor for the plugin Plugin [<name>] was not found. the plugin is probaby not suited for usage in maven 2. Example are the cobertura report plugin. Try to find another version of the plugin or build your own version.
Reporting
Plugins
The most important reporting pkugins for Maven2 can be found at:
Plugin | From | Status | Description |
---|---|---|---|
Checkstyle | Apache | Release | Checks the code style against the project standards |
Clover | Alassian | Release | Tests the coverage of the tests with a database, |
Cobertura | Mojo Codehaus | Release | Tests the coverage of the unit tests. See Cobertura ar Sourceforge. |
DOAP | Apache. | Release | Generates a Description of a Project (DOAP) file from a POM To generate the DOAP file use mvn -N doap:generate |
Docck | Apache | Release | Checks that a project complies with the Plugin Documentation Standard. |
Javadoc | Apache | Release | Creates javadoc. Look at the website for all the available goals (Mojo's). |
Jxr | Apache | Release | The JXR plugin produces a cross-reference of the project's sources |
Pmd | Apache | Release | Code analysis tool on your project's source code and generate a site report with its results. It also supports the separate Copy/Paste Detector tool (or CPD) distributed with PMD. |
Project-info | Apache | Release | Generate reports information about the project. |
Simian | Mojo Codehaus | Sandbox | Generates a copy/paste detection (duplicate lines) based on the Redhill Simian tool. More about Maven sandbox |
Sonar | Mojo Codehaus | Release | Sonar is an open platform to manage code quality. As such, it covers the 7 axes of (source) code quality: Architecture Design, Comments, Coding Rules, Potential Bugs, Complexity, Unit Test, Duplications. See Nemo for an on line insight of Open Source Projects. See Sonar Documentation for more in depth information and documentation. |
Surefire | Apache | Release | Parses the generated TEST-*.xml files under ${basedir}/target/surefire-reports and renders them to DOXIA which creates the web interface version of the test results. |
Documentation & Guides
- Apache Maven Documentation & Guides
- Maven-2-0 How to Guide, Scribd electronic books.
- Java World Article Getting the most out maven 2
- Jan Dockx Maven 2 Training online (Del.ico.ous).
See also
- Maven See also on this wiki contains more links.
- Collection of plugins at Mojo Codehaus, The Mojo project is a collection of plugins for Maven 2.
Plugins are currently being published to the Codehaus repository. Previous releases have also been published on the Maven Central repository. Snapshots are available on request through the user mailing list or by emailing the maintainer. Each plugin has a list of people involved in creating or supporting it. - Nemo Sonar Source, Sonar website containing the Apache,
- SonaType, Sonatype is transforming software development. The company was founded by Jason van Zyl, the creator of Apache Maven, to deliver innovative solutions that increase developer productivity, improve project management and reduce business risk. Sonatype’s value-added Maven products and services help organizations optimize their development process and create a standard development infrastructure. Software development organizations rely on Sonatype to deliver better software faster, while adhering to internal standards and policies. Sonatype is privately held with investments from Accel Partners, Bay Partners, Hummer Winblad Venture Partners, and Morgenthaler Ventures.
- Maven2 Eclipse, How to use Maven2 and Eclipse