„Trebuie să încerci necontenit să urci foarte sus, dacă vrei să poți să vezi foarte departe.” - Constantin Brâncuși

Eclipse RCP: Installing and Updating with p2 (Part I)

2 comentarii
With Eclipse RCP you can build complex platform independent applications using a powerful framework. As it is very important to keep your applications updated, one of the most interesting feature of Eclipse RCP is Equinox p2. Provisioning is the act of finding and installing new functionality, and updating or removing existing functionality. Equinox p2 is a provisioning platform for Eclipse-based applications and debuted in Eclipse v3.4 as a replacement for the old Update Manager.

Although the update system represents a very important aspect for a professional software product, the issues encountered during implementation by a lot of developers shows that it is not quite strait forward to build one and integrate it.


The scope of this article is to make a step-by-step presentation of how to create an update-able application using Eclipse RCP. The tutorial is composed of two parts:
  • In Part I we will create an Eclipse RCP application and we will also integrate the p2 update system.
  • In tutorial's Part II we will add a default update site, create a new version of the application and some new features which will be installed using the integrated update system created in Part I.
Development Environment
  • IDE: Eclipse Juno (4.2.2)
  • Eclipse Platform 3.8.2
  • JDK 1.7.2.0_21
Implementation
  1. As the example is intended for Eclipse Platform 3.x based applications, we should set the target platform in IDE: Window → Preferences → Plugin Development → Target Platform
  2. Create a New Plug-in Project and choose RCP application with a view from the Available Templates (add branding also).
  3. Create a Product Configuration for this plugin: Right click on the project → New
    → Product Configuration
  4. You can test your product by clicking on in application.product Overview tab. You have just created an Eclipse RCP application which can also be exported using Exporting section from application.product Overview tab:
  5. The product is currently based on plug-ins and contains (Dependencies tab) among others, the plug-in defined in Step 2.  As only features can be updated we will have to change the product and make it based on features:
  6. Create a new feature (File→New→Feature Project). Add the following plugins to this feature: org.eclipse.equinox.ds, org.eclipse.ui.forms and the plugin created on Step 2. (In my example ro.ecojocaru.rpc.application)
  7. Go to Product (application.product) and on Dependencies tab add the newly created feature on Step 6, plus the following features (required for product run and update system): org.eclipse.rcp, org.eclipse.equinox.p2.user.ui, org.eclipse.equinox.p2.core.feature, org.eclipse.equinox.p2.rcp.feature, org.eclipse.equinox.p2.extras.feature (or by adding the first two features and pressing Add Required will add the rest of them)
  8. At this step you can test your product again and it should run successfully based on features as it was running based on plug-ins.
  9. The next step is to integrate the menu that will allow user to perform updates. You can observe that in Eclipse IDE, updates can be handled through Help → Check for Updates and Help → Install New Software... Go to the application main plugin (created on Step 2), open plugin.xml and choose Extensions tab. On extension org.eclipse.ui.menus add a new menu with label &Help and id help. By creating this menu, update handler menu items  will automatically be added, due to *p2 features added to the product.
  10. Ensure that you have in product (application.product), Configuration tab, the correct start levels and auto-start flags set for the bundles required to run the p2 processes.
  11. You can now test again your product and notice that Help menu is added to the menu bar and also it contains update handler menu items, similar with the ones from Eclipse IDE.
  12. Update features do not work correctly in development mode so you will have to export the product (If you developed on a different JDK than system's default take care also to specify the location of the correct JRE or you can bundle the JRE for development environment with product in Launching tab).
  13. Go to your exported product and run the application. You now have an Eclipse RCP application with a functional p2 update system integrated.
In the second part of this tutorial we will add some update sites and also we will create new features to our application and update it using the integrated update system.

References
  • http://wiki.eclipse.org/Equinox/p2/Adding_Self-Update_to_an_RCP_Application

2 comentarii :

  1. Hi


    I’ve been facing this problem quite for some time and thought you’ll able to figure this out quickly.

    I created a sample eclipse RCP application with the following components

    com.module.product
    com.eclispe.p2.feature
    com.eclispe.p2.utils
    com.modules.feature
    com.module1

    I set all component versions to be 1.0.0.

    com.module.product has the .product file and p2.inf file. The product configuration is based on : features. The dependencies in .product file have com.modules.feature and org.eclipse.equinox.p2.rcp.feature.

    com.eclispe.p2.feature includes the plugin.com.eclispe.p2.utils that contributes the “Update Handler” to perform the live update from the menu.

    com.modules.feature is a dummy feature that depends on com.moudle.product and com.module1 (has dummy menu contribution).

    Now when i change the versions of all mentioned components to 1.0.1 and export it to the repository and then try to perform p2 update the old exported 1.0.0 version, the updated plugins and features are downloaded and installed successfully. But it seems for the feature components alone (e.g., com.modules.feature) the old feature component ( com.modules.feature v1.0.0) gets deleted in the feature folder and has only the new feature component(com.modules.feature v1.0.1) .
    The plugin folder has the old version as well as the new versions.

    Due to this, when i perform “revert” to 1.0.0 version from Installation History, i get a error dialog saying “Revert configuration has encountered a problem” and “No repository found containing org.eclispe.update.feature, com.modles.feature 1.0.0”.

    I remember long time before I was successfully able to perform revert. But now somehow, not sure what mistake I am making in the configuration, it doesn’t work as expected.

    RăspundețiȘtergere
  2. Hey, I enjoyed this blog, where you talk about the growth of freelancers; I also know one of the great freelancing platforms for app developers is Eiliana.com. They helped me find top ecommerce development freelancing work. Take a look at the freelancing platform too. It is a new yet great platform for technical experts.

    RăspundețiȘtergere