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> <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 the project created (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:
|
|
|
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
Command Line Passing Parameter's
To change a default-value of a parameter, pass the parameter expression concatenating with -D with a value.
Syntax: mvn module-wizard:generate -D<parameterExpression>=<value>
Parameter |
ParameterExpression |
Group Id |
-DgroupId= |
Artifact Id |
-DartifactId= |
Version |
-Dversion= |
Module Name |
-DmoduleName= |
Module Description |
-DmoduleDescription= |
Module Author |
-DmoduleAuthor= |
OpenMRS Version Depended on |
-DopenmrsVerison= |
Example:command-
mvn module-wizard:generate -DartifactId=demo -Dversion=2.0-SNAPSHOT -DmoduleName="Demo" -DmoduleDescription="A sample module for Demo." -DopenmrsVersion=1.8.0
Now the user can jump to module questions by pressing enter to the questions and accept the provided default answer. This is useful for a large organization who often wants to create modules with same groupId, author, etc.
TODO: add a parameter that answers YES to all default prompts so that this can be truly headless