Thursday, October 13, 2011

Grails local plugin repository

If you are creating your own grails plugins, then you need to
1/ Store them on a central server
2/ Inform grails to check this server to find your plugins before going online to download them

There are 2 ways to do this (see

1/ Grails Compatible Repositories
This is easily achieved by creating (or updating if it already exists) the $HOME/.grails/settings.groovy file

e.g. to add myPluginRepository

The discovery, and distribution locations are svn repositories
grails.plugin.repos.resolveOrder=['myPluginRepository', 'default', 'core']
To publish
grails release-plugin -repository = myPluginRepository

2/ Maven Compatible Repositories (Recommended)
The maven-install command will install the Grails project or plugin artifact into your local Maven cache:
grails maven-install

In the case of plugins, the plugin zip file will be installed, whilst for application the application WAR file will be installed.

The maven-deploy command will deploy a Grails project or plugin into a remote Maven repository:
grails maven-deploy

It is assumed that you have specified the necessary configuration within a pom.xml or that you specify the id of the remote repository to deploy to:
grails maven-deploy --repository=myPluginRepository

The repository argument specifies the 'id' for the repository. You need to configure the details of the repository specified by this 'id' within your grails-app/conf/BuildConfig.groovy file or in your USER_HOMER/.grails/settings.groovy file:
grails.project.dependency.distribution = {
localRepository = "/path/to/my/local"
remoteRepository(id:"myPluginRepository", url:"http://myserver/path/to/repo")

The syntax for configuring remote repositories matches the syntax from the remoteRepository element in the Ant Maven tasks. For example the following XML:
<remoteRepository id="myPluginRepository" url="scp://localhost/www/repository">
<authentication username="..." privateKey="${user.home}/.ssh/id_dsa"/>

Can be expressed as:
remoteRepository(id:"myPluginRepository", url:"scp://localhost/www/repository") {
authentication username:"...", privateKey:"${userHome}/.ssh/id_dsa"

By default the plugin will try to detect the protocol to use from the URL of the repository (ie "http" from "http://.." etc.), however if you need to explicitly specify a different protocol you can do:
grails maven-deploy --repository=myPluginRepository --protocol=webdav

The available protocols are:

* http
* scp
* scpexe
* ftp
* webdav

No comments: