Fork me on GitHub

Groovy Metaprogramming Koans

Groovy Version 1.7.10, 1.8.1
Author Marcin Gryszko (OSOCO)


Metaprogramming, according to Wikipedia is the writing of computer programs that write or manipulate other programs (or themselves) as their data, or that do part of the work at compile time that would otherwise be done at runtime.

Groovy dynamic nature plus the built-in implementation of the Metaobject Protocol make easy to add new behaviour or data at runtime.

The Metakoans will teach you:

The Koans assume that you have some basic practical experience with Groovy. If not, I recommend you personally Programming Groovy by Venkat Subramaniam. Although it covers Groovy 1.5.4, you find on 300 pages everything about Groovy from first steps with the language to advanced metaprogramming.


  1. Download and install Groovy (see above for supported versions). If you are on Windows and use installer, don't forget to mark Gant in modules selections. Check your installation with:
    groovy -version
  2. If you are on Linux/MacOSX install Gant. Make sure you pick up a release that corresponds to the Groovy version (if not, strange things will happen). Check your installation with:
    gant -version
  3. Clone the Metakoans GitHub repository or download the koans as zip/tar archive (as explained below).
  4. The downloaded sources contain already solved metakoans (don't look into koans directory!) that student metakoans are generated from. To generate your working copy (assuming your are in the proto-metakoans directory), type:
    gant -f generate_koans_to_solve.gant
    The student koans are generated in the ../groovy-metakoans-to-solve

Working with Metakoans

Go to groovy-metakoans-to-solve directory:
cd ../groovy-metakoans-to-solve
and type to start your way to meta-enlightment:
The metakoans are divided into thematic area, one per file. The execution will fail at the first place where you need to provide your answer (FAILED message). These places are marked with __ (double underscore) or FillMeIn*. Think, meditare, reflect, read, talk to your Groovy buddies and fix the test. If you complete the koan successfully, you get an OK message and the next koan will fail. Continue until you reach the enlightment...

Download Source

You can download this project in either zip or tar formats.

You can also clone the project with Git by running:

git clone git://


Found an issue? You liked the Metakoans? Drop me a line to or @mgryszko


Groovy Metakoans are released under a Creative Commons, Attribution-NonCommercial-ShareAlike License