Saturday, December 26, 2009

Grails - a decomposed application project

Hi there,

I've been looking around for ways to nicely decompose a large application (an Enterprise Application so to speak) using Grails. It turns out this platform has such a capability already build-in! Interested? Read on...

The basic building blocks of Grails are plugins. There's a plugin for everything: the ORM layer, IoC container, security, twitter access - you name it! So how is this going to help us decompose a large enterprise-grade application? Well, we're going to compose it from... plugins!

Here's a step-by-step instruction on how to create the main application along with one additional pluging. Other plugins can be added exactly the same way as the single one mentioned here.
  1. Create a grails application (we're going to name it "myapp" here) using standard Grails command grails create-app myapp
  2. Do not change the folder just yet to myapp - instead issue the following Grails command: grails create-plugin myapp-plugin
  3. cd to myapp
  4. Add the line plugins.myapp-plugin=0.1 to application.properties (that's in the main application, not in the plugin!)
  5. cd to grails-app/conf
  6. Add the following line to BuildConfig.groovy: grails.plugin.location.'myapp-plugin' = '../myapp-plugin'
  7. cd out of the application and into the myapp-plugin folder
  8. Issue grails package-plugin command to create plugin.xml
  9. cd back to your application and run it as usual using grails run-app
That's it! Whenever you make changes to your plugin they will be automatically picked up just as if they were a part of your main application which is the greatest feature ever!

Have fun!

No comments: