A working example of custom p2 provisioning action
Asked Answered
R

2

9

I’m trying to write a custom p2 provisioning action to execute my own code when installing feature. Doing so with installHandler for Update Manager was easy, but as for p2, there’s absolutely no docs on this topic in the web, most of the time eclispe just silently ignores me (even in a log), and the only example I’ve found is not working.

So, if somebody can point me at a working example of custom provisioning action, that would help me understand the whole thing.

Thanks.

Remissible answered 27/5, 2011 at 15:23 Comment(0)
R
10

Finally, I’ve got it working somehow:

example_plugin:

plugin.xml:

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.5"?>
<plugin>
  <extension point="org.eclipse.equinox.p2.engine.touchpoints" id="example" name="Eclipse Touchpoint">
    <touchpoint type="com.company.example.plugin" class="org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint" version="1.0"/>
  </extension>

  <extension point="org.eclipse.equinox.p2.engine.actions">
    <action
      class="com.company.example.plugin.CustomAction"
      name="do_custom_action"
      touchpointType="com.company.example.plugin"
      touchpointVersion="1.0"          
      version="1.0">
    </action>
  </extension>
</plugin>

META-INF\p2.xml:

provides.0.namespace=com.company.example.plugin
provides.0.name=do_custom_action
provides.0.version=1.0

example_feature:

feature.xml:

<?xml version="1.0" encoding="UTF-8"?>
<feature id="com.company.example.feature" label="Maven installer feature" version="2.2.1.qualifier">
  <description url="http://www.example.com/description">[Enter Feature Description here.]</description>
  <copyright url="http://www.example.com/copyright">[Enter Copyright Description here.]</copyright>
  <license url="http://www.example.com/license">[Enter License Description here.]</license>

 <requires>
   <import plugin="com.company.example.plugin"/>
 </requires>

 <plugin
   id="com.company.example.plugin"
   download-size="0"
   install-size="0"
   version="0.0.0"
   unpack="false"/>
</feature>

p2.inf:

metaRequirements.0.namespace=com.company.example.plugin
metaRequirements.0.name=do_custom_action
metaRequirements.0.range=1.0

instructions.configure = com.company.example.plugin.do_custom_action();

General comments:

  • Custom touchpoint action is stored in a plugin as a regular class.
  • Update site must contain proper artifacts.jar/content.jar (don’t know why, took a lot of time to debug this).
Remissible answered 30/5, 2011 at 18:32 Comment(1)
META_INF\p2.xml should be META_INF\p2.infPronucleus
G
0

If you want to let your touch point action working, there are two approaches,

  1. install your plug-in firstly that provides the new touchpoint action. Then install the contents from the repository using the new touchpoint action.
  2. the iu depending on the new touchpoint action need require the bundle provides the new touchpoint action, it exactly likes what you found. See the example code attached by Simon Kaegi
Glovsky answered 30/5, 2011 at 6:56 Comment(1)
Thaks Kane! Do you know if there’s a way to automatically download plugin with custom touchpoint before calling it? What about example code, I cannot get it working — bundle2 doesn’t get downloaded automatically.Remissible

© 2022 - 2024 — McMap. All rights reserved.