Apache Maven is a dependency management and project build system that Elastic Path utilizes to build all of our projects.
It is a prerequisite to doing binary-based development with the Elastic Path source.
The Elastic Path Developer's guide is not a primer for learning Maven. This manual assumes you already have a basic understanding of Maven profiles, archtypes, etc. For a good Maven primer document, see Sonatype's online manual Maven: The Complete Reference
Maven is an open source build system that utilizes convention over configuration and has a powerful plug-in system for delegating tasks to different stages of the build cycle.
In Maven, a project is defined by the presence of an XML file called a Project Object Model (POM). In the POM, all necessary project information such as dependencies, properties, project inheritance, and build configurations are declared. It is similar to a Makefile or an Ant build.xml in that it is the figurative “map” of the project. However, unlike a build.xml which tells Ant the precise steps to do as it runs, a POM states configurations to the default Maven behavior.
See the Maven POM Reference for more in-depth detail.
Build Cycle Basics
One of the central concepts of Maven is the idea of a build cycle - that the process of building a project is clearly defined. According to this process, the task of building consists of a number of sequential steps to execute. In other words, in order to move on to the next step, all previous steps must be executed first. ie. To package code into a JAR, you must first validate and compile the code.
In Maven, there are three defined build cycles: default, clean, and site. The default build cycle is outlined below:
Validates the project and sees if all necessary information is provided.
Compiles the source code.
Packages the code into a distributable format. ie. JAR or WAR
Verifies package validity.
Installs the package within the local Maven repository for use in other projects.
To execute a Maven install and all previous phases, run:
To create a JAR file but not install it in the Maven repository, run:
For more information, refer to Maven's Introduction to the Build Cycle.