A working example of custom p2 provisioning action - eclipse

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.

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).

If you want to let your touch point action working, there are two approaches,
install your plug-in firstly that provides the new touchpoint action. Then install the contents from the repository using the new touchpoint action.
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

Related

How do I create a context sensitive help in Run Configurations?

I have to create the help in Run Configurations on my plugin. As the same as this picture.
http://i.stack.imgur.com/bU5xL.png
I have searched on many sites include Google, or in textbooks,
but I haven't found how I do it. What should I do ? or Do you have any suggestions?
Thank you in advance.
This is done using the normal Eclipse context help system.
You specify the help context id in the org.eclipse.debug.ui.launchConfigurationTabGroups extension point using the helpContextId of the launchConfigurationTabGroup
Example from JUnit:
<extension
point="org.eclipse.debug.ui.launchConfigurationTabGroups">
<launchConfigurationTabGroup
type="org.eclipse.jdt.junit.launchconfig"
helpContextId="org.eclipse.jdt.junit.junit_tab_group"
class="org.eclipse.jdt.internal.junit.launcher.JUnitTabGroup"
id="org.eclipse.jdt.junit.launchConfigurationTabGroup.junit">
<launchMode
perspective="org.eclipse.debug.ui.DebugPerspective"
description="%JUnitTabGroupDescription.debug"
mode="debug">
</launchMode>
<launchMode
description="%JUnitTabGroupDescription.run"
mode="run">
</launchMode>
</launchConfigurationTabGroup>
</extension>
Use the org.eclipse.help.contexts extension point to declare a file containing the context help ids:
<extension point="org.eclipse.help.contexts">
<contexts file="contexts_JDT_JUnit.xml" plugin="org.eclipse.jdt.junit"/>
</extension>
and the context file contents:
<?xml version="1.0" encoding="UTF-8"?>
<?NLS TYPE="org.eclipse.help.contexts"?>
<contexts>
<context id="junit_tab_group">
<description>This launch configuration runs JUnit tests.</description>
<topic label="Using JUnit" href="gettingStarted/qs-junit.htm"/>
</context>
</contexts>
see the Eclipse help for more details.

What are the steps needed in DITA-OT to pass ANT command line parameters to custom plugin's override XSLT-script

This question follows this: Is it possible to pass custom ANT parameters into custom plugin with DITA-OT?
I have plugin folder called: com.mymods.pdf under DITA-OT/plugins folder. Under is explained the structure and files shortly (follows this example closely http://dita-ot.github.io/1.8/readme/dita2pdf-customization.html). Plugin works but now I want to pass ANT command line parameters into mycustom.xsl:
com.mymods.pdf/
cfg/
common/
vars/
en.xml
fo/
attrs/
mycustom.xsl
xsl/
mycustom.xsl
catalog.xml
integrator.xml
plugin.xml
build_mymods_pdf_template.xml (dita2com.mymods.pdf.init target is here and it depends on dita2pdf2)
build.xml (<project><import file="build_mymods_pdf.xml"/></project>)
insertParameters.xml (see the linked question for contents)
So where I need to apply changes and/or add new files?
I use the plugin from other location with "mainANT.xml" which has target and transtype for using "dita2mymodsPDF".
plugin.xml code:
<?xml version='1.0' encoding='UTF-8'?>
<plugin id="com.mymods.pdf">
<require plugin="org.dita.pdf2" />
<feature extension="dita.conductor.transtype.check" value="com.mymods.pdf" />
<feature extension="dita.transtype.print" value="com.mymods.pdf" />
<feature extension="dita.conductor.target.relative" file="integrator.xml" />
<feature extension="dita.conductor.com.mymods.pdf.param" file="insertParameters.xml"/>
<extension-point id="dita.conductor.com.mymods.pdf.param" name="PDF XSLT parameters"/>
</plugin>
build_mymods_pdf_template.xml code:
<?xml version='1.0' encoding='UTF-8'?>
<project name="com.mymods.pdf" default="com.mymods.pdf">
<property name="transtype" value="com.mymods.pdf"/>
<target name="dita2com.mymods.pdf.init">
<property location="${dita.plugin.com.mymods.pdf.dir}/cfg" name="customization.dir" />
<property location="${dita.plugin.com.mymods.pdf.dir}/xsl/fo/topic2fo_shell_fop.xsl" name="args.xsl.pdf" />
<property name="args.chapter.layout" value="BASIC" />
<property name="args.bookmark.style" value="COLLAPSED" />
<!--property name="args.fo.include.rellinks" value="nofamily" /-->
</target>
<target depends="dita2com.mymods.pdf.init, dita2pdf2" name="dita2com.mymods.pdf" />
</project>
Also integrator.xml code:
<?xml version='1.0' encoding='UTF-8'?>
<project name="com.mymods.pdf">
<target name="dita2com.mymods.pdf.init">
<property location="${dita.plugin.com.mymods.pdf.dir}/cfg" name="customization.dir" />
<property location="${dita.plugin.com.mymods.pdf.dir}/xsl/fo/topic2fo_shell_fop.xsl" name="args.xsl.pdf" />
<property name="args.chapter.layout" value="BASIC" />
<property name="args.bookmark.style" value="COLLAPSED" />
<!--property name="args.fo.include.rellinks" value="nofamily" /-->
</target>
<target depends="dita2com.mymods.pdf.init, dita2pdf2" name="dita2com.mymods.pdf" />
</project>
Not totally sure whether integrator.xml or build_mymods_pdf_template.xml is like it actually should. But this fileset works and uses mycustom.xsl (other for attributes and other for XSLT overrides). Now the problem is that how to get my own custom ANT parameters so the plugin can see its value.
This is really easy for pdf2 plugin but still can't yet get it working inside my com.mymods.pdf . I think I don't need to post catalog.xml because it just tells where are "mycustom.xsl" files that are working properly.
Really easy way, not the cleanest way to do this is:
Note: This applies for DITA-OT 1.8.4 check suitability for other versions.
Create your custom PDF plugin as told in: http://dita-ot.github.io/1.8/readme/dita2pdf-customization.html
Create "insertParameters.xml" as in: http://dita-ot.github.io/1.8/dev_ref/plugin-xsltparams.html
In my case with following custom parameters:
<?xml version='1.0' encoding='UTF-8'?>
<dummy>
<!-- EXAMPLE: <param name="paramNameinXSLT" expression="${antProperty}" if="antProperty"/> -->
<param name="custom.data1" expression="${custom.data1}" if="custom.data1"/>
<param name="custom.data2" expression="${custom.data2}" if="custom.data2"/>
</dummy>
Now drop this "insertParameters.xml" into DITA-OT\plugins\org.dita.pdf2
Create processing to custom.xsl under xsl\custom.xsl.
Here is an example code snippet for custom.xsl
<?xml version='1.0' encoding='UTF-8'?>
<snippet>
<xsl:param name="custom.data1"/>
<xsl:param name="custom.data2"/>
<fo:block><xsl:value-of select="$custom.data1"/></fo:block>
<fo:block><xsl:value-of select="$custom.data2"/></fo:block>
</snippet>
Run integrator.xml to integrate changes into your DITA-OT.
Give in command line commands for running your PDF scenario like: "ant dita2mypdf -f -Dcustom.data1="myCustomParameter1value" -Dcustom.data2="myCustomParameter2value"
Run the process to create PDF and your parameters should be visible!
What this question was really intended to achieve to get a step by step instruction to set all these things to work 100% in the custom plugin that not a single thing needs to be added into DITA-OT default plugins (not even single file into pdf2 folder as in this solution). This could make updating DITA-OT remarkably easier for future.
The cleaner? alternative to this approach is
add a placeholder insertParameters.xml to the root of the DITA-OT 1.8.5. The file does not exist in the standard DITA-OT 1.8.5
<?xml version='1.0' encoding='UTF-8'?>
<dummy>
<param name="dummy" expression="{$dummy} if="dummy"/>
</dummy>
add the override insertParameters.xml to the root of your plugin
<?xml version='1.0' encoding='UTF-8'?>
<dummy>
<param name="my.runtime.parameter" expression="{$my.runtime.parameter} if="my.runtime.parameter"/>
</dummy>
Then run ant -f integrator.xml
Without knowing precisely which parameters you need to pass, it's difficult to answer this question. However, let's assume you're invoking this from the command line and you've defined a transtype of mymodspdf. The command would look like this:
ant -f build.xml -Dtranstype mymodspdf -Dmyparameter1 paramval1 -Dmyparameter2 paramval2
HTH,
Julio J. Vazquez
Write Spirit
http://www.writespiritservices.com

Optional extension points in plugin.xml

I want to define an extension point in my plugin.xml which is not available in my target platform. This is fine for me, because I want to take advantage of it only if it's available .
However ,when I add it Eclipse flags it with an error
Unknown extension point: 'org.eclipse.ui.trace.traceComponents'
Can I somehow mark this extension point as optional? I know that I can reduce the Unresolved extension points severity per-workspace or per-project, but I'd rather not do that for just one error.
The complete plugin.xml is
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
id="org.apache.sling.slingclipse.preferences"
name="Slingclipse Preferences"
point="org.eclipse.ui.preferencePages">
<page
name="Slingclipse"
class="org.apache.sling.slingclipse.preferences.SlingclipsePreferencePage"
id="org.apache.sling.slingclipse.preferences.defaultPreferences">
</page>
</extension>
<extension
point="org.eclipse.core.runtime.preferences">
<initializer
class="org.apache.sling.slingclipse.preferences.PreferenceInitializer">
</initializer>
</extension>
<extension
point="org.eclipse.ui.startup">
<startup
class="org.apache.sling.slingclipse.SlingclipseStrartup">
</startup>
</extension>
<extension
point="org.eclipse.ui.importWizards">
<category
id="org.apache.sling.slingclipse.ui.wizards.sampleCategory"
name="Sling">
</category>
<wizard
category="org.apache.sling.slingclipse.ui.wizards.sampleCategory"
class="org.apache.sling.slingclipse.ui.wizards.ImportWizard"
icon="icons/sample.gif"
id="org.apache.sling.slingclipse.ui.wizards.ImportWizard"
name="Import from Repository">
<description>
Import a file from the local file system into the workspace.
</description>
</wizard>
</extension>
<extension
point="org.eclipse.ui.trace.traceComponents">
<component
id="org.eclipse.ui.trace.tracingPrefPage"
label="Slingclipse">
<bundle
name="org.apache.sling.slingclipse"></bundle>
</component>
</extension>
</plugin>
You are mixing two concepts here: Development time versus runtime.
Extension points are dependencies declared at development time. Therefore you should have the plugin defining that extension point in your target platform at development time. But you are right, you can generally write the manifest XML for extending that extension point without it being available. In practice this does not work well because many extension points require to implement an interface which itself is also defined in the (non existing) plugin.
To make the functionality be optional for a user (and to not force him to have the defining plugin), you need to make the installation of your plugin optional. But that is not related to the manifest and the use of extension points at all. E.g. you have to declare a feature containing your plugin and make that feature depend on the feature containing the plugin defining the extension point.

How Eclipse check available plugin in some environment?

I made some Eclipse plugin and update site on Indigo(Eclipse v3.7).
I can debug my plugin with new Eclipse instance, but I can't install my plugin via update site.
When I try to test install my plugin with Indigo (same environment as dev environment), the install wizard says:
Cannot complete the install because some dependencies are not satisfiable
com.mytest.helloworld.feature.group [1.0.0.201203071543] cannot be installed in this environment because its filter is not applicable.
(I tried to install my plugin with the same version of eclipse - Indigo.
And, My plugin works fine after manual install.)
Is there any check point to solve this?
How eclipse check available plugin? (based on what information?)
Here is my features.xml.
<?xml version="1.0" encoding="UTF-8"?>
<feature
id="com.mytest.helloworld"
label="mytest Feature"
version="1.0.0.qualifier"
provider-name="mytest.com"
plugin="com.mytest.helloworld"
os="aix,hpux,linux,macosx,qnx,solaris,win32"
ws="carbon,cocoa,gtk,motif,photon,win32,wpf"
nl="en,ko"
arch="ia64,ia64_32,PA_RISC,ppc,sparc,x86,x86_64">
<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>
<url>
<update label="mytest update" url="http://localhost:8088/plugin"/>
</url>
<requires>
<import plugin="org.eclipse.ui"/>
<import plugin="org.eclipse.core.runtime"/>
<import plugin="org.eclipse.core.expressions" version="3.4.101" match="greaterOrEqual"/>
<import plugin="com.android.ide.eclipse.adt" version="0.9.5" match="greaterOrEqual"/>
<import plugin="org.jdom" version="1.1.1" match="greaterOrEqual"/>
<import plugin="org.apache.commons.httpclient" version="3.1.0" match="greaterOrEqual"/>
<import plugin="org.eclipse.jdt.core" version="3.5.2" match="greaterOrEqual"/>
<import plugin="org.eclipse.core.resources" version="3.5.2" match="greaterOrEqual"/>
</requires>
<plugin
id="com.mytest.helloworld"
os="aix,hpux,linux,macosx,qnx,solaris,win32"
ws="carbon,cocoa,gtk,motif,photon,win32,wpf"
nl="en,ko"
arch="ia64,ia64_32,PA_RISC,ppc,sparc,x86,x86_64"
download-size="1000"
install-size="1000"
version="0.0.0"
unpack="false"/>
<plugin
id="com.mytest.helloworld.nl1"
os="aix,hpux,linux,macosx,qnx,solaris,win32"
ws="carbon,cocoa,gtk,motif,photon,win32,wpf"
nl="en,ko"
arch="ia64,ia64_32,PA_RISC,ppc,sparc,x86,x86_64"
download-size="1"
install-size="1"
version="0.0.0"
fragment="true"
unpack="false"/>
</feature>
Have you been able to run the plugin in a new Eclipse instance from your development environment? I.e press the run button and start a new Eclipse application with your plugin active.
It seems like there is some issue with filters, either you have defined a version requirement that doesnt work, or perhaps defined an OS that doesnt work. Posting your feature.xml might help.
Edit based on comment:
Try to remove the OS specific parts from the XML, i.e the properties "os", "ws", "arch" and perhaps "nl".
You would get
<feature
id="com.mytest.helloworld"
label="mytest Feature"
version="1.0.0.qualifier"
provider-name="mytest.com"
plugin="com.mytest.helloworld">
You only need to enter those properties if you are restricting the choice in some way, that is, your plugin contains OS specific code that will only work on some operating systems/architectures.

Buckminster RCP simple project materialization

After watching the webinar, skimming over the BuckyBook PDF, and following the Eclipse RCP build tutorial, I still don't know how to materialize a simple RCP plug-in project from CVS into an eclipse workspace.
Does anyone have an example with a CQUERY and an RMAP file, for a simple one project workspace?
Its actually easy.
Here is a sample CSPEC:
<?xml version="1.0" encoding="UTF-8"?>
<cq:componentQuery xmlns:cq="http://www.eclipse.org/buckminster/CQuery-1.0" resourceMap="example-site.rmap">
<cq:rootRequest name="example-site" componentType="eclipse.feature"/>
</cq:componentQuery>
Note the root request name property points to a component. If you have an RCP app which has a main bundle (say one that is the launching point to your app), then you would point to this component using the name property above. This CSPEC will then download all dependent components using the RMAP below, using search paths, providers etc.
The RMAP:
<searchPath name="default">
<provider
readerType="cvs"
componentTypes="osgi.bundle,eclipse.feature"
source="true"
mutable="true">
<uri format=":pserver:anon#cvs.local:/opt/data/cvsroot,{0}/">
<bc:propertyRef key="buckminster.component" />
</uri>
</provider>
</searchPath>
<searchPath name="galileo">
<provider readerType="eclipse.import" componentTypes="osgi.bundle,eclipse.feature"
mutable="false" source="false">
<uri format="http://download.eclipse.org/releases/galileo?importType=binary"/>
</provider>
</searchPath>
<locator searchPathRef="default" pattern="^example\-.*" />
<locator searchPathRef="galileo" failOnError="false" />