Tuesday, February 15, 2005

Writting IDEA plugins

(imported from http://blogs.codehaus.org/people/avasseur, read comments there)

Today Jonas and I shipped Backport175, a back port of the JSR-175, the Java 5 Annotations spec.

This project comes with an Eclipse plugin and an IDEA plugin, so its time to say something about IDEA...

I just like the architecture of the IDEA plugins. There is very few docs on the topic, some very bad javadoc, and some samples around but no books yet etc.
Anyway, you can find some help on the IDEA forums, and guys like the Groovy ones have written plugins as well, so you can find a bunch of code around.

The nice thing in IDEA plugins is that it s just code, a rather clear API, and a bit of IOC (IDEA is using PicoContainer). A plugin as just one XML descriptor.
For an Eclipse plugin, you need a lot of XML, find what are the extension point, and dig in the docs and books, and get familiar with the Eclipse plugin wizardry. The game is very different, while for IDEA, it s just an API that you have to get familiar with.

What is missing the most in IDEA v4 is a good plugin project wizard, but if you have the chance to give a try to IDEA IRIDA, the EAP of the upcoming v5, then you have it, and it's as easy to debug your plugin as it is for a regular app.
The great thing with IDEA is that you can write a very small Ant script to build the plugin. I would not even try to go there for Eclipse (perhaps I am wrong ...).

You can probably learn some in that space by comparing both Backport175 plugins. It will leads you thru
- how to have a menu of your own to add / remove the feature to a given project (nature / actions and menu)
- how to hook in in the build system (builder / compilation listener)
- how to deal with markers

Off course, it is probably not the correct design neither for Eclipse nor for IDEA (I am far from beeing efficient in that plugin area) but it seems to do the job.

IDEA plugin CVS
Eclipse plugin CVS

Thanks to JetBrains to allow free use of IDEA for OSS projects !