## Overview

The following assumes basic familiarity with use of source repository and command-line build systems.

## Building with Maven

Maven is a network-based build management system. We assume the binary distribution has been installed (version 2.2.1 or above, 3.0 or above for reporting) and that the executable mvn is in the system path.

People new to Maven may find useful to download a PDF version of the website documentation. There is also extensive free documentation available from the Sonatype Maven Books.

### Maven settings.xml

To activate the use of the settings.xml provided:

    mvn -s settings.xml clean install

The settings.xml defines the repositories for all the required dependencies that are not found in Maven Central. Typically, you need to invoke the -s settings.xml only once to cache the dependencies. Also, if you are running in a corporate environment, you may be using a Maven Repository Manager, such as Nexus, which may proxy the repositories behind a public open-source group.

### Maven build profiles

One of Maven's most useful features are profiles.

JBehave's profiles are:

- default: builds all releasable modules
- examples: runs examples
- gui: runs examples that require non-headless mode (separated as they do not run on CI)
- reporting: builds reports
- distribution: builds distributions, both "bin" and "src"

Note that profiles are additive and the default profile is always active.

Some examples:

    mvn clean install -Pexamples (build core and runs examples, excluding GUI-based ones)
    mvn clean install -Pexamples,gui (build core and runs all examples, including GUI-based ones)
    mvn clean install -Preporting,distribution (build with reporting and distribution)

Note that the Maven build phase install is used as it automatically implies all other previous phases in the module build cycle, in particular the test or integration-test phases, where appropriate.

### Performing a release

Using Maven's release plugin makes the release process very easy:

    mvn release:prepare -Preporting,distribution
    mvn release:perform -Preporting,distribution

It is a two-step process as the first step (release:prepare) creates a tag in source control replacing all snapshot versions with a fixed version, while the second step (release:perform) builds the release from the tag and performs the upload to the remote repository.

## Integration with IDEs

Maven is supported in most modern IDEs - e.g. Intellij IDEA or Eclipse (via the m2eclipse plugin). It builds the project classpath based on the dependencies declared in the POMs.