(Quick Reference)

4 Publishing Grails plugins - Reference Documentation

Authors: Peter Ledbrook

Version: 3.0.0

4 Publishing Grails plugins

If you want to make your Grails plugins available to other people, then the best approach is to publish them using this plugin. The publication process is straightforward:
  1. Package the plugin as a zip or jar
  2. Deploy it to a Maven or Subversion repository
  3. Optionally notify a plugin portal of the release

The publish-plugin command does all of this for you. It can also integrate with a source control management (SCM) provider if a corresponding plugin is installed, ensuring that all your changes are committed and tagged before the plugin is published. You'll find more information about this later.

4.1 Publishing to Grails Central Plugin Repository

The most common use case for the publish-plugin command is to publish a public plugin so that it is available to all Grails users; well, to those that have an internet connection at least. Because of this, the command's default configuration is geared towards the Grails Central Plugin Repository. As long as you have a Grails.org account, simply installing the Release plugin and executing

grails publish-plugin

will do everything necessary to publish the plugin and announce its release. Note however you require prior permission granted in order to publish a particular plugin. See the details on requesting permission to publish a plugin for more information.

During the publishing process you may be asked for your grails.org usernames and passwords, but otherwise that's it. Your plugin will be deployed to the Grails Central Plugin Repository, its plugin portal page on grails.org will be updated, and the release will be announced on various channels such as Twitter (user @grailsplugins).

It's a pain to enter your username and password every time you publish a plugin, so you can set these for the Grails Central Plugin Repository in ~/.grails/settings.groovy:

grails.project.repos.grailsCentral.username = "me"
grails.project.repos.grailsCentral.password = "s0longf!shthanks"

The above values will be used whenever you publish to the Grails Central Plugin Repository and grails.org.

4.2 Custom repositories and plugin portals

Not all plugins should be publicly available: some are too specific to certain projects while others are confidential. Still, teams can gain big advantages from deploying such plugins to their own private repositories. Because of that, the Release plugin can of course publish plugins to any target repository and even notify private plugin portals.

Repository types and configuration

Grails supports two types of plugin repository: the traditional Subversion-based one and Maven-compatible. The public plugin repository is currently an example of the former. All you need to do is set up a standard Subversion repository and the Release plugin will do the rest.

Maven-compatible ones can be easily set up with either Artifactory or Nexus. Subversion-based repositories are useful for older versions of Grails, but if you only use Grails 1.3 or above, we recommend you use a Maven-compatible repository for your plugins.

Whichever type of repository you go for, the configuration settings are mostly the same. The key options are the repository URL and the username and password for deploying to the repository. All of these can be configured in either ~/.grails/settings.groovy or BuildConfig.groovy. Typically, a single repository hosts many plugins, so it's usually a good idea to put the configuration in settings.groovy and then specify in grails-app/conf/BuildConfig.groovy which repository a plugin should be published to by default:

grails.project.repos.default = "companyRepo"

or

grails.project.repos.default = "grailsCentral"

for example. This saves you from having to use the --repository command line argument every time you publish a plugin, although you can still use it to override the default. For example, you may have a local Maven-compatible repository you want to test deployment to, so you could configure it in settings.groovy and then run:

grails publish-plugin --repository=localReleases

One last thing: the Release plugin handles the differences between publishing to Subversion and Maven-compatible repositories, but you still need to let it know what type you're using. By default it assumes a Maven-compatible repository, but you can declare as repository as a Subversion one through its type configuration option. Just set it to "svn".

Your own plugin portal

How would you like your own plugin portal for your private plugins? You'll be able to see what plugins are available, tag them and do searches. The public plugin portal at grails.org is part of that web site, but it's also an open source project on GitHub. There are also plans to extract the plugin portal so that it can be used independently of the grails.org web site.

Currently, your best option if you want your own portal is to grab a copy of the grails.org source code and run your own version locally. It's a Grails application, so it's not hard to get it started. Once it's up and running, it provides a REST API that the Release plugin can use for plugin release notifications. The portal updates the information for the given plugin and then announces the release in various ways. You'll probably want to disable the announcements, which you can do by modifying the PluginUpdateService.announceRelease() method.

Configuring the Release plugin to notify your own portal is straightforward and described in the configuration section. Remember, you can specify a default portal for each project and you can also override that default via the --portal command line argument.