Friday, January 9, 2009

Releasing a New Version of an Existing Plugin

In this post I am going to cover releasing a second version of your plugin.  It is inevitable that you will need to make changes to your plugin after its first release.  I would recommend also reading part one, and part two of this series. Here are the steps you will need to follow to successfully update your plugin.

Step one: You need to obtain a working copy of your source from the plugin repository.  If you attempt to release a second version of your plugin with out performing this step you will get errors.
To check out your source run the following command.
svn co http://myrepository.mydomain.com/svn/repsitory/grails-/trunk my-plugin
Tip: if you are using grails 1.2  and you wish to manage your sources somewhere other than subversion you can add --ziponly flag to the grails release plugin command (grails release-plugin -repository=myRepository --zipOnly).  You are then free to manage your plugin source in what ever source control suits your needs.

Step two: Add any source files that are ignored by grails package-plugin.   When grails automatically released your plugin it ignored certain artifacts.  Some of these are useful when you are testing your plugin via grails run-app, this includes : Config.groovy, UrlMappings.groovy, and any files in your plugins exclude list.  It also did not check in your grails-app/conf/BuildConfig.groovy file which is essential to re-releasing your plugin.  You will need to create the conf directory mkdir grails-app/conf.  You will then need to re-create or copy the BuildConfig.groovy file as explained in part 2.

Tip: For testing purposes a  grails plugin can be run with run-app just like any other grails application.  That is why it is often useful to have files checked into your source tree that are not packaged as part of the plugin. 



Step 3: You will now need to make the required changes to your plugin.  Don't forget to update the plugin version in application.properties and more importantly in GrailsPlugin.groovy. You will need to do a subversion add for any new files you add to your plugin. 


Tip a great way to test your plugin and to speed up time in developing it is to use it as part of a real application.  In grails 1.1 and later this is easy.  You simply add the following to your BuildConfig.groovy file.
grails.plugin.location.="/full/path/to/directory/you/checkedout/in/step/one"
See Grails 1.1 release notes for more info
If you are lucky enough to be using Intelij 9 it will automatically add a new grails module for this plugin.


Step 4: Release your new plugin to the repository.  This step is the same as the first release you simply run
grails release-plugin -repository=
Grails will perform the following steps. 
  • check in all of your updates to the trunk,
  • tag the new version of your plugin
  • update the LATEST_RELEASE tag 
  • update and checkin a new .plugin-meta/plugins-list.xml file.  
That's it!! now you can advertise your new functionality to your co-workers.  They will be amazed and awed at your talent, and how much time you saved them by sharing your work as a plugin :)


Check out this upcoming book on developing grails plugins.