Update November 2018: This blog post has been superseded by the OpenMRS SDK (https://wiki.openmrs.org/display/docs/OpenMRS+SDK)
My team mates and I are completing a number of OpenMRS workshops focused on improving our module development capability. This blog post captures the unwritten lessons that we have picked up as a way of giving back our lessons to help others in the community (and will be moved to the OpenMRS Wiki once the lessons have been internalized and consolidated, as that is its natural home).
The approach is based on the following OpenMRS community articles:
- Creating Modules – https://wiki.openmrs.org/display/docs/Creating+Modules
- Creating your First Module – https://wiki.openmrs.org/display/docs/Creating+Your+First+Module
As you develop the module it is important to keep testing and verifying whatever you do especially when the module involves user interface components, extending the OpenMRS UI. The process we ended up using was as follows:
- Setup a module using the module creation command line utility
- Downloaded Spring Loaded from its maven repository http://mvnrepository.com/artifact/org.springframework/springloaded
- Downloaded and setup OpenMRS standalone from http://openmrs.org/download/ picking a version greater than 1.11.x which supports debugging options
- Once the standalone version is installed, open the openmrs-standalone-runtime.properties and add the following variables to the vm_arguments: (should all be one line – separated here for clarity)
- -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
- -Dmodule.development.directory={absolute path to root folder of the module}
- -javaagent:{absolute path to spring loaded jar}
- -noverify -Dspringloaded=inclusions=org.openmrs.module.modulepackage..* (note the two trailing dots before the *)
- Setup newly the module into an IDE (tested with IntelliJ & Eclipse)
- Installed a FileSync utility, RemoteSynchronizer for IntelliJ & FileSync (http://andrei.gmxhome.de/filesync/) for Eclipse
- Setup sync for the omod webapp folder into the standalone webapp folder located at WEB-INF/view/module/{modulename}
Our development workflow is smoothened out since any changes to Java classes & JSPs are automatically applied & reflected in the standalone app.
Additional Tips and Tricks
- Tomcat – Change the following init params in web.xml:
- modificationTestInterval from 4 to 0, so that JSPs are automatically recompiled
- development is true (this is the default)
- Intellij – the Java classes are not automatically recompiled on saving changes so there is need to run mvn package -DskipTests
- Follow the OpenMRS conventions as much as possible by cloning openmrs-core to see how the design of the interfaces, service layers is done. This will help get access to lots of the magic that happens behind the scenes.
- Java 8 will give you trouble, stick to 1. 7 as we did not try 1.6 anywhere.
As i said i am impressed with your developments on software developments, we can discuss about many issues about s/w devt. My contacts are 0704932289. Hope to hear from you asap. Robert.