Maven is a tool design to support as many task as possible for the management of a software project.
Its purpose is to provide a simple tool to achieve the following tasks:
- Builds
- Documentation
- Reporting
- Dependencies
- SCMs
- Releases
- Distribution
A number of good tutorials can be found on maven's guide page.
Archetypes:In maven there is the possibility to create archetype models of projects. This means that it is possible to create very easily new projects which have a number of templates to start with. This is related to the possibilities of RAILS.
This is performed by issueing the following command:
$ mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-appProject Object Model: POM
There is a concept of project object model somewhat similar to the ant build files.
An example from the website (see this page):
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.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>
</project>
This model is quite easy to understand.
Project File and Directory StructureThe project file and directory structure depends on the archetype chosen to create a new project. There are means of configuring this, see: http://maven.apache.org/guides/mini/guide-creating-archetypes.html.
The build Life cycleEach possible tasks (e.g. validate, compile, package) may require other to be performed first. This means that there are dependencies between the tasks (like in ant).
Common tasks- mvn compile (compile the code)
- mvn test (test the functionalities of this project)
- mvn test-compile (compile test classes for this project)
- mvn package (package the code of this project)
- mvn clean (clean the builds and task )
- mvn site (create a template website for the project)
- mvn idea:idea (create an IntelliJ IDEA descriptor for the project)
- mvn eclipse:eclipse (create the project description files for eclipse)
There are a number of plugins which can be useful for maven. You can add them to the POM file of the project, see: How_do_I_use_plug-ins
A list of plugins can be found there.
SCM Plugin ( Source Code Management plugin)One of the many pluging is the SCM plugin which offers useful tasks/goals for interacting with a SCM
External DependenciesThere is also the possibility to configure external dependencies.
DeploymentThere are also possibilities of deployment if things are configured. For example, the created distribution can be copied and added to a repository using scp. For this, some information about user names, keys and/or passwords have to be configured.
DocumentationThere are also some thing to help in the creation of a documentation site using archetypes. See: guide-site.