The Groovy Koans project is a collection of small exercises in the form of unit tests, designed to get Java developers up to speed on Groovy features and common idioms. It starts by teaching you basic Groovy building blocks, and gradually builds your knowledge towards metaprogramming, slurpers, and all the goodness Groovy has to offer.
- Make sure you have JDK 1.6+ installed
- Download and unzip the Koans (or clone the GitHub repository with
$ git clone https://github.com/nadavc/groovykoans.git
) - Remove the solutions from the Koans using
$ ./gradlew removeSolutions
- Execute Koan01 with
$ ./gradlew koan01
and fail (or any other Koan using$ ./gradlew koan##
) - Fix code, and execute again
- Keep going until you're fluent at Groovy :)
- Download and install IntelliJ IDEA Community Edition
- In IDEA,
File -> Open Project
and open thebuild.gradle
file
- Execute
./gradlew eclipse
- Download and install Eclipise IDE for Java Developers
- In Eclipse,
File -> Import...
,Existing Projects into Workspace
, and select the project directory
The gradlew
script downloads Groovy and Gradle for you, so you don't have to set up anything by yourself.
To allow gradlew to work through your proxy, simply add the following parameters:
$ ./gradlew koan01 -Dhttp.proxyHost=[http proxy] -Dhttp.proxyPort=[http proxy port]
One of the perks of learning through Koans is that once your Koan is solved, you can compare your solution with the 'official' solution and perhaps learn from that comparison as well. It is also a way to make sure that the Koans are indeed solvable by filling in the blanks.
For optimal learning experience, however, you should first try to solve the Koans without those solutions as reference.
To remove the solutions, run $ ./gradlew removeSolutions
from the root of your unzipped Koans.
These are the Koans that are currently planned:
- Embedding Groovy
- Creating your own DSL
- Creating your own builder
- Transformations
- GPars
Follow me on Twitter or GitHub for updates.
The Koan concept started way back in Zen practice. It was then adapted by the good folks of rubykoans.com and perfected by Neo4j. The Groovy Koans project is licensed under the WTFPL.
Please feel free to leave comments and pull requests :)
Enjoy!