Skip to content
ldcouto edited this page Dec 3, 2014 · 1 revision

Maven Survival Guide

General

Maven is a software tool for Java project management and build automation. It's primary advantage over using things like Ant is that it automates dependency resolution. See Apache's "What is Maven?" page for a better high-level description.

Normal Usage

If you have a checked out repository, the basic commands are

mvn
mvn -f ide/pom.xml

Where the first will build the core Overture libraries, and the second will build the IDE. Assuming everything completes successfully, there will be an runnable application in ide/product/target/products/org.overture.ide.platform.product/<platform>/<windowing-system>/<architecture>/Overture/.

Equivalent to those commands is

mvn -PWith-IDE

To clean up the working directory and delete all of the build products, do

mvn -PWith-IDE -Dtycho.mode=maven clean

Build Lifecycles

The build lifecycle is a list of named phases which can be used to give order to goal execution. This means that a goal of a plug-in can be bound to a specific phase thus called when this phase is reached in the build:

  1. process-resources
  2. compile
  3. process-test-resources
  4. test-compile
  5. test
  6. package
  7. install
  8. deploy

There are also the site and clean phases, though they are not active by default. The typical invocation of maven runs through the phases in the numbered list above, stopping after the install phase (for Overture, at least, as the Overture build has install:install set as the default goal).

Notable Local "Quirks"

The Overture build is split into two chunks: what's in the ide/ subdirectory, and everything else. This comes about because we use the Eclipse Tycho maven plugin to create standalone Overture binaries.

So, if maven is invoked in the repository root, it will ignore the ide/ directory and build all of the pure-java parts of the project. If maven is invoked with the -PWith-IDE flag, or in the ide/ directory directly, then Tycho will be enabled and it will build the Eclipse-based parts of the project (in addition to the core, if using the flag). This dual behaviour comes about because Tycho has a long-standing bug in Tycho that does dependency resolution in the wrong place (see their wiki page and bug report 353889 about it). The Tycho devs don't see the bug as critical, so don't expect it to be fixed any time soon.

Basic Goals

Goal Description
compile Compiles the project and all sub projects
test Runs compile and then tests
package Build a jar containing the compiled resources of the project.
install Installs the jar of the project in the local repository including its own pom so other plug-ins which depends on it just can add this to their classpath.
clean

Options

Option Description
-X Show debug info
-o Run offline. This speeds up the process a lot if you have already downloaded all dependencies to the local repository.
-N Do not run recursively. (Do not run subprojects)
-fae Fail at end. This is use full if running a root project. Allow all non-impacted builds to complete.
-Dmaven.test.skip=true Skip all testing
-Dmaven.javadoc.skip=true Skip javadoc compilation
-Dtycho.mode=maven Disable tycho dependency resolution