1. Follow the general feature hierarchy when developing Carbon features
- Aggregate/Composite feature
- Server feature
- Console feature
- Common feature (if any)
2.
Follow the general naming convention in features : Just like the
feature’s ID is important to identify features at runtime , the name is
important for the users to identify features uniquely in the UI. So
every feature’s name should follow a convention, be unique and should be
self-describing. 3. Use p2 properties meaningfully in the advice file given at the p2-feature-gen goal in your feature’s pom.xml
- org.wso2.carbon.p2.category.type: server | console | common
Above
property is used to define whether the feature is a backend (server),
UI (console) or a common feature. This property is read by feature
manager for BE, FE filtering
- org.eclipse.equinox.p2.type.group: true | false
This property is important to be explicitly defined as ‘false’ when the feature is not
a group type feature and you don’t want it to be listed in feature
manager UI. (We list down group type features in the feature manager UI)
For sub features (console, ui) which are dependencies to the aggregate-feature use this property as false.
Usage Sample :
<adviceFile>
<properties>
<propertyDef>org.wso2.carbon.p2.category.type:server</propertyDef>
<propertyDef>org.eclipse.equinox.p2.type.group:false</propertyDef>
</properties>
</adviceFile>
4.
Correctly give the relative path to the feature.properties in the
feature’s pom: This properties file contains the license and copyright
text to be viewed in feature manager UI. The file is located at
branches/4.0.0/features/etc/feature.properties.
The
relative path from your feature to this file needs to be given
correctly in order to load the license and copyright in the UI
Usage Sample:
<propertiesFile>../../../etc/feature.properties</propertiesFile>
5. Use correct carbon-p2-plugin instruction to construct the features
Usage Sample :
<bundles>
<bundleDef>org.wso2.carbon:org.wso2.carbon.security.mgt</bundleDef>
</bundles>
(eg:
Include the console, server and common features in your composite
feature. And set org.eclipse.equinox.p2.type.group: true only in your
composite feature)
Usage Sample :
<includedFeatures>
<includedFeatureDef>org.wso2.carbon:org.wso2.carbon.core.common.feature:4.0.2</includedFeatureDef> <includedFeatures>
Usage Sample :
<importBundles>
<importBundleDef>org.wso2.xkms.wso2:xkms</importBundleDef>
</importBundles>
Usage Sample :
<importFeatures> <importFeatureDef>org.wso2.carbon.core.server:${wso2carbon.version}</importFeatureDef>
</importFeatures>
6. Use p2-touchpoint instructions to perform additional configuration operations for the feature.
Using
touchpoint instructions we can do things like copying configuration
files to target system during a p2 phase (collect, configure, install,
uninstall, unconfigure). You can define these touchpoint instructions in
the p2.inf file of your feature.
Usage Sample :
instructions.configure = \
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/features/org.wso2.carbon.apimgt.publisher_${feature.version}/publisher/,target:${installFolder}/../deployment/server/jaggeryapps/publisher,overwrite:true);\
Common mistakes in creating features
Not
using org.eclipse.equinox.p2.type.group:false property in
sub-features: Because of this we can see low-level sub-features listed
as top-level features in the featuremanager UI.
Not
giving the relative path correctly to feature.properties. This causes
the license and copyright not being loaded in the feature manager UI.