Friday, November 27, 2009

Nesting categories

A recurring topic around categorization in p2 is the ability to nest categories.


Like for the categorization of bundles, the trick consists in using the eclipse feature editor to express the dependencies and thus construct the desired nesting.

Steps:
First phase, creation of the inner category.
  1. Create a feature project called InnerCategory1. In our example this will be the feature containing the elements to be shown categorized.
  2. Turn this feature into a category by creating a p2.inf and filling it with:
    properties.1.name=org.eclipse.equinox.p2.type.category
    properties.1.value=true
  3. Remove everything from the build.properties of the feature.
  4. Use the features and plug-ins tab of the feature editor to add content to be categorized.
This concludes the creation of the inner category. The following steps create the "top level" category.
  1. Create a feature project called TopLevelCategory
  2. Turn this feature into a category creating a p2.inf and filling it with:
    properties.1.name=org.eclipse.equinox.p2.type.category
    properties.1.value=true
  3. Remove everything from the build.properties of the feature.
  4. In the features tab of the editor, add InnerCategory1
  5. Export the top level feature enabling metadata generation
You can find the code of this example on the wiki.
Happy categorization, happy provisioning!

2 comments:

Don Laidlaw said...

I tried this. It may have worked at one point, but I cannot get it to work in 3.5.1. I am using the target platform to browse the repository, and it never shows any of the categories. After Adding a software site, and selecting Group By Category, the dialog shows "There are no categorized items".

Pascal said...

Don, I think that PDE has some issues with showing categories, so you may want to open a bug against them with an example repo. Thx.