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.
- Create a grails application (we're going to name it "myapp" here) using standard Grails command grails create-app myapp
- Do not change the folder just yet to myapp - instead issue the following Grails command: grails create-plugin myapp-plugin
- cd to myapp
- Add the line plugins.myapp-plugin=0.1 to application.properties (that's in the main application, not in the plugin!)
- cd to grails-app/conf
- Add the following line to BuildConfig.groovy: grails.plugin.location.'myapp-plugin' = '../myapp-plugin'
- cd out of the application and into the myapp-plugin folder
- Issue grails package-plugin command to create plugin.xml
- cd back to your application and run it as usual using grails run-app