Distributing Plugins in Grails Plugins Repository
The preferred way of plugin distributing is to publish it under Grails Plugins Repository. This will make your plugin visible to the
list-plugins command:
Which lists all plugins in the Grails Plugin repository and also the
plugin-info command:
grails plugin-info [plugin-name]
Which outputs more information based on the meta info entered into the plug-in descriptor.
If you have created a Grails plug-in and want it to be hosted in the central repository take a look at the wiki page , which details how to go about releasing your plugin in the repository.
When you have access to the Grails Plug-in repository to release your plugin you simply have to execute the
release-plugin command:
This will automatically commit changes to SVN, do some tagging and make your changes available via the
list-plugins command.
Configuring Additional Repositories
By default when you use the
list-plugins,
install-plugin and
release-plugin command they work against the central repository hosted at http://plugins.grails.org.
However, Grails supports the notion of multiple plugin repositories. To configure multiple repositories you can using the
grails-app/conf/BuildConfig.groovy
file:
grails.plugin.repos.discovery.myRepository="http://svn.codehaus.org/grails/trunk/grails-test-plugin-repo"
grails.plugin.repos.distribution.myRepository="https://svn.codehaus.org/grails/trunk/grails-test-plugin-repo"
Repositories are split into those used for discovery over HTTP and those used for distribution, typically over HTTPS. You can also provide these settings in the
USER_HOME/.grails/settings.groovy
file if you prefer to share the same settings across multiple projects.
Once this is done the
list-plugins,
install-plugin and
plugin-info commands will automatically resolve against the newly configured repository. If you want to list only the plugins from the repository you can use its alias to do so:
grails list-plugins -repository=myRepository
Additionally, if you want to distribute a plugin within the configured repository you can do so with the
release-plugin command:
grails release-plugin -repository=myRepository
Secured Plugin Repositories
By default when using a repository URL starting with the
https://
protocol, Grails will prompt you for a username and password. If you prefer
not to get these prompts then you can specify the username and password to use in your
~/.grails/settings.groovy
file as follows:
grails.plugin.repos.discovery.myRepo="https://user01:password01@myserver.com"
The format is:
PROTOCOL://USERNAME:PASSWORD@SERVER
With this set Grails will use the specified username and password rather than prompting you for one.
Configuring Repository Search Order
A common use case for having your own plugin repository is when you want to override or provide a modified version of an existing plugin within the central repository.
However, by default Grails will search repository in a preset order. The repositories it will search are as follows:
default
- The default repository found at http://plugins.grails.org
core
- The repository for plugins provides by the framework (such as the hibernate plugin)
If you add an additional repository then Grails will search the repository you have defined last, meaning it is not possible to override a plugin in the central repository unless you change the search order. To change the repository search order you can do the following:
grails.plugin.repos.resolveOrder=['myRepository','default','core']
In the above case the repository called
myRepository
will be searched before the default one. In addition, if you remove the built in repositories from the list you can prevent Grails from searching these repositories at all:
grails.plugin.repos.resolveOrder=['myRepository']
This is useful in a circumstance where you don't want Grails to perform any internet lookups when searching for plugins.