Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. This Developer Center contains the guides for Commerce 6.13.0 through 7.4.1.Visit new site

This version of Elastic Path Commerce is no longer supported or maintained. To upgrade to the latest version, contact your Elastic Path representative.

Maven

Maven

Apache Maven is a dependency management and project build system that Elastic Path utilizes to build all of our projects.

Warning: Learning Maven

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

Overview

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:

Build Phase

Task

validate

Validates the project and sees if all necessary information is provided.

compile

Compiles the source code.

test

Runs tests.

package

Packages the code into a distributable format. ie. JAR or WAR

verify

Verifies package validity.

install

Installs the package within the local Maven repository for use in other projects.

To execute a Maven install and all previous phases, run:

mvn install

To create a JAR file but not install it in the Maven repository, run:

mvn package

For more information, refer to Maven's Introduction to the Build Cycle.