This post will describe how to install additional files such as configuration files, licenses etc. to a product along with a equinox feature installation. The files of interest is described below.
1. p2.inf
This file can be used to declare provisioning actions. More information about p2.inf format can be found at [1]. Various installation actions can be done by using touchpoints. A touchpoint presents an interface between p2 and a particular runtime configuration. Currently there are two touchpoints which contain instructions to performed, org.eclipse.equinox.p2.touchpoint.natives (os level instructions) and org.eclipse.equinox.p2.touchpoint.eclipse (p2 level instructions). Instructions fall in to one of the phases “install”, “uninstall”, “configure”, “unconfigure” in the p2 engine phases. Many of these instructions accept arguments.
Comprehensive documentation about touchpoints can be found at [2].
For this discussion we use natives touchpoint’s copy instruction. There is a particular syntax that has to be followed when specifying a instruction.
Citing from documentation..
As an example – an “install” instruction for a bundle might consist of the following statement:
installBundle(bundle:${artifact});
* installBundle is the action name
* bundle is the parameter name
* ${artifact} is the parameter value. The value ${artifact} signifies the use of a pre-defined variable named “artifact”.
Now let’s specify we need to copy conf.xml file to configuration folder upon feature installation.
instructions.configure = \ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/
conf.xml,target:${installFolder}/configuration/conf.xml,overwrite:true);
Here we have specified this instruction should be carried out in “configure” phase using instructions.configure directive. ${installFolder} is one of the predefined variables defined in all the phases which denotes the root folder for current profile.
2. build.properties
The role of the build.properties file is to map development-time structures in a bundle’s project onto the structures described in the bundle’s manifest and needed at runtime. It’s documentation can be found at [3]. In this case we configure it to copy our configuration file to the generated feature during feature build. Important thing to note is that build.properties file is used at build time while p2.inf is used at feature installation time to perform similar jobs.
We use a feature specific property root to indicate to list the files and folders to be copied to the root of the generated artifacts. Documentation about rootfiles can be found at [4].
Here are the entries in the build.properties used in this example.
custom=true
root=file:conf.xml
From documentation..
‘custom=true’ – indicates that the build script is hand-crafted as opposed to automatically generated. Therefore no other value is consulted.
“file:” prefix is used to denote a relative path while “absolute:” prefix is used to denote an absolute path. Relative paths are taken relative to the containing feature.
With these configurations in place we are ready to build the feature and provision it in to the respective profile.
[1] http://wiki.eclipse.org/Equinox/p2/Customizing_Metadata
[2] http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/p2_actions_touchpoints.html
[3] http://help.eclipse.org/helios/topic/org.eclipse.pde.doc.user/reference/pde_feature_generating_build.htm
[4] http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.pde.doc.user/tasks/pde_rootfiles.htm
Read Full Post »