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.

3 comments:

Chris Aniszczyk (zx) said...

You have to becareful as the further you peel into an onion, there's a greater change you'll burst into tears ;)

Chengdong said...

We use the feature eclipse.idReplacer to replace the feature version. Works very well.

When we use it to replace plugin, it does not seem work.

Can you give a detail explanation about the useage of eclipse.idReplacer, especially for pluginids?

Is the version has to be 0.0.0? If I have a 3.2.2_xxx plugin, can I replace that plugin with 3.2.1_xxx?

Does this work for org.eclipse.pde.build_3.3.2.v20071019?
Thanks
-Chengdong

Unknown said...

Plug-in ids and Feature ids are treated the same. The format is
entry[, entry]*
entry := id:old_version,new_version

The old_version must match the version found in the feature.xml, and must end in "qualifier" or be "0.0.0". (I had to check the code to see this restriction.)

Therefore to replace a plugin 3.2.2.xxxx, the feature.xml must actually list version="3.2.2.qualifier", which can be replaced with "3.1.2.xxx".

The class that implements this task is named IdReplaceTask.