Page tree

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


To import the templates copy the tools/src/main/resources/intellij/templates.xml file to the destination given to you in these IntelliJ sharing live templates instructions.

You might need to restart IntelliJ if you do not see the imported templates right away. The next section shows you Follow the next section on how to see and use the templates.

See all templates available

After importing the templates restart IntelliJ, open the IntelliJ preferences and enter the search term "templates" which should show Editor -> Live Templates under the results in the left pane like shown here

Image RemovedImage Added

As you can see the templates are in what IntelliJ calls "template group" named "OpenMRS" so you can easily find and enable/disable the templates if you for example work on other projects.


  • type in the name of the template (which you can find in the Templates settings as shown above)
  • (if the context menu does not show hit Control+Space)
  • hit TAB to expand the code template (this can be changed in the template settings Options -> Expand with)
  • if there are variables in the template you can now override them and advance to the next variable or the end with ENTER

to speed up coding and adhere to the OpenMRS style more easily.

Read the next sections for some examples.


To add a new unit test to a test class, open the test class in the editor. Place the cursor to where you want to add the test and write test which will open a context menu


If you want to log an event in a class that does not yet have an instance of a Logger open the class and place the cursor to the top and type logger which will show you a list of options like shown below


You see the access modifier defaults to private but is selected so you can overrule that if you'd like, by hitting ENTER you accept the snippet default value and

you are ready to log!

Log an event

If your class already has a Logger instance just place the cursor to where you want to log and type logd (for debug), logi (for info), ... hit Control+Space (for the context menu) select the template and hit enter. Depending on what template you are using you might need to only enter your log message or also add a parameter after the message like for example for loge logpe (for logging errors).an error and passing it an exception) or logpi (to log an info message using the slf4j parametrized message style like"the temperatur was {}", temperatureObject) ).

Import OpenMRS core into IntelliJ