Thursday, October 04, 2007

Selecting Plug-in Versions in a Headless Product Build

As Pascal likes to say: "PDE.Build is an onion." Don't be afraid to reach in and savor those inner layers. Here is an example:

We support building from a .product file. Generally, people base their product files on a list of plug-ins. There is currently no way to specify plug-in versions in the product file. If you have a requirement on a specific version of some bundle and for some reason there are multiple versions in your target, then you may be stuck with pde.build choosing the wrong version for you.

In a product build, a container feature is generated based on the contents of the .product file and the build is run using this generated feature. Features can specify the versions of the plug-ins they want to include, or they can specify "0.0.0" which means any version. They can also specify a version like "3.2.1.qualifier" which means any version starting with "3.2.1". (Though beware of this bug). The generated feature simply specifies "0.0.0" for each plug-in from the .product file.

PDE.Build provides an eclipse.idReplacer ant task. It uses this task to replace versions in the feature.xml with the actual versions that are built. It is easy to imagine using this task to modify the generated feature.xml to specify the plug-in versions you want before fetching or generating scripts.

In your customTarges.xml preFetch (or preGenerate) task, do something like this:

<eclipse.idReplacer
featureFilePath="${buildDirectory}/features/org.eclipse.pde.build.container.feature/feature.xml"
selfVersion="1.0.0"
featureIds=""
pluginIds="org.eclipse.foo:0.0.0,1.3.0.qualifier,org.bar:0.0.0,3.2.0.qualifier," />
Beware of this bug in 3.3.0, and this bug in 3.3.1.