Maven
A maven is an expert in a particular field. The word comes from Yiddish. Maven is a through development of Ant [1], but works completely different.
Maven is succeeded by Maven 2 which has a different approach from version 1.
Maven's primary goal is to allow a developer to comprehend the complete state of a development effort in the shortest period of time.
In order to attain this goal there are several areas of concern that Maven attempts to deal with:
- Making the build process easy
- Providing a uniform build system
- Providing quality project information
- Providing guidelines for best practices development
- Allowing transparent migration to new features
Programming
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.
What is it
Maven provides a comprehensive approach to managing software projects. From compilation, to distribution, to documentation, to team collaboration, Maven provides the necessary abstractions that encourage reuse and take much of the work out of project builds.
[Better Builds with Maven, p.22]
Concepts
- Repositories for Artifacts
- POM (Project Object Model)
- Convention over Configuration
- Reuse of Build Logic
Continuous build
- Continuum, Apache Project Continuum a continuous integration server for building Java based projects. It supports a wide range of projects.
- Cruisecontrol, Sourceforge project CruiseControl is a framework for a continuous build process. It includes, but is not limited to, plugins for email notification, Ant, and various source control tools. A web interface is provided to view the details of the current and previous builds.
Install Maven 2
First download Maven from the apache site.
- Unpack the archive where you would like to store the binaries, eg:
tar zxvf maven-2.0.tar.gz
or
unzip maven-2.0.zip
- A directory called "maven-2.0" will be created.
- Add the bin directory to your PATH, eg:
export PATH=/usr/local/maven-2.0/bin:$PATH or set PATH="c:\program files\maven-2.0\bin";%PATH%
- Make sure JAVA_HOME is set to the location of your JDK
- Run "mvn --version" to verify that it is correctly installed.
For more information, please see http://maven.apache.org
The default directory of the repository on a WINTEL machine is (the quotes are essential).
"%USERPROFILE%\.m2\repository"
Maven User Quick Guide
Backward compatability hwas been the starting point, though there has been changes.
|
First Maven Project Creation
Creating your first project! In order to create the simplest of Maven projects, execute the following from the command line:
mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app
this will create the following pom.xml
:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.mycompany.app</groupId> <artifactId>my-app</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <name>Maven Quick Start Archetype</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> <reports> <report>..</report> ... </reports> </project>
Project Object Model (POM)
top The POM is the basic unit of work in Maven containing every important piece of information about your project and is essentially one-stop-shopping for finding anything related to your project.
|
|
Plugins
Maven should download plugins by itself. Unfortunately a redirection is used maven can not handle. To download a new/changed plugin use:
maven plugin:download -DgroupId=<groupId> -DartifactId=<atifactId> -Dversion=<versionNumber> -Dmaven.repo.remote=http://repo1.maven.org/maven,http://people.apache.org/repo
Example:
maven plugin:download -DgroupId=maven -DartifactId=maven-simian-plugin -Dversion=1.6.1 -Dmaven.repo.remote=http://repo1.maven.org/maven,http://people.apache.org/repo
Don't forget to remove the older version of the plugin from your repository cash. There are 3 plugin directories. Suppose you have entered in the build.properties, located in the USERPROFILE folder, the label value pair:
maven.home.local = C:/TEMP/maven-1.1-beta-2/.maven
then the (relative) path names mean:
Plugin | Description |
---|---|
../plugins | Source directory |
../.maven/cache | Unpacked plugin directory (repository cash) |
../maven/plugins | User plugin directory |
See also
- Apache-Maven, The Apache-Maven-Home-Site of all versions.
- Browse/Search Maven Repositories, Use this site for your searches for repositories and how to use them in Maven.
- Maven in Wikipedia. A maven (also mavin) is a trusted expert in a particular field, who seeks to pass knowledge on to others.
The word maven comes from the Hebrew, via Yiddish, and means one who understands, based on an accumulation of knowledge. See Apache Maven forthe Computer Maven version. - Maven 2 See also contains more links.
Maven 1
- Maven 1, Home of the 1st version of Maven.
- Maven Repository, Home of the repository for Maven . Do not browse, use the Search instead.
- Maven Repository Mirror --can be slow to load, is an alternative for the original Maven repository.
Maven 2
- Maven 2, Harm's wiki special for Maven 2.
- Maven 2, Home of the 2nd version of Maven. The latest Maven-version is 3.0.3 ( © 19 May 2011, last modified: GMT: 03:53, 2024 December 12, Maven).
- Maven 2 Repository, The original Maven 2 repository. Do not browse, use the Search instead.
- Maven 2 Repository Mirror --can be slow to load, is an alternative for the Maven 2 Maven 2 repository.
Related
- Cobertura is a free Java tool that calculates the percentage of code accessed by tests. It can be used to identify which parts of your Java program are lacking test coverage. It is based on jcoverage.
- CodeHaus is a collaborative environment for building opensource projects with a strong emphasis on modern languages, focussed on quality components that meet real world needs.
- Ibiblio Website of Ibiblio, The Public's Library and Digital Archive. A public interface to read public domain books online. And the home-site for maven repository mirrors.
Developers Notebook
To use maven, read the maven Developers Notebook, by Vincent Massol and Timothy O'Brien.
Jars for Maven
Missing jars for maven? Look here:
Plugins for Maven
Many plugins are available. The ones named below have a special page on this site.
How to get Maven
Example Files
See also
- Maven 2, the successor of Maven version 1 has a different POM and command line name.
- Coding Standards, Quality control of the programming standards.
If you like Maven you may like Ant too.