Maven

This page is outdated and no longer receives updates!

Configuration

These pages describes how to use the popular Maven with the most common Java IDEs

For groups of developers working on limited internet connections it may be worth setting up a Maven proxy to reduce the amount of traffic required for Maven development. See Setting up a Maven proxy server for instructions on setting up the Nexus proxy server.

Common Maven Commands

List of common commands for working with the Maven OpenMRS branch: Maven Branch Except for the Jetty command, all commands are expected to be run from the root of the checked out project.

Maven can be downloaded here: http://maven.apache.org/download.html

Build Project and Run All Tests

Go to the most outer project directory and run:

mvn clean install

It will compile, run tests, build all artifacts and install them to your local repo. Built artifacts are located in the target directory of each module (api/web/webapp)

To build the project, but skip running tests (you must run tests when building for the first time in order to create test artifacts):

mvn clean install -Dmaven.test.skip=true

To run individual tests:

mvn test -Dtest=Classname

This will run the tests from Classname. So to run tests from ConceptTest, you need to go to api folder and type:

mvn test -Dtest=ConceptTest

Compile and Start Jetty for hot deployment

Must be run from the webapp directory. Starts up Jetty and deploys OpenMRS.
Requires increasing memory for Maven

Open the Internet browser and go to http://localhost:8080/openmrs

Compile and Start Jetty for hot deployment with JRebel

Must be run from the webapp directory. Starts up Jetty and deploys OpenMRS with JRebel to allow on-the-fly class and web resource reloading.
Warning: this does not work perfectly at the moment - please report any issues on the JRebel Support Forum.
Requires increasing memory for Maven

For working only with trunk, no file editing is necessary. For working with trunk and one or more module(s), please first edit webapp/pom.xml. Search for the string JRebel, and follow instructions regarding relevant modifications that must be done for working with JRebel and one or more modules.

Generate HTML Junit Report

The html output will be in: target/site/surefire-report.html

Generate Javadocs in Jar

Generates Javadoc html for each module in target/apidocs and packages to target/<artifact>-<VERSION>-javadoc.jar. For more details, see the Maven Javadoc Plugin

Generates Javadoc html for entire project in target/apidocs and packages to target/openmrs-<VERSION>-javadoc.jar. For more details, see the Maven Javadoc Plugin

Branching and Releasing

Creates a branch based on trunk. Also allows incrementing trunk version to next SNAPSHOT version. For more details, see the Maven Release Plugin

Increasing memory for Maven

  • In Linux: Add a file called ".mavenrc" to your home directory with this content:

  • In Windows: Add a new environment variable called MAVEN_OPTSand set it to

  • In Eclipse: Within the relevant Run Configuration, select the JRE tab and set the VM Argumentsto

By setting MAVEN_OPTS as an environment variable, the options specified will be applied to all Maven executions. However, this can be overridden by each project by specifying the parameters at the command line (or in the Eclipse Run Configuration).

Related pages