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.
- IDE: Eclipse Juno (4.2.2)
- Eclipse Platform 3.8.2
- JDK 220.127.116.11_21
- 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
- Create a New Plug-in Project and choose RCP application with a view from the Available Templates (add branding also).
- Create a Product Configuration for this plugin: Right click on the project → New
→ Product Configuration
- 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:
- 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:
- 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)
- 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)
- 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.
- 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.
- 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.
- 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.
- 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).
- Go to your exported product and run the application. You now have an Eclipse RCP application with a functional p2 update system integrated.