Setup for using module wizard plugin in command line.
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 in your settings.xml
File Location-
- Linux: ~/.m2
- Windows: C:\Documents and Settings\USER\.m2
- Vista/Windows7: C:\Users\USER\.m2
If the settings.xml file does not exist create the file
Settings.xml file should look similarly as below:
<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/service/local/repositories/releases/content/archetype-catalog.xml</archetypeCatalog> </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 the wizard archetype at command line
- Go to a folder where you want to create project (like your workspace folder)
- Run maven plugin command - " mvn module-wizard:generate"
- Follow the wizard prompts
How to use the maven archetype command line
When wizard prompts :
|
groupId: org.openmrs.module: : <input by user> |
|
if parameter includes (Y/N) then value should be letter 'y'(yes) or 'n'(no) , not case sensitive. |
Example output
|
Description |
Example |
File Structure |
---|---|---|---|
a) |
Creation of basic Demo Module:
|
|
|
b) |
Creation of Demo Module with a link in admin page:
|
|
|
c) |
Creation of Demo Module with a SpringMvc driven page:
|
|
|
d) |
Creation of Demo Module with a service/serviceimpl/dao/hibernatedao:
|
|
|
Headless install (no prompts)
User can directly create modules skipping the prompts by making the interactive mode parameter false.
Command: mvn module-wizard:generate -DinteractiveMode=false
To change a default-value of a parameter, pass the parameter expression concatenating with -D with a value.
Command: mvn module-wizard:generate -D<parameterExpression>=<value>
Parameter |
ParameterExpression |
Default Value |
Group Id |
groupId= |
org.openmrs.module |
Artifact Id |
artifactId= |
whirlygig |
Version |
version= |
1.0-SNAPSHOT |
Module Name |
moduleName= |
Whirlygig |
Module Description |
moduleDescription= |
Allows user to generate and save whirlygigs. |
Module Author |
moduleAuthor= |
<user-name> |
OpenMRS Version Depended on |
openmrsVerison= |
1.8.2 |
Do you want admin page link : (Y/N) |
adminLinkReply= |
n |
Link Name |
adminPageLink= |
Manage Whirlygigs |
Do you want Spring driven Mvc page : (Y/N) |
springMvcReply= |
n |
Do you want service/serviceimpl/dao/hibernatedao mapping : (Y/N) |
serviceReply= |
n |
Service Name |
serviceDaoName= |
Whirlygig |
Object Name |
objectName= |
Whirlygig |
Does this module depend on another module: (Y/N) |
dependentModules= |
null |
Note:
- For passing value for dependent modules list it should follow a case-
<Module 1 Id>:<Module 1 Version>,<Module 2 Id >:<Module 2 Version>,<Module 3 Id>:<Module 3 Version>,.....-DdependentModules=ReportModule:1.0.0,CohortModule:1.0.5,
Example:
Creating a Demo module with a link in admin page and a dependent module with out any prompts.
mvn module-wizard:generate -DinteractiveMode=false -DartifactId=demo -DmoduleName=Demo -DmoduleDescription="A sample module for demo." -DopenmrsVerison=1.8.0 -DadminLinkReply=y -DadminPageLink="Manage Demo Pages" -DdependentModules=Cohort:1.0.2,
Using the wizard archetype in your IDE
Import the created module as "Existing Maven Projects" , you will observe a parent project (name=artifactId) and two child projects, api (name=artifactId-api) and omod (name=artifactId-omod).
If the project gives error try enabling maven dependency management or Update Project Configuration. (Right Click on project->Maven->"Enable Dependency Management" or "Update Project Configuration")
this section needs more work