This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
All of Roo is an add-on. For example, the tree of projects in Roo's source code are all of the add-ons that make up the base Roo commands:
I highly encourage everyone to download the source from GitHub:
either do a git clone https://github.com/SpringSource/spring-roo.git or download the zip. Then open up some of the addon-* folders and plunk around. It's really a neat way to build a tool, but basically add-ons can be triggered two ways at least:
1) react to changes in files / events
2) execute commands issued in the Roo shell
To expose shell commands, your add-on will have a Commands class that extends CommandMarker. Each command you expose is annotated with @CliCommand - then you can set parameters, etc.
Roo add-ons are just OSGi Java code, and generally you'll do one of several things:
1. add/update/remove an .aj file (AspectJ ITD)
2. generate Java source files (but not update once generated, that's a basic rule)
3. manipulate configuration files
4. manipulate the build (pom.xml) file
So, think of Roo like a really smart project configurator that is completely pluggable and customizable, and that comes with a base set of configuration to build Spring applications. You can extend it to do anything you want.
I have four add-ons I'm building now over at http://www.rimple.com/silly-weasel-forge/ as a way to teach others to write add-ons. I'm not perfect at it yet, and have run into some interesting problems, which I've documented on the blog at rimple.com. The book has two chapters to get you started as well. They are:
- jqueryui addon (installs jQuery and jQuery UI and inserts them in load-scripts.jspx).
- site addon - configures maven's site reporting. Eventually I'll parameterize the reports and configuration
- coffeescript addon - configures a Maven coffeescript compiler that gets executed during the compile phase
- spock add-on - my favorite at the moment - lets you write Groovy Spock BDD tests against your Roo application - I'm using it to write tests against add-ons, since they aren't Spring code but OSGi Java code and need a simple test mechanism.