the corner office

a blog, by Colin Pretorius

Eclipse dependencies

Between the moving and packing/unpacking, I've managed to squeeze in a very wee bit of Eclipse tinkering. As I mentioned before, I saw two things to get my head around: SWT/JFace development, and the Way of the Plugin. I figured I'd be as dumb as possible about plugins to start off with, and focus on putting together GUIs.

That wasn't so easy. I could have sidestepped the plugin/RCP thing completely and just fired up some windows from a main() method. I didn't want to do that, but I was wrong in thinking that you don't need to give thought to plugin management from the get-go.

The first problem I ran into was trying to use my tco.util projects as dependencies like I normally do for standalone and web apps. No go. You can refer to another project at compile time, but not at run time. I read a forum post explaining that I'd need to turn my depended-upon projects into plugin projects of their own, and then specify the dependencies in my plugin.xml.

Not happy with that idea... much like my gripes about Eclipse WTP wanting to stomp over utility projects, I don't want to have to plugin-ify utility projects which aren't going to be used only in a plugin environment. The alternative is to roll the util projects into separate jar files. You then have two choices: you can either include the jar file directly into your plugin, in the usual lib/ directory style, or else you can create a separate plugin which uses the jar file.

If you include the jar file in a lib directory, then presumably it loads within the plugin's own classloader. You need to explicitly add the jar file to the classpath entry on the plugin.xml's 'Runtime' tab. Unfortunately, you can only specify locations within the current project directory.

Alternatively, if you want to use the jar as a separate plugin, then Eclipse has a tool which allows you to create a plugin project from a jar file.

Either way is a pain, because rolling these jar files is a chore. It is possible to hook in custom Ant scripts which do it automatically when code changes, but that's not my idea of pretty, and it's frustrating when I just want to crank out something easy to play around with.

I understand why plugins needs to so rigidly separate: that's the whole point of the design, but for development and testing it would be nice to have a third way: specify a POJO-esque project as a dependency on a project's build path, as normal, and allow the IDE to either virtually or physically include the depended-upon project's class files and exported jar files in the current project's class path.

{2007.04.25 21:58}

« Packing and moving

» More RCPing