Grails Github Gist Plugin

What is a GitHub Gist?

GitHub has this handy code snippet sharing system called Gists that make it easy to display and share formatted code with syntax highlighting. You can easily embed Gists into other sites such as a Wordpress blog with a simple JavaScript script tag.

Plugin Description

This plugin allows you to create and update GitHub Gists from sections of a Grails project so you can use compiled and tested code snippets written from the comfort of your IDE in blog articles, etc. And when you update the code in your Grails project you can easily update the corresponding Gists to keep them up-to-date.

The plugin uses the GitHub Java API to create and update the Gists.


Add the plugin definition in BuildConfig.groovy:

compile ":github-gist:0.2"


Mark the sections of code you want to upload to create a Gist with starting and ending <gist></gist> XML tags, usually in comments. And type of comment doesn’t matter (block /* */ vs. line //).

// <gist>
void myGistMethod() {
  // Magic happens here
// </gist>

Then run 'grails process-gists', enter your GitHub username and password, and voila! the Gists are created. And the <gist> XML tags are updated with the ID of the newly created Gists, which you’ll probably need to share the Gists.

> grails process-gists
GitHub username: myusername
GitHub password: **********

And when you later want to update your Gists, run the same command 'grails process-gists'.

Optional config parameters

If you do want to type in your GitHub username and password (or if you want to create/update Gists in an automated build), you can specify your GitHub credentials in Config.groovy parameters:


Public/Private Gists

By default, the Gists created are public (for easy sharing on blogs, etc.), but if you so desire you can mark Gists as private by:

// <gist public="false">
// </gist>

Plugin Code

The plugin code is on Github at