OpenMRS SDK 2.x

OpenMRS SDK 2.x

Important!

This version is outdated. Please use latest SDK version: OpenMRS SDK

Overview

OpenMRS SDK (latest version - 2.1, released on 2015/11/18) allows for rapid development of modules and the OpenMRS Platform code. It is an ever expanding project with a rich feature-set, outlined below. Operating System compatibility was also taken into account, allowing users to install the SDK and be up and running within a few minutes on Windows, Linux and Mac OS X.

The SDK was proposed as a GSoC 2013 Project, which was then developed by @Chris Niesel and @Rafal Korytkowski (Mentor) throughout the length of GSoC 2013.

In GSoC 2015 the OpenMRS SDK was reworked by @Dmytro Trifonov and @Rafal Korytkowski (Mentor) to support OpenMRS 2.x and provide better integration with IDEs by the mean of a maven plugin.

Feedback 

Please help us improve SDK. We kindly ask you to report any problems in JIRA or in notes. Please include the output of openmrs-sdk:help in your problem description. In order to test SDK on your computer please go through the Step By Step instructions that you find below.

Release Notes

  • 2.1 (released on 2015/11/18)

  • 2.0.3 (released on 21/09/2015)

  • 2.0.2 (released on 27/08/2015)

  • all release notes...

Installation

1. Development Environment Check

Before we get started with the installation of the OpenMRS SDK you have to make sure that if you are planning on working in conjunction with GitHub, that you have
Git installed. For a howto on how to do that see here.

Once Git is installed, you have to make sure that you have the Apache Maven installed. To see if you do, open up a console/terminal and enter

mvn -v

You should see output like this:

SDK requires Maven 3+ and JDK 1.7+ installed. You can download Maven from here and install.

If you do not have similar output, you are missing the Maven, please go ahead and install it.
Here are tutorials for Windows, Mac OSX, Ubuntu.

You will also want to make sure that your maven has enough memory available for building code, running tests and servers. Please set the MAVEN_OPTS system property to "-Xmx2048m -XX:MaxPermSize=1024m". It depends on your OS how you set it up. See http://stackoverflow.com/a/2820738 for Windows or http://unix.stackexchange.com/a/117470 for Unix/Linux.

If you are using an IDE for calling openmrs-sdk commands, please make sure to configure VM arguments in run configurations accordingly.

Once completed this, let's move onto setting up the sdk.

2. Setting up OpenMRS SDK

For setup the SDK you just need to open the terminal and execute:

mvn org.openmrs.maven.plugins:openmrs-sdk-maven-plugin:setup-sdk

Once it is finished, you can make sure the SDK works. To do so, open up a terminal/console and issue the following:

mvn openmrs-sdk:help

The output it gives, should be similar of that below:

If that is the case, you have successfully installed the SDK.

3. Upgrading OpenMRS SDK

If your SDK version isn't the latest version, you can update it using -U option with any SDK command.

For example, execute mvn openmrs-sdk:help -U, to be sure that you have the latest version installed.

Examples of usage

Useful tip

 For all commands, you may not pass any attributes. In this case, all required parameters will be prompted in interactive mode.

Creating a module

OpenMRS Platform module

The SDK allow you, the user to create a basic module, with little effort! All that you have to do is, make sure you have a console/terminal window open and make sure you are
in a directory that you have write access to.  If that is the case, you just issue the following:

mvn openmrs-sdk:create-platform-module

This will now prompt you for various inputs, the default value/name is already assigned, which you can change if you input your own.
Once the creation process is finished, you can now start working on your module. Be sure that you initialize a git project and push it to 
your Github account for easy development access. 

OpenMRS Reference Application 2.x module

Similarly as creating OpenMRS 1.x module, you can create module for OpenMRS 2.x. For that, you can execute command:

mvn openmrs-sdk:create-module 

Creating a server

OpenMRS Platform server

For running and testing OpenMRS modules we need to create and configure an OpenMRS server instance. For creating a OpenMRS platform server you can use setup-platform command.

Example:

mvn openmrs-sdk:setup-platform -DserverId=test -Dversion=1.11.2

NOTE FOR WINDOWS USERS

In windows, the command above may give a maven error stating POM.xml not found..build failed. To resolve this issue, avoid inserting the parameters. Instead, simply type in :

mvn openmrs-sdk:setup-platform

And you will be prompted for the parameters which you can enter manually. Same instructions go for setting up the Reference Application server as well.

You can pass server attributes for the server. To get full list of them, see setup-platform section of this documentation.