Automatic Using the Maven Archetype
Info |
---|
The easiest way to create a module is to Use the Module Maven Archetype. |
...
It will create the project skeleton and a pom.xml file with all the dependencies for OpenMRS |
...
APIs and |
...
modules. |
...
Video Guide |
...
from OpenMRS University |
Manual Step by Step Instructions
There is really no reason to do anything other than use the maven archetype (see above), but if you want to create the module structure manually:
- Check out a local copy of the basicmodule using Maven (view source or view source in svn)
- (assumes you have m2eclipse installed in maven. see Using the M2Eclipse Maven Plugin In Eclipse
- Right click on openmrs-modules/basicmodule/trunk openmrs svn repo, choose Check out as Maven Project
- Under advanced, uncheck 'separate projects for modules'
- Next to 'name template': enter your project/folder name. e.g. MyModuleX
- Click finish
- Disconnect the project from the database (you won't be checking your changes back in as the "BasicModule")
- Using Subclipse: right-click on the project name, select "Team->Disconnect..."
- "Confirm Disconnect from SVN" wizard appears
- select the "Also delete the SVN meta..." radio button
- click "Yes" button
- Replace all references to the Basic Module with your new modules name, using the same Conventions. (For example, rename BasicModule to MyFirstModule).
- edit omod/src/main/resources/config.xml
- find the "<id>" tag, edit the value (example: change "<id>basicmodule</id>" to " <id>myfirst</id>")
- find the <name> tag, edit the value (example: change "<name>Basic Module</name>" to "<name>My First Module</name>")
- find the <author> tag, change the value from Ben Wolfe to your name ... Ben shouldn't get all the credit
- find the <description> tag, edit the value if you want,
- you can change the <version> value, following the Versioning conventions
- find the <activator> tag, change the activator name. Must be a class in your module. Case sensitive!
- edit omod/src/main/resources/moduleApplicationContext.xml
- This file is really only needed if you want either 1) your module to provide jsp files or 2) your module to have its own ___Service.java class
- edit omod/src/main/resources/liquibase.xml
- This is only needed if you are adding your own tables to the openmrs data model (or modifying others)
- rename the packages
- expand api/src/main/java
- right-click on org.openmrs.module.basicmodule "Refactor->Rename..."
- the "Rename Package" wizard appears
- edit the name (example: change to "org.openmrs.module.myfirst")
- select all of the check boxes (Put a * in the "File name patterns" text field)
- click "Preview"
- (wait patiently)
- click "OK" on the final screen of the wizard
- repeat the previous for omod/src/main/java and omod/src/test/java
- Be certain to rename all files that have BasicModule (or basicmodule) in their name (for example basicmoduleForm.jsp under web/module). Also look in the contents of the files (e.g. AdminList.java and build.xml)
- Change the contents of omod/src/main/resources/messages_*.properties
- Build your module using maven. "mvn package" at command line or "right click on project, run as --> maven package"
- edit omod/src/main/resources/config.xml
- Try out your module
- Go to your openmrs installation Administration-->Manage Modules
- Choose Upload and browse to the "omod/target" folder in your checked out code. choose the latest.omod file
- Document your module
- Modules should have a home page that describes their purpose, features, instructions, known issues, etc.
- Feel free to create a wiki page for your module on this wiki. Your page should be called "FooBar Module" if you have created a module called FooBar.
- Create it as a child of the Active Projects page
- Publish the resulting .omod file
- Consider using the OpenMRS Module Repository app. Read more about it here: Module Repository
- Committing your code to the OpenMRS subversion repository
- See Requesting Subversion Repository Access to get a new SVN project created for you.
- After a new SVN project has been created for you, the easiest way is to:
- check out the new project that was created for you
- then copy and paste your unattached code into that project
- Then just commit that entire project
...