licenses p2 pde

Implementing shared licenses with 3.7M5

This is the best Eclipse license I’ve ever seen.

Image © chriscardinal, http://www.flickr.com/photos/disatasu/3243844762/ licensed under Creative Commons by-nc-sa 2.0

Conversely, dealing with license files in Eclipse features is a bit painful.  Today, each time the Eclipse license changes, you need to copy the new license files to your features.  The license files included in the Eclipse SDK are highlighted below:

These same files are included in the 46 features that the Eclipse and RT Equinox project builds.  This is very tedious to update when the license files change. Lots of copy and paste. The license text also appears in the feature.properties.

In Eclipse 3.7M4,  the PDE and p2 teams added support for shared licenses.

The license files will be copied from the license feature to the feature that refers to it.  In 3.7M5, I modified our features to use this shared licenses. For instance, the beginning of the feature.xml for the Eclipse SDK now looks like this:



To implement this, I followed these steps. 

1. Create a license feature. This feature doesn’t include any bundles or features. It only stores the license files which its build.properties reference.   The feature.properties has only two properties – the licenseURL and license. 

2. Update the existing features to reference the license feature.  Remove the license files from these features.  Remove the references to the license files from your feature’s build.properties.  The values will be inherited from the build.properties of the license feature.  Remove the name and values of licenseURL and license from the feature.properties. These will be included from the license feature. Ensure that you don’t have duplicate properties in the feature.properties of the license feature and feature your are updating. This will cause a build failure.

3.  Update your map files to include to the new feature. You don’t need to nest the feature in another feature to fetch it, this happens automatically. For example, this is where our license feature is located

feature@org.eclipse.license=v20110121,:pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse,,org.eclipse.sdk-feature/features/org.eclipse.license

4. Run a test build. Fix typos until you have a clean build. Verify that all your features still include the appropriate license files. 

There isn’t an IU for the license feature included in the p2 repository.  The license text is included in the metadata.

Note that you’ll need to build with 3.7M5 bundles.  There was a bug in the 3.7M4 bundles that prevented shared licenses from working in generated source features.

The advantage of this approach is that when the license files are updated, we’ll only need to update the license feature.  We’ll also have to increment the versions of the license feature in the referring feature, but that’s a simple search and replace. 

Some other implementation details: I could have also stored the copyright information in the feature.properties of the license feature. However, the copyrights of our features are not identical, so I didn’t choose this approach. This may be useful for other teams.

Thanks to the  PDE and p2 team for implementing this!

Further references

Bug 306818 – Improve license support in p2.
License mechanism description in wiki
Bug 332662 – Adopt new feature that allows to share the license file

3 comments on “Implementing shared licenses with 3.7M5

  1. Very cool. Maintaining this stuff has always been an annoyance. You mentioned copyright text. Is it possible to store other shared properties such as Update Site names, etc.. using this mechanism?

    Like

  2. Miles, all the properties in the license feature will be inherited by the feature referencing it. Thus you could inherit the copyright text. I don't do that because the same text doesn't apply to all our features. The same thing applies for us for our feature names, they are all different 🙂

    Like

  3. This blog contains some important missing bits.

    The feature.properties defines two
    properties

    license
    licenseURL

    The values for the former is the actual license text, which is hard to get in .properties format. (i.e. using \ for continuing on the next line. The later is the URL for the local file or http url.

    When setting the shared license, the following entries in the feature.xml remain unchanged.
    These should be edited in the xml editor of the feature editor and set to:

    %license

    this will replace with the properties in the features.properties from the shared license feature.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: