Publishing Negation Requirements

Publishing Negation Requirements

The Eclipse provisioning platform (p2) has a pretty awesome resolver (the planner) that computes all the requirements when you try to install something.  It’s this awesome resolver that let’s you install something like the „Eclipse C/C++ Development Tools“ without worrying about all the dependencies you need.

When most people think about dependency resolution they think about the requirements that must be present for an install to succeed.  However, that’s not the only type of requirement that exists.  Another requirement is a negation requirement. That is, something that must not exist for the installation to succeed.

A useful example of a negation requirement comes to mind when you think of  RAP (the Remote Application Platform). RAP is not intended to be installed into your IDE, but rather it’s meant to be installed in your target platform and deployed into a run-time environment.  If you do install RAP into your IDE then you’re asking for trouble (since RAP is an alternate replacement for SWT, your widget library).  RAP has traditionally used some pretty hacky work-arounds to ensure that it won’t be installed in the IDE.

With the up coming Eclipse milestone (Eclipse Juno M6), you can publish negation requirements. This means, RAP (and other components) can specify requirements that must not exist.  Negation requirements are specified by setting the cardinality (both min and max) to 0.  This is done using the p2.inf file.

In this case, our example feature wil not install if BadFeature is present.  Now, if I build and publish this and try to install, p2 will fail.

But, if I de-select the ‚BadFeature‚, then all is well again.

If you need negation requirements, please try this out when M6 is available and report bugs / feedback.