Wiki Spaces


Get Help from Others

Q&A: Ask OpenMRS
Discussion: OpenMRS Talk
Real-Time: IRC Chat | Slack


Page tree
Skip to end of metadata
Go to start of metadata


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:

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

mvn jetty:run

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.

export MAVEN_OPTS="-noverify -javaagent:PATHTOJREBELJAR/jrebel.jar"
mvn jetty:run -P jrebel

Generate HTML Junit Report

mvn surefire-report: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

mvn javadoc:jar

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

mvn javadoc:aggregate-jar

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

mvn release:branch -DbranchName= -Dusername= -Dpassword=

Increasing memory for Maven

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

    MAVEN_OPTS="$MAVEN_OPTS -Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m"
  • In Windows: Add a new environment variable called MAVEN_OPTSand set it to

    -Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m
  • In Eclipse: Within the relevant Run Configuration, select the JRE tab and set the VM Argumentsto

    -Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m

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).