Wednesday, June 4, 2014

Tycho 11: Install root level features


Introduction

Do you know about root level features?

Components installed in eclipse are called installable units (IUs). These are either features or products. Now IUs might be containers for other features, creating a tree like dependency structure. Lets take a short look at the Installation Details (menu Help / About Eclipse) of our sample product from tycho tutorial 8:

We can see that there exists one root level feature Tycho Built Product which contains all the features we defined for our product. What is interesting is, that the Update... and Uninstall... buttons at the bottom are disabled when we select child features.

So in an RCP application we may only update/uninstall root level features. This means that if we want to update a sub component, we need to create a new version of our main product. For a modular application this might not be a desired behavior.

The situation changes when a user installs additional components into a running RCP application. Such features will be handled as root level features and can therefore be updated separately. So our target will be to create a base product and install our features in an additional step.

Great news is, that tycho 0.20.0 allows us to do this very easily.

Tycho Tutorials

For a list of all tycho related tutorials see Tycho Tutorials Overview

Source code for this tutorial is available on github as a single zip archive, as a Team Project Set or you can browse the files online.

Step 1: Identify independent features

Tycho will do all the required steps for us, we only need to identify features to be installed at root level. So open your product file using either the Text Editor or XML Editor. Locate the section with the feature definitions. Now add an installMode="root" attribute to any feature to be installed on root level.
   <features>
      <feature id="org.eclipse.e4.rcp"/>
      <feature id="org.eclipse.platform"/>
      <feature id="com.codeandme.tycho.plugin.feature" installMode="root"/>
      <feature id="com.codeandme.tycho.product.feature"/>
      <feature id="org.eclipse.help" installMode="root"/>
      <feature id="org.eclipse.emf.ecore"/>
      <feature id="org.eclipse.equinox.p2.core.feature"/>
      <feature id="org.eclipse.emf.common"/>
      <feature id="org.eclipse.equinox.p2.rcp.feature"/>
      <feature id="org.eclipse.equinox.p2.user.ui"/>
      <feature id="org.eclipse.rcp"/>
      <feature id="org.eclipse.equinox.p2.extras.feature"/>
   </features>

Make sure to update the tycho version to be used to 0.20.0 or above.

Nothing more to do, build your  product and enjoy root level features in action.


3 comments:

  1. I wasn't able to find any hint in the Tycho documentation on where this installMode property should actually be specified. Thanks a lot!

    ReplyDelete
  2. Hi,

    Thanks a lot for your tutorial. I have a question, though, which you might (or not) be able to answer… I’m in charge of a quite large RCP application (https://github.com/gama-platform/gama) where developers used to use PDE build to produce releases, before we recently moved to Tycho for that. One problem we are facing, however, is that if the features in our product are marked with the property “installMode=”root””, they are not exported by PDE build (i.e. they are not present in the plugins directory of the application, and the application is not functional). And if we remove the property, they are correctly exported again. But of course, we lose in that case the ability to update the features in the resulting release…

    Do you have an idea of why it is the case ? And any idea on how we could enable developers to use either PDE build or Tycho while having plugins correctly exported and features marked as updatable ? (keeping PDE build around is for the moment necessary for quick testing of functionalities in the release — and because it is more convenient for first-time developers to just have to click on a button rather than going through the process of Maven/Tycho builds).

    Thanks in advance for any answer, even negative 🙂

    Cheers
    Alexis

    ReplyDelete