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
Go to a folder where you want to create a project (like your workspace folder)
Run the following maven plugin command
mvn module-wizard:generate
or
Follow the wizard questions
The wizard prompts with the following pattern: | |
If a question ends with "(y/n)" then an answer should be a letter 'y' (yes) or 'n' (no) (case insensitive). |
Valid OpenMRS versions to depend on can be found in our maven repository
Example output
 | Description | Example | File Structure |
---|---|---|---|
a) | Creation of basic Demo Module: Â Â Â
| ||
b) | Creation of Demo Module with a link in the admin page:Â Â Â Â
| ||
c) | Creation of Demo Module with a service/dao layers:
|
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).