Sunday, August 19, 2012

How to define a Feature Category to represent a WSO2 Product

In the last post I've explained how to install feature-categories in Carbon from Feature Manager. In this blog post I will briefly discuss how to publish a feature category to WSO2 p2-repo.

A feature category in the p2-repo represents a certain WSO2 product. (eg: Application Server, Data Services Server etc..) The category will categorize all required features to constitute the particular product. It makes life easy for a user to install a set of features relevant to a product at once by selecting the relevant product category.
eg: if the user wants to install Application Server on top of Carbon, the user can simply select the "Application Server" category and install all features grouped under that category.

The process of publishing a feature category to p2-repo should follow below steps;

1. First you need to know all the features required to install your product; this is defined in the product's p2-profile-gen.
eg: All features required to construct Application Server is defined in it's p2-profile-gen

2. Make sure all the required features are published to the repository in the carbon-p2-plugin's p2-repo-gen goal. So all required features should be included as <featureArtifact>s. 

3. Now create a <category> to represent your product under <categories> section which represents all the feature categories published in the p2-repo.

4. Include the relevant feature list as <catFeature>s under your category except the product's styles feature. A catFeature represent a required p2-feature for a category. Please note that, <id> and <version> are required for a <catFeature>. 
<id> is the feature's p2-artifact-id given in the feature's pom under p2-feature-gen goal of the carbon-p2-plugin. If a version for the p2-artifact isn't explicitly defined, it will inherit the feature's maven artifact's version.
(eg: In platform/features/admin-mgt/org.wso2.carbon.admin.mgt.feature/pom.xml the p2 artifact-id given for org.wso2.carbon.admin.mgt.feature is org.wso2.carbon.admin.mgt )

5. The styles feature should not be grouped under the Product category by default, because then if the user selects several product categories at once, it will try to install several product styles at once and break the server's style. The solution is to have a seperate feature category for Product Styles. Then the user can select the product style to install separately.

6. As the final step, it's important to test the installation of your category on Carbon at-least once, to see if there are any missing requirements for the installation. 

So following above 6 simple steps you can define a category of features to cluster the required set of features to install a WSO2 Product on top of Carbon.