Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: link for the code. From SVN to GIT

...

I am going to demonstrate how I use Maven in Intellij IDEA. You are welcome to edit this page if you find anything that's useful or beneficial to developers.

Panel
 

Requirement:

Panel
  1. # Intellij IDEA 9 with Maven plugins enabled. It is enabled by default.

...

  1. Apache Maven 2.2.1. Download maven from maven.apache.org and follow the installation instruction.
Panel
 

Checkout Source and Create Project:

Panel
  1. # check out maven branch from http://svn.openmrs.org/openmrs/trunk.  From the toolbar, select VCS > Checkout from Version Control > Subversion.
  2. This is no longer available since we have switched our code base from SVN to GIT.Try this link https://github.com/openmrs/openmrs-core.git .

  1. When checkout is done, it will ask you to create a new project. Say "yes".
  2. Select "Import project from external model".
  3. Select "Maven" as external model.
  4. "Root directory" is selected by default, Click "Next".
  5. Click Next to import Maven project.
  6. Click Next if you don't want to change Project Name and Location.
  7. Finish importing maven project, IDEA will load the project.
Panel
 

Develop with Maven

There are three modules defined in maven project, openmrs-api,openmrs-web and openmrs-webapp. OpenMrs is a parent project. When we run any maven goal on parent project, it will run the same goal on its children according to the dependency order. Common maven goals are shown under Lifecycle node. There are also goals provided by maven plugins which are shown under Plugins node.

Panel
 

How to run Junit

If you want to run all tests across modules, click test under Lifecycle node in Openmrs project.

...

You can also create IDEA run configuration to run junit tests. For example to create a run configuration that runs all junit tests across modules, you can click menu "Run -> Edit Configuration", click + and pick junit, type name "All Tests", select "All in package", select search for tests "In whole project", select "openmrs:test-compile" in before launch section and save. The pro of this is that it uses native IDE test view, and you can navigate to the line where error happens.

Panel
 

How to Run Web Application

...

Current configuration of Jetty is that it will reload static resources like jsp, javascript files etc. If there is any java class change, It will require to run maven:compile goal and restart Jetty.

Panel
 

How to Debug Web Application

Jetty plugin can pick up any changes of static resources, so changes of jsp, property or css files don't require a restart. However changes of java class will have to restart. The following solutions could help in some situations.

Panel
 
JVM Hotswap

If you only change things in a method, you can use JVM Hotswap. In IDEA, you click "Build -> Compile.." which will compile only the class you modify and IDEA will provide hotswap dialog. Currently IDEA doesn't support hotswap if you use maven to compile.

Panel
 
Hot Deploy

There is memory leak when hot deploying web application. But if you increase JVM permgen, you can still do it.

Panel
 
Use JRebel

Check this http://www.zeroturnaround.com/jrebel/comparison, You can see Jrebel can do a lot more than JVM Hotswap does. Here is how you configure JRebel to work with OpenMRS

...