Monday, December 21, 2009

Grails Plugins With In-House Repository Part 1 (Introduction).

In this series of posts I am going to cover how to use grails to create and use a plugins to develop your application.  

Grails plugin system is one of the most powerful features of the framework. If you have been using grails for any length of time you have probably started using some of the rich plugins available in the grails plugin repository.   Grails plugins go much further than just adding third party libraries. They  allow for true modular application development, by letting you create a plugin for each feature area in your application.  Each of these plugins can contain views, controllers, library dependencies, and domain classes. They can interact with the spring application context, participate in generating the web-xml, and even add dynamic methods to grails artifacts.  As with most things in grails it is easy to create and use plugins, and the payoff is tremendous.  Every time you add new features to your application you should be thinking, "can I make this a plugin?"

If you are not already familiar with developing plugins you should start by reading this tutorial by Scott Davis, and reading the section on Plugins in the Grails Framework Documentation.

You now have a choice of sharing your plugin with the world by publishing it to grails central repository, or publishing to a private in-house repository. If you want to publish to central repository see this article.

In many cases it makes sense to set up a private repository to manage your plugins.   You may wish to over-ride some of the plugins hosted in the central repository, or you may be developing proprietary / closed source plugins for use in your organization.  Grails allows you to manage your plugins using a subversion repository.  This repository is used to manage both the source for your plugin, and the distributable .zip file.  (Note in grails 1.2 it will be possible to manage the source in a different repository).  The grails release-plugin command will take care of creating the correct directory structure in your repository, committing source files, and tagging each release.


You will want to get started by creating a new subversion repository to host your plugins.  You will also need to set up your subversion repository for access via http.(Grails assumes http/https as the protocol you can't use svn:// urls).  You probably also want to consider restricting access to your plugin repository by setting up authentication.

That is all for today's post.  In the next post I will cover how to set up your plugin to publish to this repository, and how to use plugins from this repository in your applications.