Apache Maven: Difference between revisions
No edit summary |
No edit summary |
||
Line 24: | Line 24: | ||
A key feature of Maven is that it is network-ready. The core engine can dynamically download plug-ins from a repository, the same repository that provides access to many versions of different Open Source Java projects, from Apache and other organisations and developers. This repository and its reorganized successor, the Maven 2 repository, strives to be the ''de facto'' distribution mechanism for Java applications, but its adoption has been slow. Maven provides built in support not just for retrieving files from this repository, but to upload artifacts at the end of the build. A local cache of downloaded artifacts acts as the primary means of synchronizing the output of projects on a local system. |
A key feature of Maven is that it is network-ready. The core engine can dynamically download plug-ins from a repository, the same repository that provides access to many versions of different Open Source Java projects, from Apache and other organisations and developers. This repository and its reorganized successor, the Maven 2 repository, strives to be the ''de facto'' distribution mechanism for Java applications, but its adoption has been slow. Maven provides built in support not just for retrieving files from this repository, but to upload artifacts at the end of the build. A local cache of downloaded artifacts acts as the primary means of synchronizing the output of projects on a local system. |
||
Maven is |
Maven is built using a plugin-based architecture that allows it to make use of any application controllable through standard input. Theoretically, this would allow anyone to write plugins to interface with build tools (compilers, unit test tools, etc.) for any other language. In reality, support and use for languages other than Java has been minimal. Currently a plugin for the .Net framework exists and is maintained <ref>[http://doodleproject.sourceforge.net/mavenite/dotnet-maven-plugin/index.html NET Maven Plugin - .NET Maven Plugin<!-- Bot generated title -->]</ref>, and a C/C++ native plugin was at one time maintained for Maven 1.<ref>[http://maven.apache.org/maven-1.x/plugins/native/ Maven Native Plugin - Maven Native Plug-in<!-- Bot generated title -->]</ref> |
||
==Theory== |
==Theory== |
Revision as of 17:15, 25 September 2008
Developer(s) | Apache Software Foundation |
---|---|
Stable release | 2.0.9
/ April 10, 2008 |
Repository | |
Written in | Java |
Operating system | Cross-platform |
Type | Build Tool |
License | Apache License 2.0 |
Website | http://maven.apache.org |
- For other uses of the word Maven see: Maven (disambiguation)
Maven is a software tool for Java project management and build automation created by Sonatype's Jason van Zyl in 2002. It is similar in functionality to the Apache Ant tool (and to a lesser extent, PHP's PEAR and Perl's CPAN), but has a simpler build configuration model, based on an XML format. Maven is hosted by the Apache Software Foundation, where it was formerly part of the Jakarta Project.
Maven uses a construct known as a Project Object Model (POM) to describe the software project being built, its dependencies on other external modules and components, and the build order. It comes with pre-defined targets for performing certain well defined tasks such as compilation of code and its packaging.
A key feature of Maven is that it is network-ready. The core engine can dynamically download plug-ins from a repository, the same repository that provides access to many versions of different Open Source Java projects, from Apache and other organisations and developers. This repository and its reorganized successor, the Maven 2 repository, strives to be the de facto distribution mechanism for Java applications, but its adoption has been slow. Maven provides built in support not just for retrieving files from this repository, but to upload artifacts at the end of the build. A local cache of downloaded artifacts acts as the primary means of synchronizing the output of projects on a local system.
Maven is built using a plugin-based architecture that allows it to make use of any application controllable through standard input. Theoretically, this would allow anyone to write plugins to interface with build tools (compilers, unit test tools, etc.) for any other language. In reality, support and use for languages other than Java has been minimal. Currently a plugin for the .Net framework exists and is maintained [1], and a C/C++ native plugin was at one time maintained for Maven 1.[2]
Theory
Convention over configuration
The overarching philosophy of Maven is standardization of builds by embracing Convention over Configuration in order to utilize existing patterns in software production. This strategy necessarily restricts project variability to a large degree, which is reflected in Maven's exhortation to adhere to its project model.[3] While readily suitable for new projects, existing complex projects may be simply unsuitable for Maven usage.[4] The restrictiveness of the project layout convention was made somewhat more configurable with the release of Maven 2.
Reuse
Maven is built around the idea of reuse and, more specifically, the reuse of build logic. As projects are typically and frequently built in similar patterns, a logical choice would be to reuse the build processes. The main idea is not to reuse the code or functionality (like Apache Ant), but to simply change the configuration of already written code. That's the main difference between Apache Ant and Apache Maven: one is a library of good and useful utilities and functions, while the other is a configurable and highly pluggable framework.
Although Maven is somewhat configurable, historically the Maven project has heavily emphasized that users should adhere to their concept of a standard project model as much as possible.
Life cycle
The parts of the main Maven project life cycle are:
- compile
- test
- package
- install
- deploy
The idea is that, for any goal, all previous goals have already been successfully accomplished. For example, when running mvn install Maven will check if mvn package has successfully been run (the jar exists in target/), in which case it will not be run again.
Also, there are some goals that are outside the life cycle that can be called, but Maven assumes that these goals are not part of the default life-cycle (don't have to be always performed). These goals are:
- clean
- assembly:assembly
- site
- site-deploy
- etc.
But these goals can be added to the default life cycle through the project's POM.
The POM
IDE Integration
Maven replaces the IDE in the build process so its integration with the different Java IDEs is very important. There are Maven plugins for creating IDE configuration files from the POMs. Currently supported:
Assembly descriptor
Examples
Maven projects are created with a command line of the following kind:
mvn archetype:create -DgroupId="com.some.company" -DartifactId="some-project" -Dversion="0.0.1"
See also
- Apache Continuum, a continuous integration server which integrates tightly with Maven
- Apache Archiva, a repository manager developed by several core Maven committers
- Apache Ant
- Nexus Maven Repository Manager