Eclipse Papercut #5 – Getting external libraries as bundles

In this episode of Eclipse Papercuts I explain how you get bundles for popolar Java libraries for your Eclipse plugin development.

I believe it has advantages to work with plugin projects instead of pure Java projects even if the plan is not to create Eclipse plugins / RCP applications.

The core strength of OSGi for this scenario is in my opinion the encapsalation and protection of your inner classes. With OSGi bundles you decide which packages of your project are exported and therefore visible to other projects (via the tab Runtime in the editor for the file plugin.xml).

This leaves only one problem: If you are using externally libraries you have to convert them into bundles / plugins.

I would be nicer to consume pre-packages bundles. As I created a bug iText should be OSGi and tweeted about it Chris Aniszczyk pointed me to Eclipse Orbit.

Eclipse Orbit provides lots of standard libraries already pre-packaged as bundles / plugins.

Lets see how you could get the iText version from Orbit. Check the Orbit FAQ to find out more.

You need to connect via cvs to the Eclipse cvs repository. CVS URL is :pserver:anonymous@dev.eclipse.org/cvsroot/tools

Navigate to “org.eclipse.orbit”. Select “com.lowagie.text” and check it out.

orbit10

Orbit keeps the different version of the library as cvs branches. Select your project and select Replace With -> Another Branch or Version…
orbit20

orbit30

After selecting the branch and pressing ok the system will download the library and you can start using the library.

In addition to Orbit you can also use the Springsource bundle repository. On this website you can search for bundles and download then directly. You can then import them as plugin projects into your workspace.

About Lars Vogel

Lars Vogel is the founder and CEO of the vogella GmbH and works as Eclipse and Android consultant, trainer and book author. He is a regular speaker at international conferences, He is the primary author of vogella.com. With more than one million visitors per month this website is one of the central sources for Java, Eclipse and Android programming information.
This entry was posted in Eclipse, Papercut and tagged , , , , . Bookmark the permalink.

9 Responses to Eclipse Papercut #5 – Getting external libraries as bundles

  1. Jeff McAffer says:

    Lars, better than checking these out from CVS you can just go to the Orbit download page (http://download.eclipse.org/tools/orbit/downloads/) and get the “built” bundles from one of the builds. Then just add this to your target platform and off you go.

    Note also that some years ago I donated a chapter from the RCP book that talks about the bundling process. It is a little out of date but the basic principles are the same. See http://eclipse.org/orbit/documents/RCP_Chapter20.pdf.

  2. Lars Vogel says:

    @Jeff: thanks for the download link and link to your RCP chapter

  3. Jeff, Lars – I think neither CVS checkout nor manual zip downloads are the way to go in 2009. Just opened a bug [https://bugs.eclipse.org/bugs/show_bug.cgi?id=290053] over at Orbit to provide a p2 repository. This way we could leverage the advantages of PDE Target provisioning to get the bundles into the target.

  4. Lars Vogel says:

    @Benjamin: Excellent idea!

  5. Eric Jain says:

    How up to date are the bundles in Orbit, in your experience? The Springsource bundle repository is great, but it can take weeks to months for a new version of a bundle to be added — even after filing a request.

  6. Lars Vogel says:

    @Eric the iText libary I downloaded was (I believe 1.5) while the latest available version of iText is 2.1.7. Therefore in this example the lib was quite old.

    I believe the requirements of libaries is driven by the Eclipse projects so if a project requires a recent version then Orbit has it. I’m not sure if there is general rule for libs in Orbit.

  7. You can skip a step when checking out orbit bundles. Instead of replacing with a branch or version, if you do “Check Out As…”, then the third wizard page lets you select the version.

  8. Lars Vogel says:

    @Andrew: Thanks for the tip.

  9. Daniel Milosevic says:

    As always, thanks for the tips.

Comments are closed.