Update: I had a couple of simple mistakes in my presentation, which are now corrected.
I gave a talk at AJUG-QLD last night, on using XDoclet for code generation. Went down pretty well, I think, though that could be just my flattered ego talking.
One of the focus points of my talk was on extending XDoclet and writing your own modules. To this end, I pulled out some code I’d developed about 18 months ago, which was a small and simple plugin designed to create JUnit test suites by annotating your test cases.
Anyway, on to the point of this entry: I read with interest Cedric’s post about a similar tool called SGen. For those of you who don’t know, the XDoclet development sort of went into a big hole called “XDoclet 2”, very little of which has seen the light of day yet. In addition, XDoclet 1.2 is not the easiest tool to extend. This motivated Cedric (who works for BEA, who have hyped XDoclet on their dev2dev site) to want to write his own XDoclet replacement: SGen. Now, it’s still very early days for SGen, but it has a big advantage over XDoclet 2 in that it’s actually got code I could download and play with.
So, for the purposes of this talk, of course, I wrote a similar module for SGen. And I thought I’d comment on my opinions gathered from this exercise:
- Over all, very nice, even though it’s early days. What I got developed was a module that at least detected the “junit:test” tags and spat out the names, grouped by testsuites. From there, it would be a relatively small leap to create a template (at least, it would be once the quirks of integrating a templating language, like Velocity, into SGen). This took me all of an hour, vs about 2 days for the XDoclet version.
- The code was very nice and simple, at least compared to the morass that was the XDoclet template. Not sure I like the Hungarian style names for interfaces that SGen (and the underlying tool, JAM) use, though.
- I had some distinct quirks getting the code to run, however. The instructions are rather limited at the moment, and there isn’t any Ant integration (yet). Still, it’s only a 0.1 release; I’m sure the rest will come.
- I had a quirk where I couldn’t get the “suitegen” tool to recognise annotations in a file I typed by hand, but could in a different file. Not sure what was going on there, but then I didn’t spend much time on it either.
Overall impression? I quite liked it as a “proof-of-concept” toy, but it’s not a real tool yet (and nor does it pretend to be). The architecture is nice and simple to extend, however, and certainly seemed easier to write than XDoclet templates. A telling point is that the architecture of SGen is apparently very similar to XDoclet 2 (via parallel evolution), but of course, XDoclet 2 doesn’t have a release out yet.
The real strength of XDoclet, however, is the very rich suite of modules. Any “XDoclet Killer” needs to be able to offer a similarly rich story. The XDoclet 2 guys, of course, have the opportunity to carry the existing community over, except they’ve basically lost that by letting that community hang out to dry for the last year. SGen at least will have one big backer in the form of BEA (presumably), but it may not get the wider appeal that XDoclet 1.2 has.
Oh, and if anyone really wants to see the presentation and sample code, look here it’s a 153KB download.