I have found using the new update manager (P2) in a standalone RCP application to be rather tricky. It's best to start by reading Equinox/p2/Adding Self-Update to an RCP Application and looking at the example (org.eclipse.equinox.p2.examples.rcp.sdkui) which can be retrieved from CVS: /cvsroot/rt (Eclipse CVS access info ). Place that application in your workspace.
Right-click your bundle project and make new Product Configuration
- select "Use an existing product" (and select the org.eclipse.equinox.p2.examples.rcp.sdkui.product)
- give product configuration file a name
After the product configuration is created, in the dependencies tab remove the org.eclipse.equinox.p2.examples.rcp.sdkui plugin.
Replace with your own bundle/plugin.
In your bundle, you must have a p2.inf file in the root. Mine has:
instructions.configure=\
addRepository(type:0,location:file:///C:/somepath/updatesite );\
addRepository(type:1,location:file:///C:/somepath/updatesite );
(Note that mine uses a file URL. You can of course also use an HTTP URL. If anyone can show me how to have multiple entries in here, let me know. I have yet to figure that out.)
You must also add the P2 UI elements to your application. The easiest way to do that is by adding the menu items to your application declaratively (i.e. via plugin.xml). On the extensions tab, click add and select org.eclipse.ui.menus. Then right-click that entry and add -> new -> menu contribution. Set the locationURI to menu:org.eclipse.ui.main.menu?after=additions. Now right-click -> new -> menu and give it a user friendly label. Then right click that menu and -> new -> command and I did this 4 times for these commandId's which each show up on the menu: org.eclipse.ui.window.preferences, org.eclipse.equinox.p2.ui.sdk.update, org.eclipse.equinox.p2.ui.sdk.install, org.eclipse.ui.help.aboutAction
Use Eclipse Product Export Wizard found in overview tab of product configuration file. During export, make sure "Generate metadata repository" is selected.
When you launch you should be able to use the install and update commands as well as verify installation configuration from the preferences and about menu items.
No comments:
Post a Comment