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:
Code Block |
---|
<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>
<archetypeVersion>1.0.0</archetypeVersion>
<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 :
...
...
...
if parameter includes (Y/N) then value should be letter 'y'(yes) or 'n'(no) , not case sensitive.
In case at left, the user has chosen 'n' (No).
Example output
...
...
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 admin page:
- It creates a module similar to basic module with extra adminList.java file to create a link in openmrs admin page under the parent tag of module name.
- To create a module with admin link
- you need to set module wizard question , " Do you want admin page link " value to 'y'.
- After the wizard question ,extra parameter gets prompted asking for the text of link which should appear in admin page (parameter : Link Name).
...
...
...
c)
...
Creation of Demo Module with a SpringMvc driven page:
- Creates a module with a controller which is mapped to a url , on redirecting returns model view of a jsp.
- controller mapped to path : module/<artifactId>/<artifactId>Link.form
- jsp page : <artifactId>Form.Jsp
- To create a module with spring driven page you need to set module wizard question "Do you want Spring driven Mvc page" value to 'y'.
- In example,
- controller mapped to path : module/demo/demoLink.form
- jsp page : demoForm.Jsp
...
...
...
d)
...
Creation of Demo Module with a service/serviceimpl/dao/hibernatedao:
- Creates a module with a service, serviceImpl , DAO ,HibernateDAO , pojo , hibernate mapping xml , liquiibase.xml and sqldiff.xml with related mappings.
- To create a module with service/dao files you need to set module wizard question "Do you want service/serviceimpl/dao/hibernatedao mapping " value to 'y'.
- It then prompt's for parameter.
-Service Name : Name for Service, Dao, Hibernate files.
-Object Name : Name for hbm.xml and its pojo.
...
...
Headless install (no prompts)
User can directly create modules skipping the prompts by making the interactive mode parameter false.
Code Block |
---|
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.
Code Block |
---|
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>,.....Code Block -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.
Code Block |
---|
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")
Note |
---|
this section needs more work |
Moved content to the Using the Module Maven Archetype page. Perhaps delete this one now?