Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 17 Next »

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

  1. Go to a folder where you want the project created (like your workspace folder)
  2. Run maven plugin command - " mvn module-wizard:generate"
  3. Follow the wizard prompts

How to use the maven archetype command line

When wizard prompts :


groupId: org.openmrs.module: : <input by user>
question: default value: <input by user>
The question is "groupId"
The default value is "org.openmrs.module" (if user doesn't input anything)


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 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.




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

 

  • No labels