Using the Module Maven Archetype

This page is outdated and no longer receives updates!

Setup of module wizard

Deprecated

This tool has been replaced by the OpenMRS SDK. Use that instead.

Prerequisite: Maven should be installed in you system. Check the command "mvn --version". It should display your system and maven properties.

Copy the below OpenMRS profile tag into your Maven settings.xml. The file may be found (depending on your OS) in:

  • Linux: ~/.m2

  • Windows: C:\Documents and Settings\$USER$\.m2

  • Vista/Windows7: C:\Users\$USER$\.m2

If you prefer not to modify your user Maven settings, you can point to temporal settings by specifying the -s parameter

mvn -s path_to_settings.xml [other options] [<goal(s)>] [<phase(s)>]

If the settings.xml file does not exist, create the file and copy into it the following:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <pluginGroups> <pluginGroup>org.openmrs.maven.plugins</pluginGroup> </pluginGroups> <profiles> <profile> <id>OpenMRS</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <archetypeCatalog>http://mavenrepo.openmrs.org/nexus/content/repositories/public/archetype-catalog.xml</archetypeCatalog> <archetypeRepository>http://mavenrepo.openmrs.org/nexus/content/repositories/public</archetypeRepository> </properties> <repositories> <repository> <id>openmrs-repo</id> <name>OpenMRS Nexus Repository</name> <url>http://mavenrepo.openmrs.org/nexus/content/repositories/public</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>openmrs-repo</id> <name>OpenMRS Nexus Repository</name> <url>http://mavenrepo.openmrs.org/nexus/content/repositories/public</url> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> </settings>

Using module wizard

  1. Go to a folder where you want to create a project (like your workspace folder)

  2. Run the following maven plugin command

    mvn module-wizard:generate

    or

  3. Follow the wizard questions

The wizard prompts with the following pattern:
question: default answer: : <input by user>

For instance "groupId: org.openmrs.module: : <input by user>" is a question about "groupId" with a default answer "org.openmrs.module".
The default answer will be set if you do not type anything and press enter.

If a question ends with "(y/n)" then an answer should be a letter 'y' (yes) or 'n' (no) (case insensitive).
For instance "Do you want to add an admin page link (y/n): n: : <input by user>" requires to answer 'y' or 'n' with a default answer 'n'.

Valid OpenMRS versions to depend on can be found in our maven repository

Example output

 

Description

Example

File Structure

 

Description

Example

File Structure

a)

Creation of basic Demo Module:     

  • It creates basic file structure of an openmrs module with a ModuleActivator.java     

  • To create a basic module you should set all other module wizard questions to 'n'.

b)

Creation of Demo Module with a link in the admin page:     

  • It creates a module similar to basic module with extra AdminList.java file to create a link in the OpenMRS admin page under the module name as well as a controller and a jsp page for that link.

  • To create a module with an admin link you need to answer "y" (default) to module wizard question "Do you want to add an admin page link (y/n)".

c)

Creation of Demo Module with a service/dao layers:

  • Creates a module with a Service, ServiceImpl, DAO, HibernateDAO, POJO, Hibernate mapping, liquibase.xml and sqldiff.xml.

  • To create a module with service/dao files you need to answer "y" (default) to module wizard question "Do you want to add a service layer" and specify service and pojo names

Headless install (no prompts) 

User can directly create modules skipping the prompts by making the interactive mode parameter false.

To change a default-value of a parameter, pass the parameter expression concatenating with -D with a value.

Parameter Description

ParameterExpression

Default Value

Group Id

groupId

org.openmrs.module

Artifact Id

artifactId

basicexample

Package

(set internally)

groupId.artifactId

Version

version

1.0-SNAPSHOT

Module name

moduleName

Basic Example

Module name with no spaces

(set internally)

moduleName_ns

Module description

moduleDescription

Helps to start writing OpenMRS modules

Module author

user.name

(system-user-name)

OpenMRS version to depended on

openmrsVerison

1.8.2

Do you want to add an admin page link (y/n)

adminLinkReply

y

Do you want to add a service layer (y/n)

serviceReply

y

Service name

serviceDaoName

moduleName_nsService

Object name

objectName

moduleName_ns

Do you want to add another module to depend on (y/n)

dependentModules

n

Note:

  • The module name is appended with " Module" .
    Module name = moduleName + " Module"

  • Dependent modules should be passed as a comma-separated list of moduleID:version i.e.:
    <Module 1 Id>:<Module 1 Version>,<Module 2 Id>:<Module 2 Version>,...

    Assumptions:
    -groupId=org.openmrs.module
    -artifactid=<given-module-id>-api

Example:
Creating a Demo module with a link in admin page and a dependent module with out any prompts.

Importing module to your IDE

In Eclipse, import the created module by selecting File -> Import -> Existing Maven Projects. You will observe a parent project (name=artifactId) and two child projects, api (name=artifactId-api) and omod (name=artifactId-omod).