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.

3 Comments
  • Pascal Rapicault
    Posted at 5:20 am, March 15, 2012

    To be clear, the actual support to express negative requirements has been added in 3.6. What is new here is the ability to express it in the p2.inf so you no longer have to hack metadata by hand in the repository file, or do it programmatically.

  • Gunnar
    Posted at 7:50 am, March 15, 2012

    That has been on my waiting list for quite some time now. Thanks for implementing it!

  • Ralf Sternberg
    Posted at 12:06 pm, March 15, 2012

    Thank you so much for resolving this, Ian! Do you know if Tycho is bound to a particular version of p2? In this case we’d have to wait for a new Tycho to pick up the change.