Categorize your p2 repository

May 8, 2009 | 2 min Read

Have you had the experience of creating an interesting application, exporting it, generating a p2 repository, connecting to your repository, and *BAM*, nothing there!  The reason this happens is because you likely didn’t categorize your repository. Consider the following:

I have created three fun games for Cell Phones: Tetris, Snakes and Pong.  Of course, to implement these I used eSWT, eRCP, ECF, GEF, EMF, OCL, BIRT and EclipseLink.  I used PDE Build to build these games and published everything to a p2 repository for cell phone users to install.  Here’s the question, when a cell phone user clicks on “Add new applications” what should they see?  Should the list include EMF, BIRT, OCL, etc…?  In Eclipse 3.5, the p2 team has taken the approach that unless you categorize you features, they will not show up in a repository.  This decision gives you complete control over what your users can see. In Milestone 7, the PDE team released some tooling to make categorization easier.

To make use of the new categorization, first create a category file:

From here you can categorize your features in the category definition editor:

Finally, you can select your category file when you export your feature(s)

Now, when you open  your repository, you Installable Units should show up.

In addition to using the PDE Export wizard, you can also use the CategoryPublisher, to inject category descriptions into your existing repositories.  This can be invoked as follows:

java -console -consolelog -application org.eclipse.equinox.p2.publisher.CategoryPublisher -metadataRepository file://repository -categoryDefinition //category.xml

This approach also allows you to separate the categorization of your repository from the Installable Units. This means that you can generate a repository with all your features, and provide different categorizations for different users.

Ian Bull

Ian Bull

Ian is an Eclipse committer and EclipseSource Distinguished Engineer with a passion for developer productivity.

He leads the J2V8 project and has served on several …