Friday, June 20, 2008

RHQ - tip of the day: Use the skeleton generator to generate plugin skeletons

I wrote in length about writing plugins for RHQ - of course there is still more to know about.

That is why we created the plugin community.

One cool new feature since writing the blog series is the new plugin skeleton generator, that Jason Dobies wrote. While the name of (the generator, not of Jay :-) is a little complicated ("RHQ Plugin Archetype") you don't need to be afraid :)
It is just a maven command that will create all you need.

To use the archetype you first need to download it as indicated on its wiki page.

Then you call it as follows (I am using multiple lines here, but on the shell you need to give that in one line).


$ cd $RHQ/modules/plugins
$ mvn archetype:create -DarchetypeGroupId=org.rhq \
-DarchetypeArtifactId=rhq-plugin-archetype \
-Drhq-plugin-name=test \
-DarchetypeVersion=1.0.0.GA \
-DartifactId=rhq-test-plugin \
-Dversion=1.0.1-SNAPSHOT \
-Dpackage=org.rhq.plugins.test \


This will emit a lot of stuff ending in:

[INFO] Archetype created in dir: /jon/jonHEAD/rhq/modules/plugins/rhq-test-plugin


Note that the version in the -Dversion attribute above must correspond to the version of RHQ that you are using to build the plugin. Otherwise compiling of the plugin will fail.
All options are described on the wiki page. Basically you need two things: artifactId, the name of your plugin, and package, the java package of it.

One caveat: currently (as of 6/20) it is only generating the base directory structure and plugin descriptor, but no Java files. But I am very sure, Jason will fix that soon. And hey, this is open source and the source code is available from svn.

Have fun -- and join us on irc://irc.freenode.net/ in channel #rhq.




Technorati Tags:
, ,


No comments: